data_format_changes#

Changes in the format of the data saved by the tasks.

Why this file exists#

The behavioural tasks (repository auditory-task-python, run on the Training Village) save one row per trial. Over time, the meaning or the values of some columns have changed. Old rows cannot be rewritten, so the analysis code has to read old and new rows correctly at the same time.

Each change is documented here, in one place, with:

  • what changed, and from when,

  • why it changed,

  • the constant or function the rest of the analysis code must use to read both versions.

The rest of the package imports from this file instead of hard-coding dates or names. When a task changes the format of a column again, add a new section here (and use it where that column is read), rather than patching each analysis function separately.

Rule for the rest of the package#

  • The data is converted once, at the start: preprocessing.prepare (also called analyze_df) calls fill_missing_data, which calls normalize_task_names. Every figure (figure_maker, the figures package) prepares its data first. A new public figure or analysis function must do the same before using stimulus_modality or current_training_stage.

  • Internal code then compares only with the current names (“auditory-cot”, “TwoAFC_auditory-cot_easy”…), never with the old ones.

  • Functions that may be called directly on raw data and need one specific modality normalize it themselves (e.g. common._get_single_modality).

  • Columns whose meaning changed (visual_stimulus) are always read through the functions in this file, which use the date and the village (system_name) of each trial.

  • The default is always the newest format: data of a village that is not in NEW_TASK_CODE_SINCE (e.g. a new village) is read in the newest format.

Current changes#

  1. visual_stimulus: (correct, incorrect) -> (left, right).

  2. Modality and stage names: “auditory” / “auditory_cot” -> “auditory-cot”, “auditory_local_wn” -> “auditory-local-wn”.

  3. correct: can be None (timeouts).

  4. use_sound_location: cloud of tones from the side of the reward (an older, now deprecated option) is read as the modality “auditory-local-cot”.

The first three come from the same revision of the task (branch hmv_claude of auditory-task-python), which reorganised how stimuli are handled. Each village started running it on a different day: see NEW_TASK_CODE_SINCE. Only the first change needs that date (the others are read from the values themselves).

Functions

add_left_right_brightness

Adds the columns left_brightness and right_brightness (NaN if the trial had no light stimulus), reading visual_stimulus in either format (from the date and the system_name of each row).

correct_as_number

1.0 for a correct trial, 0.0 for an incorrect one.

get_correct_incorrect_brightness

Returns (correct port, incorrect port) brightness for one trial, whatever the format it was saved in.

get_left_right_brightness

Returns (left, right) brightness of the side ports for one trial, whatever the format it was saved in.

normalize_modality

Returns the current name of a modality (other values are returned as they are).

normalize_stage

Returns the current name of a training stage, e.g. "TwoAFC_auditory_cot_easy" or "TwoAFC_auditory_easy" -> "TwoAFC_auditory-cot_easy".

normalize_task_names

Normalizes the stimulus_modality and current_training_stage columns, if present, and names the trials of use_sound_location (see section 4).

uses_new_task_code

True if a trial saved on this date by this village (its system_name) comes from the new task code, i.e. uses the new formats.

visual_stimulus_is_left_right

True if a trial saved on this date by this village saved visual_stimulus as (left, right).