iblrig.base_tasks.BaseSession
- class iblrig.base_tasks.BaseSession[source]
- __init__(subject=None, task_parameter_file=None, file_hardware_settings=None, hardware_settings=None, file_iblrig_settings=None, iblrig_settings=None, one=None, interactive=True, projects=None, procedures=None, stub=None, subject_weight_grams=None, append=False, wizard=False, log_level='INFO', **kwargs)[source]
- Parameters:
subject – The subject nickname. Required.
task_parameter_file – an optional path to the task_parameters.yaml file
file_hardware_settings – name of the hardware file in the settings folder, or full file path
hardware_settings (HardwareSettings | None) – an optional dictionary of hardware settings. Keys will override any keys in the file
file_iblrig_settings – name of the iblrig file in the settings folder, or full file path
iblrig_settings (RigSettings | None) – an optional dictionary of iblrig settings. Keys will override any keys in the file
one – an optional instance of ONE
interactive
projects – An optional list of Alyx protocols.
procedures – An optional list of Alyx procedures.
subject_weight_grams – weight of the subject
stub – A full path to an experiment description file containing experiment information.
append – bool, if True, append to the latest existing session of the same subject for the same day
- create_session()[source]
Create the session path and save json parameters in the task collection folder.
This will also create the protocol folder.
- static extra_parser()[source]
Specify extra kwargs arguments to expose to the user prior running the task.
Make sure you instantiate the parser.
- Returns:
The extra parser instance.
- Return type:
- classmethod get_task_directory()[source]
Get the path to the task’s directory.
- Returns:
The path to the task’s directory.
- Return type:
Path
- classmethod get_task_file()[source]
Get the path to the task’s python file.
- Returns:
The path to the task file.
- Return type:
Path
- static make_experiment_description_dict(task_protocol, task_collection, procedures=None, projects=None, hardware_settings=None, stub=None, extractors=None, camera_config=None)[source]
Construct an experiment description dictionary.
- Parameters:
task_protocol (
str
) – The task protocol name, e.g. _ibl_trainingChoiceWorld2.0.0.task_collection (
str
) – The task collection name, e.g. raw_task_data_00.procedures (
list
) – An optional list of Alyx procedures.projects (
list
) – An optional list of Alyx protocols.hardware_settings (
dict
) – An optional dict of hardware devices, loaded from the hardware_settings.yaml file.stub (
dict
) – An optional experiment description stub to update.extractors (
list
) – An optional list of extractor names for the task.camera_config (
str
) – The camera configuration name in the hardware settings. Defaults to the first key in ‘device_cameras’.
- Returns:
The experiment description.
- Return type:
- Parameters:
- classmethod read_task_parameter_files(task_parameter_file=None)[source]
Get the task’s parameters from the various YAML files in the hierarchy.
- register_to_alyx()[source]
Registers the session to Alyx.
This registers the session using the IBLRegistrationClient class. This uses the settings file(s) and experiment description file to extract the session data. This may be called any number of times and if the session record already exists in Alyx it will be updated. If session registration fails, it will be done before extraction in the ibllib pipeline.
Note that currently the subject weight is registered once and only once. The recorded weight of the first protocol run is used.
Water administrations are added separately by this method: it is expected that register_session is first called with no recorded total water. This method will then add a water administration each time it is called, and should therefore be called only once after each protocol is run. If water administration registration fails for all protocols, this will be done before extraction in the ibllib pipline, however, if a water administration is successfully registered for one protocol and subsequent ones fail to register, these will not be added before extraction in ibllib and therefore must be manually added to Alyx.
- Returns:
The registered session record.
- Return type:
- run()[source]
Common pre-run instructions for all tasks.
Defines sigint handler for a graceful exit.
- save_task_parameters_to_json_file(destination_folder=None)[source]
Collects the various settings and parameters of the session and outputs them to a JSON file.
- Returns:
Path to the resultant JSON file
- Return type:
Path
- Parameters:
destination_folder (Path | None)
- final save_trial_data_to_json(bpod_data)[source]
Validate and save trial data.
This method retrieve’s the current trial’s data from the trial_table and validates it using a Pydantic model (self.TrialDataDefinition). In merges in the trial’s bpod_data dict and appends everything to the session’s JSON data file.
- abstract start_hardware()[source]
Start the hardware.
This method doesn’t explicitly start the mixins as the order has to be defined in the child classes. This needs to be implemented in the child classes, and should start and connect to all hardware pieces.
- TrialDataModel: type[TrialDataModel]
- base_parameters_file: Path | None = None
A YAML file containing base, default task parameters.
- Type:
Path
- property exp_ref
Construct an experiment reference string from the session info attribute.
- extractor_tasks: list | None = None
An optional list of pipeline task class names to instantiate when preprocessing task data.
- logger: Logger = None
Log instance used solely to keep track of log level passed to constructor.
- Type:
- property one
ONE getter.
- property time_elapsed