コード例 #1
0
#draw the stimuli
trial_routine = Routine(window=mywin, frames_per_second=frames_per_second, escape_key=escape_key)

for bl in range(n_blocks):
    block = blocks[bl]

    trial_routine.wait_for_time_limit(
            components=[messages_beginning[bl]], 
            time_seconds=message_beginning_duration, 
            label='message_beginning')

    for t in range(n_trials):
        # put here things that change at the beginning of every trial
        image_trial = 'patch{}.png'.format(block['image_number'][t])
        correct_resp_trial = block['correct_response'][t]
        patch_image.image = os.path.join(directory_stimuli, image_trial)

        # first event
        trial_routine.wait_for_time_limit(
            components=[], 
            time_seconds=fixation_duration, 
            label='fixation_cross')

        # second event
        key, rt = trial_routine.wait_for_keys_or_time_limit(
            components=[patch_image],
            time_seconds=choice_timeout,
            valid_keys=choice_keys,
            label='patch_choice')
        
        # third event
コード例 #2
0
stimuli['trial'] = np.arange(n_trials) + 1

#create the dataframe
data = pd.DataFrame([])

#draw the stimuli
trial_routine = Routine(window=mywin,
                        frames_per_second=frames_per_second,
                        escape_key=escape_key)

for t in range(n_trials):
    # put here things that change every trial
    left_feedback.text = '%s' % stimuli.loc[t, 'left_feedback']
    right_feedback.text = '%s' % stimuli.loc[t, 'right_feedback']

    left_picture.image = os.path.join(os.getcwd(), 'stimuli', 'example_4',
                                      stimuli.loc[t, 'left_image'])
    right_picture.image = os.path.join(os.getcwd(), 'stimuli', 'example_4',
                                       stimuli.loc[t, 'right_image'])

    # first event
    trial_routine.wait_for_time_limit(components=[fixation_cross],
                                      time_seconds=fixation_duration,
                                      label='fixation_cross')

    # second event
    key, rt = trial_routine.wait_for_keys_or_time_limit(
        components=[left_picture, right_picture],
        valid_keys=choice_keys,
        time_seconds=choice_time_limit,
        label='gamble_choice')
    data = data.append(