Exemplo n.º 1
0
def trial_1():
    vpvk = vk.OnsetVoiceKey()
    vpvk = vk.OffsetVoiceKey(file_out='data/trial.wav')

    locM_stim.setImage("materials/EmjAn04.png")
    locM_stim.setAutoDraw(True)
    vpvk.start()
    vpvk.tStart = trialClock.getTime()

    frameN = -1  # number of completed frames (so 0 is the first frame)
    while frameN < int(round(2.0 / framelength)):
        frameN += 1
        myWin.flip()

    vpvk.stop()
    locM_stim.setAutoDraw(False)

    print(round(vpvk.event_onset, 3))

    uword.setText("P")
    uword.draw()
    myWin.callOnFlip(trialClock.reset)
    myWin.flip()
    resp, rt = get_resp()
    print(resp, rt)

    myWin.flip()
    core.wait(0.5)
Exemplo n.º 2
0
    core.wait(0.18)

    ##mask
    mask.pos = pos_options[int(trials[trialcounter, 4])]
    mask.draw()
    fix.draw()
    win.flip()
    core.wait(1)

    ## wait for the response
    if participant % 2 == 0:  #even participants
        if trials[trialcounter, 10] == 1:
            event.clearEvents(eventType='keyboard')
            keys = event.getKeys(keyList=respons)
            vpvk = vk.OnsetVoiceKey(sec=2,
                                    file_out="data/PPN_{}/trial_{}.wav".format(
                                        participant, trialcounter))
            vpvk.start()
            instruct_answer.draw()
            win.flip()

            time.sleep(2)
            vpvk.stop()
            RT = vpvk.event_onset

            if RT > 0:
                keys = ['space']
            else:
                keys = ['f']

            if keys == 'escape':
Exemplo n.º 3
0
        currentLoop = B1_trials
        # abbreviate parameter names if possible (e.g. rgb = thisB1_trial.rgb)
        if thisB1_trial != None:
            for paramName in thisB1_trial:
                exec('{} = thisB1_trial[paramName]'.format(paramName))

        # ------Prepare to start Routine "trial"-------
        t = 0
        trialClock.reset()  # clock
        frameN = -1
        continueRoutine = True
        routineTimer.add(2.000000)
        # update component parameters for each repeat
        # Create a voice-key to be used:
        vpvk = vk.OnsetVoiceKey(sec=2,
                                file_out='data/trial_' +
                                str(B1_trials.thisN).zfill(3) + '_' + Stim +
                                '.wav')

        # Start it recording (and detecting):
        # non-blocking; don't block when using Builder
        vpvk.start()
        # keep track of which components have finished
        trialComponents = [prompt]
        for thisComponent in trialComponents:
            thisComponent.tStart = None
            thisComponent.tStop = None
            thisComponent.tStartRefresh = None
            thisComponent.tStopRefresh = None
            if hasattr(thisComponent, 'status'):
                thisComponent.status = NOT_STARTED
Exemplo n.º 4
0
            thisComponent.setAutoDraw(False)

    # ------Prepare to start Routine "prac_trial"-------
    t = 0
    prac_trialClock.reset()  # clock
    frameN = -1
    continueRoutine = True
    # update component parameters for each repeat
    Stroop_Text.setColor(StroopColor, colorSpace='rgb')
    Stroop_Text.setText(StroopText)
    prac_key_resp = keyboard.Keyboard()
    practice_cue_txt.setText(practice_cue)
    prac_cont.setText(practice_cont)
    # Create a voice-key to be used:
    vpvk = vk.OnsetVoiceKey(sec=2,
                            file_out='data/trial_' +
                            str(Practice.thisN).zfill(3) + '.wav')

    # Start it recording (and detecting):
    # non-blocking; don't block when using Builder
    vpvk.start()
    # keep track of which components have finished
    prac_trialComponents = [
        Stroop_Text, prac_key_resp, practice_cue_txt, prac_cont
    ]
    for thisComponent in prac_trialComponents:
        thisComponent.tStart = None
        thisComponent.tStop = None
        thisComponent.tStartRefresh = None
        thisComponent.tStopRefresh = None
        if hasattr(thisComponent, 'status'):
Exemplo n.º 5
0
        elif thisTrial[0][0] == "R":
            handSide = 2

        trialClock.reset()

        if (thisTrial[0] == 'break'):
            break_text.draw()
            win.flip()
            event.waitKeys()
            core.wait(2)
        else:

            numTrial = numTrial + 1

            audio_file = subj + "_" + session + "_resp" + str(numTrial)
            AudioResp = voicekey.OnsetVoiceKey(sec=30, file_out=audio_file)

            hand.setImage("assets/hand-pics/" + thisTrial[0])
            hand.draw()
            # refresh the screen
            win.flip()
            # wait for audio response
            voiceResp = AudioResp.wait_for_event(plus=1)
            # append responses
            responses.append([
                handSide,
                float(thisTrial[0][2]),
                float(thisTrial[0][4:7]), 99,
                float(AudioResp.event_onset)
            ])
            while trialClock.getTime(