context.StroopContext

stroop_task.context.StroopContext(
    language,
    word_color_dict=dict(),
    msgs=dict(),
    startblock_mrk=64,
    endblock_mrk=64,
    starttrial_mrk=2,
    endtrial_mrk=4,
    congruent_mrk=0,
    incongruent_mrk=0,
    lift_off_mrk=8,
    reaction_mrk=16,
    timeout_mrk=16,
    stimulus_time_s=3.0,
    pre_stimulus_time_s=1.0,
    wait_time_min_s=1.0,
    wait_time_max_s=2.0,
    instruction_time_s=1000.0,
    results_show_time_s=5.0,
    arrow_down_press_to_continue_s=0.5,
    classical_timeout_s=45,
    focus='color',
    reactions=list(),
    block_stimuli=list(),
    known_stimuli=dict(),
    current_stimulus_idx=0,
    current_stimuli=list(),
    white_y_offset_px=100,
    font_size=36,
    instruction_font_size=16,
    fullscreen=False,
    screen_width=800,
    screen_height=600,
    tic=0,
    tic_down=0,
    marker_writer=get_marker_writer(),
    has_window_attached=False,
)

A class to represent the context for the Stroop task.

Attributes

Name Type Description
language str The language setting for the Stroop task.
word_color_dict dict A dictionary mapping words to their corresponding colors. See configs/.yaml.
msgs dict A dictionary containing messages for the Stroop task. See configs/.yaml.
startblock_mrk int Marker for the start of a block. See configs/task.yaml.
endblock_mrk int Marker for the end of a block. See configs/task.yaml.
starttrial_mrk int Marker for the start of a trial. See configs/task.yaml.
endtrial_mrk int Marker for the end of a trial. See configs/task.yaml.
congruent_mrk int Marker for congruent stimuli. See configs/task.yaml.
incongruent_mrk int Marker for incongruent stimuli. See configs/task.yaml.
lift_off_mrk int Marker for lift-off. See configs/task.yaml.
reaction_mrk int Marker for reaction. See configs/task.yaml.
timeout_mrk int Marker for timeout. See configs/task.yaml.
stimulus_time_s float Duration in seconds for stimulus presentation. See configs/task.yaml.
pre_stimulus_time_s float Duration in seconds for pre-stimulus interval. See configs/task.yaml.
wait_time_min_s float Minimum wait time in seconds. See configs/task.yaml.
wait_time_max_s float Maximum wait time in seconds. See configs/task.yaml.
instruction_time_s float Duration in seconds for instruction display. See configs/task.yaml.
results_show_time_s float Duration in seconds for results display. See configs/task.yaml.
arrow_down_press_to_continue_s float Duration in seconds for arrow down press to continue. See configs/task.yaml.
classical_timeout_s float Timeout duration in seconds for classical tasks. See configs/task.yaml.
focus Literal['text', 'color'] Focus of the Stroop task, either “text” or “color”.
reactions list List to track reactions.
block_stimuli list List of stimuli for the current block.
known_stimuli dict Dictionary of known stimuli.
current_stimulus_idx int Index of the current stimulus.
current_stimuli list List of current stimuli for drawing.
white_y_offset_px int Y-offset in pixels for white stimuli. See configs/gui.
font_size int Font size for stimuli. See configs/gui.
instruction_font_size int Font size for instructions. See configs/gui.
fullscreen bool Flag for fullscreen mode. See configs/gui.
screen_width int Width of the screen. See configs/gui.
screen_height int Height of the screen. See configs/gui.
tic float Time keeping variable.
tic_down float Time keeping variable for countdown.
marker_writer MarkerWriter Marker writer for the Stroop task.
has_window_attached bool Flag indicating if a window is attached.

Methods

Name Description
add_instruction_screen_batch Load all components and add them to an intro batch
close_context Close the context stopping all pyglet elements
create_classical_examples_to_batch Not the full table just a few examples for the instruction screen
create_classical_table_stimulus Create a classical table stimulus for the Stroop task.
create_stimuli Create stimuli for the stroop task using WORD_COLOR_PAIRS from self.word_color_dict
init_block_stimuli Initialize a block of trials by modifying a context. The stimuli will

add_instruction_screen_batch

stroop_task.context.StroopContext.add_instruction_screen_batch(
    random_wait=False,
)

Load all components and add them to an intro batch

close_context

stroop_task.context.StroopContext.close_context()

Close the context stopping all pyglet elements

create_classical_examples_to_batch

stroop_task.context.StroopContext.create_classical_examples_to_batch(batch)

Not the full table just a few examples for the instruction screen

create_classical_table_stimulus

stroop_task.context.StroopContext.create_classical_table_stimulus(
    n_stimuli=60,
    n_per_row=6,
    perc_incongruent=0.33,
)

Create a classical table stimulus for the Stroop task.

This method generates a table of stimuli for the Stroop task, where each stimulus is either congruent or incongruent based on the specified percentage. The stimuli are arranged in rows and columns, and the table is stored in the known_stimuli dictionary under the key “classical_batch”. The labels for each stimulus are also stored under the key “classical_labels”.

The generated table is saved as a CSV file in the stroop_task/assets directory to cache the layout. This will speed up the loading.

Parameters

Name Type Description Default
n_stimuli int The total number of stimuli to generate. Default is 60. 60
n_per_row int The number of stimuli per row in the table. Default is 6. 6
perc_incongruent float The percentage of incongruent stimuli in the table. Default is 0.33. 0.33

Returns

Name Type Description
None

create_stimuli

stroop_task.context.StroopContext.create_stimuli(random_wait=False)

Create stimuli for the stroop task using WORD_COLOR_PAIRS from self.word_color_dict

init_block_stimuli

stroop_task.context.StroopContext.init_block_stimuli(n_trials)

Initialize a block of trials by modifying a context. The stimuli will be accessible in ctx.block_stimuli as list of tuples (word, pyglet.text.Label, pyglet.shapes.Rectangle, pyglet.shapes.Rectangle, str) The shapes are the squares that will be shown left and right of the word, while the final string indicates the correct direction

Parameters

Name Type Description Default
n_trials int number of trials per block required