top of page
TrajTracker Paradigms: Sample scripts
Discrete-choice with custom stimuli

If the stimuli are not text, you have to create them in your own code. However, plugging them into TrajTracker is easy.

​

In this example, the stimuli are left and right arrows, so the script loads these two pictures. The rest is handled by the TrajTracker infra: on each trial, several left and right arrows appear, and the task is to choose the side to which the majority of arrows are pointing. The finger must not reach the response button before the last arrow (this is defined in the CSV trials file).

import expyriment as xpy

import trajtracker as ttrk

import trajtrackerp as ttrkp

from trajtrackerp import dchoice

 

if not xpy.misc.is_android_running():

    xpy.control.defaults.window_mode = True

    ttrk.log_to_console = True

 

config = dchoice.Config("ChooseArrowDir", max_movement_time=3, data_source="choice_2.csv",

                        use_generic_targets=True, use_text_targets=False,

                        feedback_stim_type='rectangle', feedback_select_by='accuracy',

                        feedback_place='middle',

                        speed_guide_enabled=True)

stimuli = {

    'L': xpy.stimuli.Picture("arrow-left.bmp"),

    'R': xpy.stimuli.Picture("arrow-right.bmp")

}

 

 

#-- Initialize Expyriment

exp = ttrk.initialize()

xpy.control.start(exp)

if not xpy.misc.is_android_running():

    exp.mouse.show_cursor()

 

#-- Get subject info

(subj_id, subj_name) = ttrkp.common.get_subject_name_id()

 

#-- Initialize the experiment objects

 

exp_info = dchoice.initialize_experiment(config, exp, subj_id, subj_name)

exp_info.generic_target.available_stimuli = stimuli

 

exp_info.generic_target.onset_time = [0, 0.3, 0.6, 0.9, 1.2, 1.5]

exp_info.generic_target.duration = 0.1

 

#-- Run the experiment

dchoice.run_trials(exp_info)

 

#-- Shutdown Expyriment

xpy.control.end()

bottom of page