Functions common to several paradigms¶
Functions in _common_funcs_init.py¶
-
trajtrackerp.common.
create_common_experiment_objects
(exp_info)¶ Create configuration for the experiment - object common to several paradigms.
exp_info.trials must be set before calling this function.
Parameters: exp_info (trajtracker.paradigms.num2pos.ExperimentInfo) –
-
trajtrackerp.common.
create_csv_loader
()¶ Create a
CSVLoader
for loading the data from the CSV file; initialize the loader with definitions of the columns common to all paradigms.
-
trajtrackerp.common.
create_errmsg_textbox
(exp_info)¶ Create a stimulus that can show the error messages
Parameters: exp_info (trajtracker.paradigms.num2pos.ExperimentInfo) – The experiment-level objects
-
trajtrackerp.common.
create_fixation
(exp_info)¶ Create the fixation shape
Parameters: exp_info (trajtracker.paradigms.num2pos.ExperimentInfo) – The experiment-level objects
-
trajtrackerp.common.
create_fixation_cross
(exp_info)¶
-
trajtrackerp.common.
create_generic_target
(exp_info)¶ Create a handler for non-text targets (pictures, shapes, etc.). This object supports multiple targets (so it can be used for RSVP, priming, etc.)
Parameters: exp_info (trajtracker.paradigms.num2pos.ExperimentInfo) – The experiment-level objects
-
trajtrackerp.common.
create_start_point
(exp_info)¶ Create the “start” area, with default configuration
Parameters: exp_info (trajtracker.paradigms.num2pos.ExperimentInfo) – The experiment-level objects
-
trajtrackerp.common.
create_textbox_fixation
(exp_info)¶ Create a textbox to serve as the fixation.
Parameters: exp_info (trajtracker.paradigms.num2pos.ExperimentInfo) – The experiment-level objects
-
trajtrackerp.common.
create_textbox_target
(exp_info)¶ Create a textbox to serve as the target. This text box supports multiple texts (so it can be used for RSVP, priming, etc.)
Parameters: exp_info (trajtracker.paradigms.num2pos.ExperimentInfo) – The experiment-level objects
-
trajtrackerp.common.
create_traj_tracker
(exp_info)¶ Create the object that tracks the trajectory
Parameters: exp_info (trajtracker.paradigms.num2pos.ExperimentInfo) – The experiment-level objects
-
trajtrackerp.common.
create_validators
(exp_info, direction_validator, global_speed_validator, inst_speed_validator, zigzag_validator)¶ Create movement validators, with default configuration.
Parameters: - exp_info (trajtracker.paradigms.num2pos.ExperimentInfo) – The experiment-level objects
- direction_validator (bool) – Whether to include the validator that enforces upward-only movement
- global_speed_validator (bool) – Whether to validate that the finger reaches each y coordinate in time
- inst_speed_validator (bool) – Whether to validate the finger’s instantaneous speed
- zigzag_validator (bool) – Whether to prohibit zigzag movement
Returns: tuple: (list_of_validators, dict_of_validators)
-
trajtrackerp.common.
get_parser_for
(type_cast_function, delimiter=';', always_create_list=False)¶ Given a type name (or an str->type parsing function), return a function that can parse both this type and delimited lists of this type.
This is used for parsing CSV files
-
trajtrackerp.common.
get_subject_name_id
()¶ Get the name (optional) and the initials of the subject
-
trajtrackerp.common.
load_sound
(config, filename)¶ Load a sound file
Parameters: - config – The experiment configuration object
- filename – No path needed. The file is expected to be under config.sounds_dir
-
trajtrackerp.common.
register_to_event_manager
(exp_info)¶ Register all event-sensitive objects to the event manager
Parameters: exp_info (trajtracker.paradigms.num2pos.ExperimentInfo) – The experiment-level objects
-
trajtrackerp.common.
validate_config_param_type
(param_name, param_type, param_value, none_allowed=False, type_name=None)¶ Validate that a certain configuration parameter is of the specified type
-
trajtrackerp.common.
validate_config_param_values
(param_name, param_value, allowed_values)¶ Validate that a certain configuration parameter is one of the listed values
-
trajtrackerp.common.
xy_to_pixels
(value, screen_size, parameter_name)¶ Translate a stimulus size or position to pixels.
The input is either one value (x or y) or a pair of values (x, y). It may denote either a stimulus size or a position.
If x/y is an int value (or a pair of ints), it is left unchanged. If it is a float value, it is interpreted as percentage of the screen size. In this case, the value should be between 0.0 and 1.0 for size, or between -0.5 and 0.5 for position (but the function will accept any value between -0.5 and 1.0)
Parameters: - value – The value to convert - either a number or a pair of numbers
- screen_size – The screen size - either a number or a pair of numbers (must match the “value” paremeter)
- parameter_name – If this is not None, errors will yield an exception, indicating this parameter
Returns: An int or a pair of ints (scale = pixels). If the input value is not a valid size, return None.
Functions in _common_funcs_run.py¶
-
trajtrackerp.common.
init_experiment
(exp_info)¶ Initialize the experiment environment
-
trajtrackerp.common.
on_finger_started_moving
(exp_info, trial)¶ This function should be called when the finger leaves the “start” area and starts moving
-
trajtrackerp.common.
on_finger_touched_screen
(exp_info, trial)¶ This function should be called when the finger touches the screen
-
trajtrackerp.common.
open_trials_file
(exp_info, additional_fields)¶ Parameters: additional_fields – List of field names in the CSV file (on top of the common fields)
-
trajtrackerp.common.
prepare_trial_out_row
(exp_info, trial, success_err_code)¶ Get values to save in the trials.csv output file
Returns: A dict with some values for the file
-
trajtrackerp.common.
save_session_file
(exp_info, paradigm)¶ Save the session.xml file
-
trajtrackerp.common.
show_fixation
(exp_info, visible=True)¶
-
trajtrackerp.common.
trial_failed_common
(err, exp_info, trial)¶ Called when the trial failed for any reason (only when a strict error occurred; pointing at an incorrect location does not count as failure)
-
trajtrackerp.common.
update_attr_by_csv_config
(exp_info, trial, target_obj, csv_name, attr_name)¶ Update one attribute of an object from the corresponding entry in the config CSV file
Parameters: - exp_info (trajtracker.paradigms.common.BaseExperimentInfo) –
- trial (trajtracker.paradigms.common.BaseTrialInfo) –
- target_obj – The object containing the attribute to update
- csv_name (str) – The column name in the CSV file
- attr_name (str) – The name of the attribute to update
Returns: Whether updated anthing or not
-
trajtrackerp.common.
update_fixation_for_trial
(exp_info, trial)¶ Update the fixation when the trial is initialized
-
trajtrackerp.common.
update_generic_target_for_trial
(exp_info, trial)¶ Update properties of the generic stimuli according to the current trial info
-
trajtrackerp.common.
update_movement_in_traj_sensitive_objects
(exp_info, trial, within_movement_time=True)¶ Update the trajectory-sensitive objects about the mouse/finger movement
Parameters: within_movement_time – Indicates whether the this is currently the finger’s movement time (between start of detected movement and a response being made). The function may also be called outside this time interval. Returns: None if all is OK; or an ExperimentError object if one of the validators issued an error
-
trajtrackerp.common.
update_text_target_for_trial
(exp_info, trial, use_numeric_target_as_default=False)¶ Update properties of the text stimuli according to the current trial info
Parameters: - exp_info (trajtracker.paradigms.common.BaseExperimentInfo) –
- trial (trajtracker.paradigms.common.BaseTrialInfo) –
- use_numeric_target_as_default – For number-to-position paradigm: if this is set to True, the text.target column in the CSV input file becomes optional, and the “target” column is used as the default text to show.
-
trajtrackerp.common.
update_obj_position
(exp_info, trial, visual_obj, col_name_prefix, x_or_y)¶ Update the position of a visual object according to “position.x” or “position.y” columns
Parameters: - exp_info (trajtracker.paradigms.common.BaseExperimentInfo) –
- trial (trajtracker.paradigms.common.BaseTrialInfo) –
- visual_obj – The object containing the attribute to update
- col_name_prefix (str) – Prefix of the column name in the CSV file
- x_or_y – ‘x’ or ‘y’, indicating which column to look for in the CSV file
Returns: Whether updated anthing or not
-
trajtrackerp.common.
wait_until_finger_moves
(exp_info, trial)¶ The function returns after the finger started moving (or on error)
Returns: None if all OK; if trial should terminate, a tuple with two values: (1) RunTrialResult.xxx (2) An ExperimentError object