sl-shared-assets 1.0.0rc19__py3-none-any.whl → 1.0.0rc21__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 +27 -27
- sl_shared_assets/__init__.pyi +73 -0
- sl_shared_assets/cli.py +266 -40
- sl_shared_assets/cli.pyi +87 -0
- sl_shared_assets/data_classes/__init__.py +23 -20
- sl_shared_assets/data_classes/__init__.pyi +61 -0
- sl_shared_assets/data_classes/configuration_data.py +407 -26
- sl_shared_assets/data_classes/configuration_data.pyi +194 -0
- sl_shared_assets/data_classes/runtime_data.py +59 -41
- sl_shared_assets/data_classes/runtime_data.pyi +145 -0
- sl_shared_assets/data_classes/session_data.py +168 -914
- sl_shared_assets/data_classes/session_data.pyi +249 -0
- sl_shared_assets/data_classes/surgery_data.py +3 -3
- sl_shared_assets/data_classes/surgery_data.pyi +89 -0
- sl_shared_assets/server/__init__.pyi +8 -0
- sl_shared_assets/server/job.pyi +94 -0
- sl_shared_assets/server/server.pyi +95 -0
- sl_shared_assets/tools/__init__.py +8 -1
- sl_shared_assets/tools/__init__.pyi +15 -0
- sl_shared_assets/tools/ascension_tools.py +27 -26
- sl_shared_assets/tools/ascension_tools.pyi +68 -0
- sl_shared_assets/tools/packaging_tools.py +14 -1
- sl_shared_assets/tools/packaging_tools.pyi +56 -0
- sl_shared_assets/tools/project_management_tools.py +164 -0
- sl_shared_assets/tools/project_management_tools.pyi +48 -0
- sl_shared_assets/tools/transfer_tools.pyi +53 -0
- {sl_shared_assets-1.0.0rc19.dist-info → sl_shared_assets-1.0.0rc21.dist-info}/METADATA +21 -4
- sl_shared_assets-1.0.0rc21.dist-info/RECORD +36 -0
- sl_shared_assets-1.0.0rc21.dist-info/entry_points.txt +8 -0
- sl_shared_assets/suite2p/__init__.py +0 -8
- sl_shared_assets/suite2p/multi_day.py +0 -225
- sl_shared_assets/suite2p/single_day.py +0 -563
- sl_shared_assets-1.0.0rc19.dist-info/RECORD +0 -23
- sl_shared_assets-1.0.0rc19.dist-info/entry_points.txt +0 -4
- {sl_shared_assets-1.0.0rc19.dist-info → sl_shared_assets-1.0.0rc21.dist-info}/WHEEL +0 -0
- {sl_shared_assets-1.0.0rc19.dist-info → sl_shared_assets-1.0.0rc21.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,194 @@
|
|
|
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
|
+
|
|
62
|
+
@dataclass()
|
|
63
|
+
class MesoscopeCameras:
|
|
64
|
+
"""Stores the configuration parameters for the cameras used by the Mesoscope-VR system to record behavior videos."""
|
|
65
|
+
|
|
66
|
+
face_camera_index: int = ...
|
|
67
|
+
left_camera_index: int = ...
|
|
68
|
+
right_camera_index: int = ...
|
|
69
|
+
quantization_parameter: int = ...
|
|
70
|
+
|
|
71
|
+
@dataclass()
|
|
72
|
+
class MesoscopeMicroControllers:
|
|
73
|
+
"""Stores the configuration parameters for the microcontrollers used by the Mesoscope-VR system."""
|
|
74
|
+
|
|
75
|
+
actor_port: str = ...
|
|
76
|
+
sensor_port: str = ...
|
|
77
|
+
encoder_port: str = ...
|
|
78
|
+
mesoscope_start_ttl_module_id: int = ...
|
|
79
|
+
mesoscope_stop_ttl_module_id: int = ...
|
|
80
|
+
mesoscope_ttl_pulse_duration_ms: int = ...
|
|
81
|
+
minimum_break_strength_g_cm: float = ...
|
|
82
|
+
maximum_break_strength_g_cm: float = ...
|
|
83
|
+
wheel_diameter_cm: float = ...
|
|
84
|
+
lick_threshold_adc: int = ...
|
|
85
|
+
lick_signal_threshold_adc: int = ...
|
|
86
|
+
lick_delta_threshold_adc: int = ...
|
|
87
|
+
lick_averaging_pool_size: int = ...
|
|
88
|
+
torque_baseline_voltage_adc: int = ...
|
|
89
|
+
torque_maximum_voltage_adc: int = ...
|
|
90
|
+
torque_sensor_capacity_g_cm: float = ...
|
|
91
|
+
torque_report_cw: bool = ...
|
|
92
|
+
torque_report_ccw: bool = ...
|
|
93
|
+
torque_signal_threshold_adc: int = ...
|
|
94
|
+
torque_delta_threshold_adc: int = ...
|
|
95
|
+
torque_averaging_pool_size: int = ...
|
|
96
|
+
wheel_encoder_ppr = ...
|
|
97
|
+
wheel_encoder_report_cw: bool = ...
|
|
98
|
+
wheel_encoder_report_ccw: bool = ...
|
|
99
|
+
wheel_encoder_delta_threshold_pulse: int = ...
|
|
100
|
+
wheel_encoder_polling_delay_us = ...
|
|
101
|
+
cm_per_unity_unit = ...
|
|
102
|
+
screen_trigger_pulse_duration_ms: int = ...
|
|
103
|
+
auditory_tone_duration_ms: int = ...
|
|
104
|
+
valve_calibration_pulse_count: int = ...
|
|
105
|
+
sensor_polling_delay_ms: int = ...
|
|
106
|
+
valve_calibration_data: dict[int | float, int | float] | tuple[tuple[int | float, int | float], ...] = ...
|
|
107
|
+
|
|
108
|
+
@dataclass()
|
|
109
|
+
class MesoscopeAdditionalFirmware:
|
|
110
|
+
"""Stores the configuration parameters for all firmware and hardware components not assembled in the Sun lab."""
|
|
111
|
+
|
|
112
|
+
headbar_port: str = ...
|
|
113
|
+
lickport_port: str = ...
|
|
114
|
+
unity_ip: str = ...
|
|
115
|
+
unity_port: int = ...
|
|
116
|
+
|
|
117
|
+
@dataclass()
|
|
118
|
+
class MesoscopeSystemConfiguration(YamlConfig):
|
|
119
|
+
"""Stores the hardware and filesystem configuration parameters for the Mesoscope-VR data acquisition system used in
|
|
120
|
+
the Sun lab.
|
|
121
|
+
|
|
122
|
+
This class is specifically designed to encapsulate the configuration parameters for the Mesoscope-VR system. It
|
|
123
|
+
expects the system to be configured according to the specifications available from the sl_experiment repository
|
|
124
|
+
(https://github.com/Sun-Lab-NBB/sl-experiment) and should be used exclusively by the VRPC machine
|
|
125
|
+
(main Mesoscope-VR PC).
|
|
126
|
+
|
|
127
|
+
Notes:
|
|
128
|
+
Each SystemConfiguration class is uniquely tied to a specific hardware configuration used in the lab. This
|
|
129
|
+
class will only work with the Mesoscope-VR system. Any other data acquisition and runtime management system in
|
|
130
|
+
the lab should define its own SystemConfiguration class to specify its own hardware and filesystem configuration
|
|
131
|
+
parameters.
|
|
132
|
+
"""
|
|
133
|
+
|
|
134
|
+
name: str = ...
|
|
135
|
+
paths: MesoscopePaths = field(default_factory=MesoscopePaths)
|
|
136
|
+
cameras: MesoscopeCameras = field(default_factory=MesoscopeCameras)
|
|
137
|
+
microcontrollers: MesoscopeMicroControllers = field(default_factory=MesoscopeMicroControllers)
|
|
138
|
+
additional_firmware: MesoscopeAdditionalFirmware = field(default_factory=MesoscopeAdditionalFirmware)
|
|
139
|
+
def __post_init__(self) -> None:
|
|
140
|
+
"""Ensures that variables converted to different types for storage purposes are always set to expected types
|
|
141
|
+
upon class instantiation."""
|
|
142
|
+
def save(self, path: Path) -> None:
|
|
143
|
+
"""Saves class instance data to disk as a 'mesoscope_system_configuration.yaml' file.
|
|
144
|
+
|
|
145
|
+
This method converts certain class variables to yaml-safe types (for example, Path objects -> strings) and
|
|
146
|
+
saves class data to disk as a .yaml file. The method is intended to be used solely by the
|
|
147
|
+
set_system_configuration_file() function and should not be called from any other context.
|
|
148
|
+
|
|
149
|
+
Args:
|
|
150
|
+
path: The path to the .yaml file to save the data to.
|
|
151
|
+
"""
|
|
152
|
+
|
|
153
|
+
_supported_configuration_files: Incomplete
|
|
154
|
+
|
|
155
|
+
def set_system_configuration_file(path: Path) -> None:
|
|
156
|
+
"""Sets the system configuration .yaml file specified by the input path as the default system configuration file for
|
|
157
|
+
the managed machine (PC).
|
|
158
|
+
|
|
159
|
+
This function is used to initially configure or override the existing configuration of any data acquisition system
|
|
160
|
+
used in the lab. The path to the configuration file is stored inside the user's data directory, so that all
|
|
161
|
+
Sun lab libraries can automatically access that information during every runtime. Since the storage directory is
|
|
162
|
+
typically hidden and varies between OSes and machines, this function provides a convenient way for setting that
|
|
163
|
+
path without manually editing the storage cache.
|
|
164
|
+
|
|
165
|
+
Notes:
|
|
166
|
+
If the input path does not point to an existing file, but the file name and extension are correct, the function
|
|
167
|
+
will automatically generate a default SystemConfiguration class instance and save it under the specified path.
|
|
168
|
+
|
|
169
|
+
A data acquisition system can include multiple machines (PCs). However, the configuration file is typically
|
|
170
|
+
only present on the 'main' machine that manages all runtimes.
|
|
171
|
+
|
|
172
|
+
Args:
|
|
173
|
+
path: The path to the new system configuration file to be used by the local data acquisition system (PC).
|
|
174
|
+
|
|
175
|
+
Raises:
|
|
176
|
+
ValueError: If the input path is not a valid system configuration file or does not use a supported data
|
|
177
|
+
acquisition system name.
|
|
178
|
+
"""
|
|
179
|
+
|
|
180
|
+
def get_system_configuration_data() -> MesoscopeSystemConfiguration:
|
|
181
|
+
"""Resolves the path to the local system configuration file and loads the system configuration data.
|
|
182
|
+
|
|
183
|
+
This service function is used by all Sun lab data acquisition runtimes to load the system configuration data from
|
|
184
|
+
the shared configuration file. It supports resolving and returning the data for all data acquisition systems used
|
|
185
|
+
in the lab.
|
|
186
|
+
|
|
187
|
+
Returns:
|
|
188
|
+
The initialized SystemConfiguration class instance for the local acquisition system that stores the loaded
|
|
189
|
+
configuration parameters.
|
|
190
|
+
|
|
191
|
+
Raises:
|
|
192
|
+
FileNotFoundError: If the local machine does not have the Sun lab data directory, or the system configuration
|
|
193
|
+
file does not exist.
|
|
194
|
+
"""
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""This module provides classes used to store the training and experiment data acquired by the sl-experiment library.
|
|
2
2
|
Some classes from this library store raw data later processed by Sun lab data processing pipelines. Others are used to
|
|
3
|
-
restore the
|
|
3
|
+
restore the data acquisition and runtime management system to the same state across training or experiment sessions for
|
|
4
|
+
the same animal.
|
|
4
5
|
"""
|
|
5
6
|
|
|
6
7
|
from dataclasses import dataclass
|
|
@@ -9,19 +10,32 @@ from ataraxis_data_structures import YamlConfig
|
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
@dataclass()
|
|
12
|
-
class
|
|
13
|
-
"""
|
|
13
|
+
class MesoscopeHardwareState(YamlConfig):
|
|
14
|
+
"""Stores configuration parameters (states) of the Mesoscope-VR system hardware modules used during training or
|
|
15
|
+
experiment runtime.
|
|
14
16
|
|
|
15
17
|
This information is used to read and decode the data saved to the .npz log files during runtime as part of data
|
|
16
18
|
processing.
|
|
17
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
|
+
|
|
18
32
|
Notes:
|
|
19
33
|
All fields in this dataclass initialize to None. During log processing, any log associated with a hardware
|
|
20
34
|
module that provides the data stored in a field will be processed, unless that field is None. Therefore, setting
|
|
21
35
|
any field in this dataclass to None also functions as a flag for whether to parse the log associated with the
|
|
22
36
|
module that provides this field's information.
|
|
23
37
|
|
|
24
|
-
This class is automatically configured by
|
|
38
|
+
This class is automatically configured by _MesoscopeExperiment and _BehaviorTraining classes from sl-experiment
|
|
25
39
|
library to facilitate log parsing.
|
|
26
40
|
"""
|
|
27
41
|
|
|
@@ -66,15 +80,7 @@ class HardwareConfiguration(YamlConfig):
|
|
|
66
80
|
|
|
67
81
|
@dataclass()
|
|
68
82
|
class LickTrainingDescriptor(YamlConfig):
|
|
69
|
-
"""
|
|
70
|
-
|
|
71
|
-
The information stored in this class instance is filled in two steps. The main runtime function fills most fields
|
|
72
|
-
of the class, before it is saved as a .yaml file. After runtime, the experimenter manually fills leftover fields,
|
|
73
|
-
such as 'experimenter_notes,' before the class instance is transferred to the long-term storage destination.
|
|
74
|
-
|
|
75
|
-
The fully filled instance data is also used during preprocessing to write the water restriction log entry for the
|
|
76
|
-
trained animal.
|
|
77
|
-
"""
|
|
83
|
+
"""Stores the task and outcome information specific to lick training sessions that use the Mesoscope-VR system."""
|
|
78
84
|
|
|
79
85
|
experimenter: str
|
|
80
86
|
"""The ID of the experimenter running the session."""
|
|
@@ -90,25 +96,24 @@ class LickTrainingDescriptor(YamlConfig):
|
|
|
90
96
|
"""Stores the maximum volume of water the system is allowed to dispense during training."""
|
|
91
97
|
maximum_training_time_m: int
|
|
92
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."""
|
|
93
103
|
experimenter_notes: str = "Replace this with your notes."
|
|
94
104
|
"""This field is not set during runtime. It is expected that each experimenter replaces this field with their
|
|
95
105
|
notes made during runtime."""
|
|
96
106
|
experimenter_given_water_volume_ml: float = 0.0
|
|
97
107
|
"""The additional volume of water, in milliliters, administered by the experimenter to the animal after the session.
|
|
98
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."""
|
|
99
112
|
|
|
100
113
|
|
|
101
114
|
@dataclass()
|
|
102
115
|
class RunTrainingDescriptor(YamlConfig):
|
|
103
|
-
"""
|
|
104
|
-
|
|
105
|
-
The information stored in this class instance is filled in two steps. The main runtime function fills most fields
|
|
106
|
-
of the class, before it is saved as a .yaml file. After runtime, the experimenter manually fills leftover fields,
|
|
107
|
-
such as 'experimenter_notes,' before the class instance is transferred to the long-term storage destination.
|
|
108
|
-
|
|
109
|
-
The fully filled instance data is also used during preprocessing to write the water restriction log entry for the
|
|
110
|
-
trained animal.
|
|
111
|
-
"""
|
|
116
|
+
"""Stores the task and outcome information specific to run training sessions that use the Mesoscope-VR system."""
|
|
112
117
|
|
|
113
118
|
experimenter: str
|
|
114
119
|
"""The ID of the experimenter running the session."""
|
|
@@ -137,25 +142,28 @@ class RunTrainingDescriptor(YamlConfig):
|
|
|
137
142
|
"""Stores the maximum volume of water the system is allowed to dispense during training."""
|
|
138
143
|
maximum_training_time_m: int
|
|
139
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."""
|
|
140
153
|
experimenter_notes: str = "Replace this with your notes."
|
|
141
154
|
"""This field is not set during runtime. It is expected that each experimenter will replace this field with their
|
|
142
155
|
notes made during runtime."""
|
|
143
156
|
experimenter_given_water_volume_ml: float = 0.0
|
|
144
157
|
"""The additional volume of water, in milliliters, administered by the experimenter to the animal after the session.
|
|
145
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."""
|
|
146
162
|
|
|
147
163
|
|
|
148
164
|
@dataclass()
|
|
149
165
|
class MesoscopeExperimentDescriptor(YamlConfig):
|
|
150
|
-
"""
|
|
151
|
-
|
|
152
|
-
The information stored in this class instance is filled in two steps. The main runtime function fills most fields
|
|
153
|
-
of the class, before it is saved as a .yaml file. After runtime, the experimenter manually fills leftover fields,
|
|
154
|
-
such as 'experimenter_notes,' before the class instance is transferred to the long-term storage destination.
|
|
155
|
-
|
|
156
|
-
The fully filled instance data is also used during preprocessing to write the water restriction log entry for the
|
|
157
|
-
animal participating in the experiment runtime.
|
|
158
|
-
"""
|
|
166
|
+
"""Stores the task and outcome information specific to experiment sessions that use the Mesoscope-VR system."""
|
|
159
167
|
|
|
160
168
|
experimenter: str
|
|
161
169
|
"""The ID of the experimenter running the session."""
|
|
@@ -169,17 +177,24 @@ class MesoscopeExperimentDescriptor(YamlConfig):
|
|
|
169
177
|
experimenter_given_water_volume_ml: float = 0.0
|
|
170
178
|
"""The additional volume of water, in milliliters, administered by the experimenter to the animal after the session.
|
|
171
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."""
|
|
172
183
|
|
|
173
184
|
|
|
174
185
|
@dataclass()
|
|
175
186
|
class ZaberPositions(YamlConfig):
|
|
176
|
-
"""
|
|
187
|
+
"""Stores Zaber motor positions reused between experiment sessions that use the Mesoscope-VR system.
|
|
177
188
|
|
|
178
189
|
The class is specifically designed to store, save, and load the positions of the LickPort and HeadBar motors
|
|
179
190
|
(axes). It is used to both store Zaber motor positions for each session for future analysis and to restore the same
|
|
180
191
|
Zaber motor positions across consecutive runtimes for the same project and animal combination.
|
|
181
192
|
|
|
182
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
|
+
|
|
183
198
|
All positions are saved using native motor units. All class fields initialize to default placeholders that are
|
|
184
199
|
likely NOT safe to apply to the VR system. Do not apply the positions loaded from the file unless you are
|
|
185
200
|
certain they are safe to use.
|
|
@@ -195,6 +210,9 @@ class ZaberPositions(YamlConfig):
|
|
|
195
210
|
"""The absolute position, in native motor units, of the HeadBar pitch-axis motor."""
|
|
196
211
|
headbar_roll: int = 0
|
|
197
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."""
|
|
198
216
|
lickport_z: int = 0
|
|
199
217
|
"""The absolute position, in native motor units, of the LickPort z-axis motor."""
|
|
200
218
|
lickport_x: int = 0
|
|
@@ -205,8 +223,8 @@ class ZaberPositions(YamlConfig):
|
|
|
205
223
|
|
|
206
224
|
@dataclass()
|
|
207
225
|
class MesoscopePositions(YamlConfig):
|
|
208
|
-
"""
|
|
209
|
-
|
|
226
|
+
"""Stores real and virtual Mesoscope objective positions reused between experiment sessions that use the
|
|
227
|
+
Mesoscope-VR system.
|
|
210
228
|
|
|
211
229
|
Primarily, the class is used to help the experimenter to position the Mesoscope at the same position across
|
|
212
230
|
multiple imaging sessions. It stores both the physical (real) position of the objective along the motorized
|
|
@@ -217,17 +235,17 @@ class MesoscopePositions(YamlConfig):
|
|
|
217
235
|
the experimenter manually entering all positions and setting the mesoscope to these positions when necessary.
|
|
218
236
|
"""
|
|
219
237
|
|
|
220
|
-
|
|
238
|
+
mesoscope_x: float = 0.0
|
|
221
239
|
"""The X-axis position, in centimeters, of the Mesoscope objective used during session runtime."""
|
|
222
|
-
|
|
240
|
+
mesoscope_y: float = 0.0
|
|
223
241
|
"""The Y-axis position, in centimeters, of the Mesoscope objective used during session runtime."""
|
|
224
|
-
|
|
242
|
+
mesoscope_roll: float = 0.0
|
|
225
243
|
"""The Roll-axis position, in degrees, of the Mesoscope objective used during session runtime."""
|
|
226
|
-
|
|
244
|
+
mesoscope_z: float = 0.0
|
|
227
245
|
"""The Z-axis position, in centimeters, of the Mesoscope objective used during session runtime."""
|
|
228
|
-
|
|
246
|
+
mesoscope_fast_z: float = 0.0
|
|
229
247
|
"""The Fast-Z-axis position, in micrometers, of the Mesoscope objective used during session runtime."""
|
|
230
|
-
|
|
248
|
+
mesoscope_tip: float = 0.0
|
|
231
249
|
"""The Tilt-axis position, in degrees, of the Mesoscope objective used during session runtime."""
|
|
232
|
-
|
|
250
|
+
mesoscope_tilt: float = 0.0
|
|
233
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 = ...
|