sl-shared-assets 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of sl-shared-assets might be problematic. Click here for more details.
- sl_shared_assets/__init__.py +80 -0
- sl_shared_assets/__init__.pyi +73 -0
- sl_shared_assets/cli.py +384 -0
- sl_shared_assets/cli.pyi +94 -0
- sl_shared_assets/data_classes/__init__.py +66 -0
- sl_shared_assets/data_classes/__init__.pyi +61 -0
- sl_shared_assets/data_classes/configuration_data.py +479 -0
- sl_shared_assets/data_classes/configuration_data.pyi +199 -0
- sl_shared_assets/data_classes/runtime_data.py +251 -0
- sl_shared_assets/data_classes/runtime_data.pyi +145 -0
- sl_shared_assets/data_classes/session_data.py +625 -0
- sl_shared_assets/data_classes/session_data.pyi +252 -0
- sl_shared_assets/data_classes/surgery_data.py +152 -0
- sl_shared_assets/data_classes/surgery_data.pyi +89 -0
- sl_shared_assets/py.typed +0 -0
- sl_shared_assets/server/__init__.py +8 -0
- sl_shared_assets/server/__init__.pyi +8 -0
- sl_shared_assets/server/job.py +140 -0
- sl_shared_assets/server/job.pyi +94 -0
- sl_shared_assets/server/server.py +214 -0
- sl_shared_assets/server/server.pyi +95 -0
- sl_shared_assets/tools/__init__.py +15 -0
- sl_shared_assets/tools/__init__.pyi +15 -0
- sl_shared_assets/tools/ascension_tools.py +277 -0
- sl_shared_assets/tools/ascension_tools.pyi +68 -0
- sl_shared_assets/tools/packaging_tools.py +148 -0
- sl_shared_assets/tools/packaging_tools.pyi +56 -0
- sl_shared_assets/tools/project_management_tools.py +201 -0
- sl_shared_assets/tools/project_management_tools.pyi +54 -0
- sl_shared_assets/tools/transfer_tools.py +119 -0
- sl_shared_assets/tools/transfer_tools.pyi +53 -0
- sl_shared_assets-1.0.0.dist-info/METADATA +869 -0
- sl_shared_assets-1.0.0.dist-info/RECORD +36 -0
- sl_shared_assets-1.0.0.dist-info/WHEEL +4 -0
- sl_shared_assets-1.0.0.dist-info/entry_points.txt +8 -0
- sl_shared_assets-1.0.0.dist-info/licenses/LICENSE +674 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from dataclasses import field, dataclass
|
|
3
|
+
|
|
4
|
+
from _typeshed import Incomplete
|
|
5
|
+
from ataraxis_data_structures import YamlConfig
|
|
6
|
+
|
|
7
|
+
@dataclass()
|
|
8
|
+
class ExperimentState:
|
|
9
|
+
"""Encapsulates the information used to set and maintain the desired experiment and system state.
|
|
10
|
+
|
|
11
|
+
Broadly, each experiment runtime can be conceptualized as a two state-system. The first state is that of the
|
|
12
|
+
experimental task, which reflects the behavior goal, the rules for achieving the goal, and the reward for
|
|
13
|
+
achieving the goal. The second state is that of the data acquisition and experiment control system, which is a
|
|
14
|
+
snapshot of all hardware module states that make up the system that acquires the data and controls the task
|
|
15
|
+
environment. Overall, experiment state is about 'what the animal is doing', while the system state is about
|
|
16
|
+
'what the hardware is doing'.
|
|
17
|
+
|
|
18
|
+
Note:
|
|
19
|
+
This class is acquisition-system-agnostic. It can be used to define the ExperimentConfiguration class for any
|
|
20
|
+
valid data acquisition system.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
experiment_state_code: int
|
|
24
|
+
system_state_code: int
|
|
25
|
+
state_duration_s: float
|
|
26
|
+
|
|
27
|
+
@dataclass()
|
|
28
|
+
class MesoscopeExperimentConfiguration(YamlConfig):
|
|
29
|
+
"""Stores the configuration of a single experiment runtime that uses the Mesoscope_VR data acquisition system.
|
|
30
|
+
|
|
31
|
+
Primarily, this includes the sequence of experiment and system states that defines the flow of the experiment
|
|
32
|
+
runtime. During runtime, the main runtime control function traverses the sequence of states stored in this class
|
|
33
|
+
instance start-to-end in the exact order specified by the user. Together with custom Unity projects that define
|
|
34
|
+
the task logic (how the system responds to animal interactions with the VR system) this class allows flexibly
|
|
35
|
+
implementing a wide range of experiments using the Mesoscope-VR system.
|
|
36
|
+
|
|
37
|
+
Each project should define one or more experiment configurations and save them as .yaml files inside the project
|
|
38
|
+
'configuration' folder. The name for each configuration file is defined by the user and is used to identify and load
|
|
39
|
+
the experiment configuration when 'sl-experiment' CLI command exposed by the sl-experiment library is executed.
|
|
40
|
+
|
|
41
|
+
Notes:
|
|
42
|
+
This class is designed exclusively for the Mesoscope-VR system. Any other system needs to define a separate
|
|
43
|
+
ExperimentConfiguration class to specify its experiment runtimes and additional data.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
cue_map: dict[int, float] = field(default_factory=Incomplete)
|
|
47
|
+
experiment_states: dict[str, ExperimentState] = field(default_factory=Incomplete)
|
|
48
|
+
|
|
49
|
+
@dataclass()
|
|
50
|
+
class MesoscopePaths:
|
|
51
|
+
"""Stores the filesystem configuration parameters for the Mesoscope-VR data acquisition system."""
|
|
52
|
+
|
|
53
|
+
server_credentials_path: Path = ...
|
|
54
|
+
google_credentials_path: Path = ...
|
|
55
|
+
root_directory: Path = ...
|
|
56
|
+
server_storage_directory: Path = ...
|
|
57
|
+
server_working_directory: Path = ...
|
|
58
|
+
nas_directory: Path = ...
|
|
59
|
+
mesoscope_directory: Path = ...
|
|
60
|
+
harvesters_cti_path: Path = ...
|
|
61
|
+
server_processed_data_root: Path = ...
|
|
62
|
+
server_raw_data_root: Path = ...
|
|
63
|
+
|
|
64
|
+
@dataclass()
|
|
65
|
+
class MesoscopeCameras:
|
|
66
|
+
"""Stores the configuration parameters for the cameras used by the Mesoscope-VR system to record behavior videos."""
|
|
67
|
+
|
|
68
|
+
face_camera_index: int = ...
|
|
69
|
+
left_camera_index: int = ...
|
|
70
|
+
right_camera_index: int = ...
|
|
71
|
+
face_camera_quantization_parameter: int = ...
|
|
72
|
+
body_camera_quantization_parameter: int = ...
|
|
73
|
+
display_face_camera_frames: bool = ...
|
|
74
|
+
display_body_camera_frames: bool = ...
|
|
75
|
+
|
|
76
|
+
@dataclass()
|
|
77
|
+
class MesoscopeMicroControllers:
|
|
78
|
+
"""Stores the configuration parameters for the microcontrollers used by the Mesoscope-VR system."""
|
|
79
|
+
|
|
80
|
+
actor_port: str = ...
|
|
81
|
+
sensor_port: str = ...
|
|
82
|
+
encoder_port: str = ...
|
|
83
|
+
debug: bool = ...
|
|
84
|
+
mesoscope_ttl_pulse_duration_ms: int = ...
|
|
85
|
+
minimum_break_strength_g_cm: float = ...
|
|
86
|
+
maximum_break_strength_g_cm: float = ...
|
|
87
|
+
wheel_diameter_cm: float = ...
|
|
88
|
+
lick_threshold_adc: int = ...
|
|
89
|
+
lick_signal_threshold_adc: int = ...
|
|
90
|
+
lick_delta_threshold_adc: int = ...
|
|
91
|
+
lick_averaging_pool_size: int = ...
|
|
92
|
+
torque_baseline_voltage_adc: int = ...
|
|
93
|
+
torque_maximum_voltage_adc: int = ...
|
|
94
|
+
torque_sensor_capacity_g_cm: float = ...
|
|
95
|
+
torque_report_cw: bool = ...
|
|
96
|
+
torque_report_ccw: bool = ...
|
|
97
|
+
torque_signal_threshold_adc: int = ...
|
|
98
|
+
torque_delta_threshold_adc: int = ...
|
|
99
|
+
torque_averaging_pool_size: int = ...
|
|
100
|
+
wheel_encoder_ppr = ...
|
|
101
|
+
wheel_encoder_report_cw: bool = ...
|
|
102
|
+
wheel_encoder_report_ccw: bool = ...
|
|
103
|
+
wheel_encoder_delta_threshold_pulse: int = ...
|
|
104
|
+
wheel_encoder_polling_delay_us = ...
|
|
105
|
+
cm_per_unity_unit = ...
|
|
106
|
+
screen_trigger_pulse_duration_ms: int = ...
|
|
107
|
+
auditory_tone_duration_ms: int = ...
|
|
108
|
+
valve_calibration_pulse_count: int = ...
|
|
109
|
+
sensor_polling_delay_ms: int = ...
|
|
110
|
+
valve_calibration_data: dict[int | float, int | float] | tuple[tuple[int | float, int | float], ...] = ...
|
|
111
|
+
|
|
112
|
+
@dataclass()
|
|
113
|
+
class MesoscopeAdditionalFirmware:
|
|
114
|
+
"""Stores the configuration parameters for all firmware and hardware components not assembled in the Sun lab."""
|
|
115
|
+
|
|
116
|
+
headbar_port: str = ...
|
|
117
|
+
lickport_port: str = ...
|
|
118
|
+
wheel_port: str = ...
|
|
119
|
+
unity_ip: str = ...
|
|
120
|
+
unity_port: int = ...
|
|
121
|
+
|
|
122
|
+
@dataclass()
|
|
123
|
+
class MesoscopeSystemConfiguration(YamlConfig):
|
|
124
|
+
"""Stores the hardware and filesystem configuration parameters for the Mesoscope-VR data acquisition system used in
|
|
125
|
+
the Sun lab.
|
|
126
|
+
|
|
127
|
+
This class is specifically designed to encapsulate the configuration parameters for the Mesoscope-VR system. It
|
|
128
|
+
expects the system to be configured according to the specifications available from the sl_experiment repository
|
|
129
|
+
(https://github.com/Sun-Lab-NBB/sl-experiment) and should be used exclusively by the VRPC machine
|
|
130
|
+
(main Mesoscope-VR PC).
|
|
131
|
+
|
|
132
|
+
Notes:
|
|
133
|
+
Each SystemConfiguration class is uniquely tied to a specific hardware configuration used in the lab. This
|
|
134
|
+
class will only work with the Mesoscope-VR system. Any other data acquisition and runtime management system in
|
|
135
|
+
the lab should define its own SystemConfiguration class to specify its own hardware and filesystem configuration
|
|
136
|
+
parameters.
|
|
137
|
+
"""
|
|
138
|
+
|
|
139
|
+
name: str = ...
|
|
140
|
+
paths: MesoscopePaths = field(default_factory=MesoscopePaths)
|
|
141
|
+
cameras: MesoscopeCameras = field(default_factory=MesoscopeCameras)
|
|
142
|
+
microcontrollers: MesoscopeMicroControllers = field(default_factory=MesoscopeMicroControllers)
|
|
143
|
+
additional_firmware: MesoscopeAdditionalFirmware = field(default_factory=MesoscopeAdditionalFirmware)
|
|
144
|
+
def __post_init__(self) -> None:
|
|
145
|
+
"""Ensures that variables converted to different types for storage purposes are always set to expected types
|
|
146
|
+
upon class instantiation."""
|
|
147
|
+
def save(self, path: Path) -> None:
|
|
148
|
+
"""Saves class instance data to disk as a 'mesoscope_system_configuration.yaml' file.
|
|
149
|
+
|
|
150
|
+
This method converts certain class variables to yaml-safe types (for example, Path objects -> strings) and
|
|
151
|
+
saves class data to disk as a .yaml file. The method is intended to be used solely by the
|
|
152
|
+
set_system_configuration_file() function and should not be called from any other context.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
path: The path to the .yaml file to save the data to.
|
|
156
|
+
"""
|
|
157
|
+
|
|
158
|
+
_supported_configuration_files: Incomplete
|
|
159
|
+
|
|
160
|
+
def set_system_configuration_file(path: Path) -> None:
|
|
161
|
+
"""Sets the system configuration .yaml file specified by the input path as the default system configuration file for
|
|
162
|
+
the managed machine (PC).
|
|
163
|
+
|
|
164
|
+
This function is used to initially configure or override the existing configuration of any data acquisition system
|
|
165
|
+
used in the lab. The path to the configuration file is stored inside the user's data directory, so that all
|
|
166
|
+
Sun lab libraries can automatically access that information during every runtime. Since the storage directory is
|
|
167
|
+
typically hidden and varies between OSes and machines, this function provides a convenient way for setting that
|
|
168
|
+
path without manually editing the storage cache.
|
|
169
|
+
|
|
170
|
+
Notes:
|
|
171
|
+
If the input path does not point to an existing file, but the file name and extension are correct, the function
|
|
172
|
+
will automatically generate a default SystemConfiguration class instance and save it under the specified path.
|
|
173
|
+
|
|
174
|
+
A data acquisition system can include multiple machines (PCs). However, the configuration file is typically
|
|
175
|
+
only present on the 'main' machine that manages all runtimes.
|
|
176
|
+
|
|
177
|
+
Args:
|
|
178
|
+
path: The path to the new system configuration file to be used by the local data acquisition system (PC).
|
|
179
|
+
|
|
180
|
+
Raises:
|
|
181
|
+
ValueError: If the input path is not a valid system configuration file or does not use a supported data
|
|
182
|
+
acquisition system name.
|
|
183
|
+
"""
|
|
184
|
+
|
|
185
|
+
def get_system_configuration_data() -> MesoscopeSystemConfiguration:
|
|
186
|
+
"""Resolves the path to the local system configuration file and loads the system configuration data.
|
|
187
|
+
|
|
188
|
+
This service function is used by all Sun lab data acquisition runtimes to load the system configuration data from
|
|
189
|
+
the shared configuration file. It supports resolving and returning the data for all data acquisition systems used
|
|
190
|
+
in the lab.
|
|
191
|
+
|
|
192
|
+
Returns:
|
|
193
|
+
The initialized SystemConfiguration class instance for the local acquisition system that stores the loaded
|
|
194
|
+
configuration parameters.
|
|
195
|
+
|
|
196
|
+
Raises:
|
|
197
|
+
FileNotFoundError: If the local machine does not have the Sun lab data directory, or the system configuration
|
|
198
|
+
file does not exist.
|
|
199
|
+
"""
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"""This module provides classes used to store the training and experiment data acquired by the sl-experiment library.
|
|
2
|
+
Some classes from this library store raw data later processed by Sun lab data processing pipelines. Others are used to
|
|
3
|
+
restore the data acquisition and runtime management system to the same state across training or experiment sessions for
|
|
4
|
+
the same animal.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from dataclasses import dataclass
|
|
8
|
+
|
|
9
|
+
from ataraxis_data_structures import YamlConfig
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass()
|
|
13
|
+
class MesoscopeHardwareState(YamlConfig):
|
|
14
|
+
"""Stores configuration parameters (states) of the Mesoscope-VR system hardware modules used during training or
|
|
15
|
+
experiment runtime.
|
|
16
|
+
|
|
17
|
+
This information is used to read and decode the data saved to the .npz log files during runtime as part of data
|
|
18
|
+
processing.
|
|
19
|
+
|
|
20
|
+
Notes:
|
|
21
|
+
This class stores 'static' Mesoscope-VR system configuration that does not change during experiment or training
|
|
22
|
+
session runtime. This is in contrast to MesoscopeExperimentState class, which reflects the 'dynamic' state of
|
|
23
|
+
the Mesoscope-VR system.
|
|
24
|
+
|
|
25
|
+
This class partially overlaps with the MesoscopeSystemConfiguration class, which is also stored in the
|
|
26
|
+
raw_data folder of each session. The primary reason to keep both classes is to ensure that the math (rounding)
|
|
27
|
+
used during runtime matches the math (rounding) used during data processing. MesoscopeSystemConfiguration does
|
|
28
|
+
not do any rounding or otherwise attempt to be repeatable, which is in contrast to hardware module that read
|
|
29
|
+
those parameters. Reading values from this class guarantees the read value exactly matches the value used
|
|
30
|
+
during runtime.
|
|
31
|
+
|
|
32
|
+
Notes:
|
|
33
|
+
All fields in this dataclass initialize to None. During log processing, any log associated with a hardware
|
|
34
|
+
module that provides the data stored in a field will be processed, unless that field is None. Therefore, setting
|
|
35
|
+
any field in this dataclass to None also functions as a flag for whether to parse the log associated with the
|
|
36
|
+
module that provides this field's information.
|
|
37
|
+
|
|
38
|
+
This class is automatically configured by _MesoscopeExperiment and _BehaviorTraining classes from sl-experiment
|
|
39
|
+
library to facilitate log parsing.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
cue_map: dict[int, float] | None = None
|
|
43
|
+
"""MesoscopeExperiment instance property. Stores the dictionary that maps the integer id-codes associated with each
|
|
44
|
+
wall cue in the Virtual Reality task environment with distances in real-world centimeters animals should run on the
|
|
45
|
+
wheel to fully traverse the cue region on a linearized track."""
|
|
46
|
+
cm_per_pulse: float | None = None
|
|
47
|
+
"""EncoderInterface instance property. Stores the conversion factor used to translate encoder pulses into
|
|
48
|
+
real-world centimeters."""
|
|
49
|
+
maximum_break_strength: float | None = None
|
|
50
|
+
"""BreakInterface instance property. Stores the breaking torque, in Newton centimeters, applied by the break to
|
|
51
|
+
the edge of the running wheel when it is engaged at 100% strength."""
|
|
52
|
+
minimum_break_strength: float | None = None
|
|
53
|
+
"""BreakInterface instance property. Stores the breaking torque, in Newton centimeters, applied by the break to
|
|
54
|
+
the edge of the running wheel when it is engaged at 0% strength (completely disengaged)."""
|
|
55
|
+
lick_threshold: int | None = None
|
|
56
|
+
"""LickInterface instance property. Determines the threshold, in 12-bit Analog to Digital Converter (ADC) units,
|
|
57
|
+
above which an interaction value reported by the lick sensor is considered a lick (compared to noise or non-lick
|
|
58
|
+
touch)."""
|
|
59
|
+
valve_scale_coefficient: float | None = None
|
|
60
|
+
"""ValveInterface instance property. To dispense precise water volumes during runtime, ValveInterface uses power
|
|
61
|
+
law equation applied to valve calibration data to determine how long to keep the valve open. This stores the
|
|
62
|
+
scale_coefficient of the power law equation that describes the relationship between valve open time and dispensed
|
|
63
|
+
water volume, derived from calibration data."""
|
|
64
|
+
valve_nonlinearity_exponent: float | None = None
|
|
65
|
+
"""ValveInterface instance property. To dispense precise water volumes during runtime, ValveInterface uses power
|
|
66
|
+
law equation applied to valve calibration data to determine how long to keep the valve open. This stores the
|
|
67
|
+
nonlinearity_exponent of the power law equation that describes the relationship between valve open time and
|
|
68
|
+
dispensed water volume, derived from calibration data."""
|
|
69
|
+
torque_per_adc_unit: float | None = None
|
|
70
|
+
"""TorqueInterface instance property. Stores the conversion factor used to translate torque values reported by the
|
|
71
|
+
sensor as 12-bit Analog to Digital Converter (ADC) units, into real-world Newton centimeters (N·cm) of torque that
|
|
72
|
+
had to be applied to the edge of the running wheel to produce the observed ADC value."""
|
|
73
|
+
screens_initially_on: bool | None = None
|
|
74
|
+
"""ScreenInterface instance property. Stores the initial state of the Virtual Reality screens at the beginning of
|
|
75
|
+
the session runtime."""
|
|
76
|
+
recorded_mesoscope_ttl: bool | None = None
|
|
77
|
+
"""TTLInterface instance property. A boolean flag that determines whether the processed session recorded brain
|
|
78
|
+
activity data with the mesoscope."""
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@dataclass()
|
|
82
|
+
class LickTrainingDescriptor(YamlConfig):
|
|
83
|
+
"""Stores the task and outcome information specific to lick training sessions that use the Mesoscope-VR system."""
|
|
84
|
+
|
|
85
|
+
experimenter: str
|
|
86
|
+
"""The ID of the experimenter running the session."""
|
|
87
|
+
mouse_weight_g: float
|
|
88
|
+
"""The weight of the animal, in grams, at the beginning of the session."""
|
|
89
|
+
dispensed_water_volume_ml: float
|
|
90
|
+
"""Stores the total water volume, in milliliters, dispensed during runtime."""
|
|
91
|
+
minimum_reward_delay: int
|
|
92
|
+
"""Stores the minimum delay, in seconds, that can separate the delivery of two consecutive water rewards."""
|
|
93
|
+
maximum_reward_delay_s: int
|
|
94
|
+
"""Stores the maximum delay, in seconds, that can separate the delivery of two consecutive water rewards."""
|
|
95
|
+
maximum_water_volume_ml: float
|
|
96
|
+
"""Stores the maximum volume of water the system is allowed to dispense during training."""
|
|
97
|
+
maximum_training_time_m: int
|
|
98
|
+
"""Stores the maximum time, in minutes, the system is allowed to run the training for."""
|
|
99
|
+
maximum_unconsumed_rewards: int = 1
|
|
100
|
+
"""Stores the maximum number of consecutive rewards that can be delivered without the animal consuming them. If
|
|
101
|
+
the animal receives this many rewards without licking (consuming) them, reward delivery is paused until the animal
|
|
102
|
+
consumes the rewards."""
|
|
103
|
+
experimenter_notes: str = "Replace this with your notes."
|
|
104
|
+
"""This field is not set during runtime. It is expected that each experimenter replaces this field with their
|
|
105
|
+
notes made during runtime."""
|
|
106
|
+
experimenter_given_water_volume_ml: float = 0.0
|
|
107
|
+
"""The additional volume of water, in milliliters, administered by the experimenter to the animal after the session.
|
|
108
|
+
"""
|
|
109
|
+
incomplete: bool = False
|
|
110
|
+
"""If this field is set to True, the session is marked as 'incomplete' and automatically excluded from all further
|
|
111
|
+
Sun lab automated processing and analysis."""
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@dataclass()
|
|
115
|
+
class RunTrainingDescriptor(YamlConfig):
|
|
116
|
+
"""Stores the task and outcome information specific to run training sessions that use the Mesoscope-VR system."""
|
|
117
|
+
|
|
118
|
+
experimenter: str
|
|
119
|
+
"""The ID of the experimenter running the session."""
|
|
120
|
+
mouse_weight_g: float
|
|
121
|
+
"""The weight of the animal, in grams, at the beginning of the session."""
|
|
122
|
+
dispensed_water_volume_ml: float
|
|
123
|
+
"""Stores the total water volume, in milliliters, dispensed during runtime."""
|
|
124
|
+
final_run_speed_threshold_cm_s: float
|
|
125
|
+
"""Stores the final running speed threshold, in centimeters per second, that was active at the end of training."""
|
|
126
|
+
final_run_duration_threshold_s: float
|
|
127
|
+
"""Stores the final running duration threshold, in seconds, that was active at the end of training."""
|
|
128
|
+
initial_run_speed_threshold_cm_s: float
|
|
129
|
+
"""Stores the initial running speed threshold, in centimeters per second, used during training."""
|
|
130
|
+
initial_run_duration_threshold_s: float
|
|
131
|
+
"""Stores the initial running duration threshold, in seconds, used during training."""
|
|
132
|
+
increase_threshold_ml: float
|
|
133
|
+
"""Stores the volume of water delivered to the animal, in milliliters, that triggers the increase in the running
|
|
134
|
+
speed and duration thresholds."""
|
|
135
|
+
run_speed_increase_step_cm_s: float
|
|
136
|
+
"""Stores the value, in centimeters per second, used by the system to increment the running speed threshold each
|
|
137
|
+
time the animal receives 'increase_threshold' volume of water."""
|
|
138
|
+
run_duration_increase_step_s: float
|
|
139
|
+
"""Stores the value, in seconds, used by the system to increment the duration threshold each time the animal
|
|
140
|
+
receives 'increase_threshold' volume of water."""
|
|
141
|
+
maximum_water_volume_ml: float
|
|
142
|
+
"""Stores the maximum volume of water the system is allowed to dispense during training."""
|
|
143
|
+
maximum_training_time_m: int
|
|
144
|
+
"""Stores the maximum time, in minutes, the system is allowed to run the training for."""
|
|
145
|
+
maximum_unconsumed_rewards: int = 1
|
|
146
|
+
"""Stores the maximum number of consecutive rewards that can be delivered without the animal consuming them. If
|
|
147
|
+
the animal receives this many rewards without licking (consuming) them, reward delivery is paused until the animal
|
|
148
|
+
consumes the rewards."""
|
|
149
|
+
maximum_idle_time_s: float = 0.0
|
|
150
|
+
"""Stores the maximum time, in seconds, the animal can dip below the running speed threshold to still receive the
|
|
151
|
+
reward. This allows animals that 'run' by taking a series of large steps, briefly dipping below speed threshold at
|
|
152
|
+
the end of each step, to still get water rewards."""
|
|
153
|
+
experimenter_notes: str = "Replace this with your notes."
|
|
154
|
+
"""This field is not set during runtime. It is expected that each experimenter will replace this field with their
|
|
155
|
+
notes made during runtime."""
|
|
156
|
+
experimenter_given_water_volume_ml: float = 0.0
|
|
157
|
+
"""The additional volume of water, in milliliters, administered by the experimenter to the animal after the session.
|
|
158
|
+
"""
|
|
159
|
+
incomplete: bool = False
|
|
160
|
+
"""If this field is set to True, the session is marked as 'incomplete' and automatically excluded from all further
|
|
161
|
+
Sun lab automated processing and analysis."""
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
@dataclass()
|
|
165
|
+
class MesoscopeExperimentDescriptor(YamlConfig):
|
|
166
|
+
"""Stores the task and outcome information specific to experiment sessions that use the Mesoscope-VR system."""
|
|
167
|
+
|
|
168
|
+
experimenter: str
|
|
169
|
+
"""The ID of the experimenter running the session."""
|
|
170
|
+
mouse_weight_g: float
|
|
171
|
+
"""The weight of the animal, in grams, at the beginning of the session."""
|
|
172
|
+
dispensed_water_volume_ml: float
|
|
173
|
+
"""Stores the total water volume, in milliliters, dispensed during runtime."""
|
|
174
|
+
experimenter_notes: str = "Replace this with your notes."
|
|
175
|
+
"""This field is not set during runtime. It is expected that each experimenter will replace this field with their
|
|
176
|
+
notes made during runtime."""
|
|
177
|
+
experimenter_given_water_volume_ml: float = 0.0
|
|
178
|
+
"""The additional volume of water, in milliliters, administered by the experimenter to the animal after the session.
|
|
179
|
+
"""
|
|
180
|
+
incomplete: bool = False
|
|
181
|
+
"""If this field is set to True, the session is marked as 'incomplete' and automatically excluded from all further
|
|
182
|
+
Sun lab automated processing and analysis."""
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
@dataclass()
|
|
186
|
+
class ZaberPositions(YamlConfig):
|
|
187
|
+
"""Stores Zaber motor positions reused between experiment sessions that use the Mesoscope-VR system.
|
|
188
|
+
|
|
189
|
+
The class is specifically designed to store, save, and load the positions of the LickPort and HeadBar motors
|
|
190
|
+
(axes). It is used to both store Zaber motor positions for each session for future analysis and to restore the same
|
|
191
|
+
Zaber motor positions across consecutive runtimes for the same project and animal combination.
|
|
192
|
+
|
|
193
|
+
Notes:
|
|
194
|
+
The HeadBar axis (connection) also manages the motor that moves the running wheel along the x-axis. While the
|
|
195
|
+
motor itself is not part of the HeadBar assembly, it is related to positioning the mouse in the VR system. This
|
|
196
|
+
is in contrast to the LickPort group, which is related to positioning the lick tube relative to the mouse.
|
|
197
|
+
|
|
198
|
+
All positions are saved using native motor units. All class fields initialize to default placeholders that are
|
|
199
|
+
likely NOT safe to apply to the VR system. Do not apply the positions loaded from the file unless you are
|
|
200
|
+
certain they are safe to use.
|
|
201
|
+
|
|
202
|
+
Exercise caution when working with Zaber motors. The motors are powerful enough to damage the surrounding
|
|
203
|
+
equipment and manipulated objects. Do not modify the data stored inside the .yaml file unless you know what you
|
|
204
|
+
are doing.
|
|
205
|
+
"""
|
|
206
|
+
|
|
207
|
+
headbar_z: int = 0
|
|
208
|
+
"""The absolute position, in native motor units, of the HeadBar z-axis motor."""
|
|
209
|
+
headbar_pitch: int = 0
|
|
210
|
+
"""The absolute position, in native motor units, of the HeadBar pitch-axis motor."""
|
|
211
|
+
headbar_roll: int = 0
|
|
212
|
+
"""The absolute position, in native motor units, of the HeadBar roll-axis motor."""
|
|
213
|
+
wheel_x: int = 0
|
|
214
|
+
"""The absolute position, in native motor units, of the running wheel platform x-axis motor. Although this motor is
|
|
215
|
+
not itself part of the HeadBar assembly, it is controlled through the HeadBar controller port."""
|
|
216
|
+
lickport_z: int = 0
|
|
217
|
+
"""The absolute position, in native motor units, of the LickPort z-axis motor."""
|
|
218
|
+
lickport_x: int = 0
|
|
219
|
+
"""The absolute position, in native motor units, of the LickPort x-axis motor."""
|
|
220
|
+
lickport_y: int = 0
|
|
221
|
+
"""The absolute position, in native motor units, of the LickPort y-axis motor."""
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
@dataclass()
|
|
225
|
+
class MesoscopePositions(YamlConfig):
|
|
226
|
+
"""Stores real and virtual Mesoscope objective positions reused between experiment sessions that use the
|
|
227
|
+
Mesoscope-VR system.
|
|
228
|
+
|
|
229
|
+
Primarily, the class is used to help the experimenter to position the Mesoscope at the same position across
|
|
230
|
+
multiple imaging sessions. It stores both the physical (real) position of the objective along the motorized
|
|
231
|
+
X, Y, Z, and Roll axes and the virtual (ScanImage software) tip, tilt, and fastZ focus axes.
|
|
232
|
+
|
|
233
|
+
Notes:
|
|
234
|
+
Since the API to read and write these positions automatically is currently not available, this class relies on
|
|
235
|
+
the experimenter manually entering all positions and setting the mesoscope to these positions when necessary.
|
|
236
|
+
"""
|
|
237
|
+
|
|
238
|
+
mesoscope_x: float = 0.0
|
|
239
|
+
"""The X-axis position, in centimeters, of the Mesoscope objective used during session runtime."""
|
|
240
|
+
mesoscope_y: float = 0.0
|
|
241
|
+
"""The Y-axis position, in centimeters, of the Mesoscope objective used during session runtime."""
|
|
242
|
+
mesoscope_roll: float = 0.0
|
|
243
|
+
"""The Roll-axis position, in degrees, of the Mesoscope objective used during session runtime."""
|
|
244
|
+
mesoscope_z: float = 0.0
|
|
245
|
+
"""The Z-axis position, in centimeters, of the Mesoscope objective used during session runtime."""
|
|
246
|
+
mesoscope_fast_z: float = 0.0
|
|
247
|
+
"""The Fast-Z-axis position, in micrometers, of the Mesoscope objective used during session runtime."""
|
|
248
|
+
mesoscope_tip: float = 0.0
|
|
249
|
+
"""The Tilt-axis position, in degrees, of the Mesoscope objective used during session runtime."""
|
|
250
|
+
mesoscope_tilt: float = 0.0
|
|
251
|
+
"""The Tip-axis position, in degrees, of the Mesoscope objective used during session runtime."""
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
from ataraxis_data_structures import YamlConfig
|
|
4
|
+
|
|
5
|
+
@dataclass()
|
|
6
|
+
class MesoscopeHardwareState(YamlConfig):
|
|
7
|
+
"""Stores configuration parameters (states) of the Mesoscope-VR system hardware modules used during training or
|
|
8
|
+
experiment runtime.
|
|
9
|
+
|
|
10
|
+
This information is used to read and decode the data saved to the .npz log files during runtime as part of data
|
|
11
|
+
processing.
|
|
12
|
+
|
|
13
|
+
Notes:
|
|
14
|
+
This class stores 'static' Mesoscope-VR system configuration that does not change during experiment or training
|
|
15
|
+
session runtime. This is in contrast to MesoscopeExperimentState class, which reflects the 'dynamic' state of
|
|
16
|
+
the Mesoscope-VR system.
|
|
17
|
+
|
|
18
|
+
This class partially overlaps with the MesoscopeSystemConfiguration class, which is also stored in the
|
|
19
|
+
raw_data folder of each session. The primary reason to keep both classes is to ensure that the math (rounding)
|
|
20
|
+
used during runtime matches the math (rounding) used during data processing. MesoscopeSystemConfiguration does
|
|
21
|
+
not do any rounding or otherwise attempt to be repeatable, which is in contrast to hardware module that read
|
|
22
|
+
those parameters. Reading values from this class guarantees the read value exactly matches the value used
|
|
23
|
+
during runtime.
|
|
24
|
+
|
|
25
|
+
Notes:
|
|
26
|
+
All fields in this dataclass initialize to None. During log processing, any log associated with a hardware
|
|
27
|
+
module that provides the data stored in a field will be processed, unless that field is None. Therefore, setting
|
|
28
|
+
any field in this dataclass to None also functions as a flag for whether to parse the log associated with the
|
|
29
|
+
module that provides this field's information.
|
|
30
|
+
|
|
31
|
+
This class is automatically configured by _MesoscopeExperiment and _BehaviorTraining classes from sl-experiment
|
|
32
|
+
library to facilitate log parsing.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
cue_map: dict[int, float] | None = ...
|
|
36
|
+
cm_per_pulse: float | None = ...
|
|
37
|
+
maximum_break_strength: float | None = ...
|
|
38
|
+
minimum_break_strength: float | None = ...
|
|
39
|
+
lick_threshold: int | None = ...
|
|
40
|
+
valve_scale_coefficient: float | None = ...
|
|
41
|
+
valve_nonlinearity_exponent: float | None = ...
|
|
42
|
+
torque_per_adc_unit: float | None = ...
|
|
43
|
+
screens_initially_on: bool | None = ...
|
|
44
|
+
recorded_mesoscope_ttl: bool | None = ...
|
|
45
|
+
|
|
46
|
+
@dataclass()
|
|
47
|
+
class LickTrainingDescriptor(YamlConfig):
|
|
48
|
+
"""Stores the task and outcome information specific to lick training sessions that use the Mesoscope-VR system."""
|
|
49
|
+
|
|
50
|
+
experimenter: str
|
|
51
|
+
mouse_weight_g: float
|
|
52
|
+
dispensed_water_volume_ml: float
|
|
53
|
+
minimum_reward_delay: int
|
|
54
|
+
maximum_reward_delay_s: int
|
|
55
|
+
maximum_water_volume_ml: float
|
|
56
|
+
maximum_training_time_m: int
|
|
57
|
+
maximum_unconsumed_rewards: int = ...
|
|
58
|
+
experimenter_notes: str = ...
|
|
59
|
+
experimenter_given_water_volume_ml: float = ...
|
|
60
|
+
incomplete: bool = ...
|
|
61
|
+
|
|
62
|
+
@dataclass()
|
|
63
|
+
class RunTrainingDescriptor(YamlConfig):
|
|
64
|
+
"""Stores the task and outcome information specific to run training sessions that use the Mesoscope-VR system."""
|
|
65
|
+
|
|
66
|
+
experimenter: str
|
|
67
|
+
mouse_weight_g: float
|
|
68
|
+
dispensed_water_volume_ml: float
|
|
69
|
+
final_run_speed_threshold_cm_s: float
|
|
70
|
+
final_run_duration_threshold_s: float
|
|
71
|
+
initial_run_speed_threshold_cm_s: float
|
|
72
|
+
initial_run_duration_threshold_s: float
|
|
73
|
+
increase_threshold_ml: float
|
|
74
|
+
run_speed_increase_step_cm_s: float
|
|
75
|
+
run_duration_increase_step_s: float
|
|
76
|
+
maximum_water_volume_ml: float
|
|
77
|
+
maximum_training_time_m: int
|
|
78
|
+
maximum_unconsumed_rewards: int = ...
|
|
79
|
+
maximum_idle_time_s: float = ...
|
|
80
|
+
experimenter_notes: str = ...
|
|
81
|
+
experimenter_given_water_volume_ml: float = ...
|
|
82
|
+
incomplete: bool = ...
|
|
83
|
+
|
|
84
|
+
@dataclass()
|
|
85
|
+
class MesoscopeExperimentDescriptor(YamlConfig):
|
|
86
|
+
"""Stores the task and outcome information specific to experiment sessions that use the Mesoscope-VR system."""
|
|
87
|
+
|
|
88
|
+
experimenter: str
|
|
89
|
+
mouse_weight_g: float
|
|
90
|
+
dispensed_water_volume_ml: float
|
|
91
|
+
experimenter_notes: str = ...
|
|
92
|
+
experimenter_given_water_volume_ml: float = ...
|
|
93
|
+
incomplete: bool = ...
|
|
94
|
+
|
|
95
|
+
@dataclass()
|
|
96
|
+
class ZaberPositions(YamlConfig):
|
|
97
|
+
"""Stores Zaber motor positions reused between experiment sessions that use the Mesoscope-VR system.
|
|
98
|
+
|
|
99
|
+
The class is specifically designed to store, save, and load the positions of the LickPort and HeadBar motors
|
|
100
|
+
(axes). It is used to both store Zaber motor positions for each session for future analysis and to restore the same
|
|
101
|
+
Zaber motor positions across consecutive runtimes for the same project and animal combination.
|
|
102
|
+
|
|
103
|
+
Notes:
|
|
104
|
+
The HeadBar axis (connection) also manages the motor that moves the running wheel along the x-axis. While the
|
|
105
|
+
motor itself is not part of the HeadBar assembly, it is related to positioning the mouse in the VR system. This
|
|
106
|
+
is in contrast to the LickPort group, which is related to positioning the lick tube relative to the mouse.
|
|
107
|
+
|
|
108
|
+
All positions are saved using native motor units. All class fields initialize to default placeholders that are
|
|
109
|
+
likely NOT safe to apply to the VR system. Do not apply the positions loaded from the file unless you are
|
|
110
|
+
certain they are safe to use.
|
|
111
|
+
|
|
112
|
+
Exercise caution when working with Zaber motors. The motors are powerful enough to damage the surrounding
|
|
113
|
+
equipment and manipulated objects. Do not modify the data stored inside the .yaml file unless you know what you
|
|
114
|
+
are doing.
|
|
115
|
+
"""
|
|
116
|
+
|
|
117
|
+
headbar_z: int = ...
|
|
118
|
+
headbar_pitch: int = ...
|
|
119
|
+
headbar_roll: int = ...
|
|
120
|
+
wheel_x: int = ...
|
|
121
|
+
lickport_z: int = ...
|
|
122
|
+
lickport_x: int = ...
|
|
123
|
+
lickport_y: int = ...
|
|
124
|
+
|
|
125
|
+
@dataclass()
|
|
126
|
+
class MesoscopePositions(YamlConfig):
|
|
127
|
+
"""Stores real and virtual Mesoscope objective positions reused between experiment sessions that use the
|
|
128
|
+
Mesoscope-VR system.
|
|
129
|
+
|
|
130
|
+
Primarily, the class is used to help the experimenter to position the Mesoscope at the same position across
|
|
131
|
+
multiple imaging sessions. It stores both the physical (real) position of the objective along the motorized
|
|
132
|
+
X, Y, Z, and Roll axes and the virtual (ScanImage software) tip, tilt, and fastZ focus axes.
|
|
133
|
+
|
|
134
|
+
Notes:
|
|
135
|
+
Since the API to read and write these positions automatically is currently not available, this class relies on
|
|
136
|
+
the experimenter manually entering all positions and setting the mesoscope to these positions when necessary.
|
|
137
|
+
"""
|
|
138
|
+
|
|
139
|
+
mesoscope_x: float = ...
|
|
140
|
+
mesoscope_y: float = ...
|
|
141
|
+
mesoscope_roll: float = ...
|
|
142
|
+
mesoscope_z: float = ...
|
|
143
|
+
mesoscope_fast_z: float = ...
|
|
144
|
+
mesoscope_tip: float = ...
|
|
145
|
+
mesoscope_tilt: float = ...
|