sl-shared-assets 2.0.1__py3-none-any.whl → 3.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 +17 -9
- sl_shared_assets/__init__.pyi +12 -8
- sl_shared_assets/cli.py +258 -21
- sl_shared_assets/cli.pyi +44 -5
- sl_shared_assets/data_classes/__init__.py +8 -3
- sl_shared_assets/data_classes/__init__.pyi +8 -4
- sl_shared_assets/data_classes/configuration_data.py +149 -30
- sl_shared_assets/data_classes/configuration_data.pyi +49 -11
- sl_shared_assets/data_classes/runtime_data.py +70 -49
- sl_shared_assets/data_classes/runtime_data.pyi +41 -33
- sl_shared_assets/data_classes/session_data.py +193 -253
- sl_shared_assets/data_classes/session_data.pyi +99 -116
- sl_shared_assets/data_classes/surgery_data.py +1 -1
- sl_shared_assets/server/__init__.py +2 -2
- sl_shared_assets/server/__init__.pyi +5 -2
- sl_shared_assets/server/job.py +229 -1
- sl_shared_assets/server/job.pyi +111 -0
- sl_shared_assets/server/server.py +431 -31
- sl_shared_assets/server/server.pyi +158 -15
- sl_shared_assets/tools/__init__.py +2 -1
- sl_shared_assets/tools/__init__.pyi +2 -0
- sl_shared_assets/tools/ascension_tools.py +9 -21
- sl_shared_assets/tools/ascension_tools.pyi +1 -1
- sl_shared_assets/tools/packaging_tools.py +2 -2
- sl_shared_assets/tools/project_management_tools.py +147 -41
- sl_shared_assets/tools/project_management_tools.pyi +45 -6
- {sl_shared_assets-2.0.1.dist-info → sl_shared_assets-3.0.0.dist-info}/METADATA +127 -13
- sl_shared_assets-3.0.0.dist-info/RECORD +36 -0
- {sl_shared_assets-2.0.1.dist-info → sl_shared_assets-3.0.0.dist-info}/entry_points.txt +2 -0
- sl_shared_assets-2.0.1.dist-info/RECORD +0 -36
- {sl_shared_assets-2.0.1.dist-info → sl_shared_assets-3.0.0.dist-info}/WHEEL +0 -0
- {sl_shared_assets-2.0.1.dist-info → sl_shared_assets-3.0.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -4,15 +4,15 @@ from .runtime_data import (
|
|
|
4
4
|
RunTrainingDescriptor as RunTrainingDescriptor,
|
|
5
5
|
LickTrainingDescriptor as LickTrainingDescriptor,
|
|
6
6
|
MesoscopeHardwareState as MesoscopeHardwareState,
|
|
7
|
+
WindowCheckingDescriptor as WindowCheckingDescriptor,
|
|
7
8
|
MesoscopeExperimentDescriptor as MesoscopeExperimentDescriptor,
|
|
8
9
|
)
|
|
9
10
|
from .session_data import (
|
|
10
11
|
RawData as RawData,
|
|
11
12
|
SessionData as SessionData,
|
|
12
|
-
|
|
13
|
+
SessionTypes as SessionTypes,
|
|
13
14
|
ProcessedData as ProcessedData,
|
|
14
15
|
ProcessingTracker as ProcessingTracker,
|
|
15
|
-
ProjectConfiguration as ProjectConfiguration,
|
|
16
16
|
)
|
|
17
17
|
from .surgery_data import (
|
|
18
18
|
DrugData as DrugData,
|
|
@@ -25,7 +25,9 @@ from .surgery_data import (
|
|
|
25
25
|
from .configuration_data import (
|
|
26
26
|
MesoscopePaths as MesoscopePaths,
|
|
27
27
|
ExperimentState as ExperimentState,
|
|
28
|
+
ExperimentTrial as ExperimentTrial,
|
|
28
29
|
MesoscopeCameras as MesoscopeCameras,
|
|
30
|
+
AcquisitionSystems as AcquisitionSystems,
|
|
29
31
|
MesoscopeMicroControllers as MesoscopeMicroControllers,
|
|
30
32
|
MesoscopeAdditionalFirmware as MesoscopeAdditionalFirmware,
|
|
31
33
|
MesoscopeSystemConfiguration as MesoscopeSystemConfiguration,
|
|
@@ -39,7 +41,6 @@ __all__ = [
|
|
|
39
41
|
"ImplantData",
|
|
40
42
|
"SessionData",
|
|
41
43
|
"RawData",
|
|
42
|
-
"VersionData",
|
|
43
44
|
"ProcessedData",
|
|
44
45
|
"SubjectData",
|
|
45
46
|
"SurgeryData",
|
|
@@ -48,7 +49,6 @@ __all__ = [
|
|
|
48
49
|
"ZaberPositions",
|
|
49
50
|
"ExperimentState",
|
|
50
51
|
"MesoscopePositions",
|
|
51
|
-
"ProjectConfiguration",
|
|
52
52
|
"MesoscopeHardwareState",
|
|
53
53
|
"RunTrainingDescriptor",
|
|
54
54
|
"LickTrainingDescriptor",
|
|
@@ -62,4 +62,8 @@ __all__ = [
|
|
|
62
62
|
"MesoscopeMicroControllers",
|
|
63
63
|
"MesoscopeAdditionalFirmware",
|
|
64
64
|
"ProcessingTracker",
|
|
65
|
+
"ExperimentTrial",
|
|
66
|
+
"AcquisitionSystems",
|
|
67
|
+
"SessionTypes",
|
|
68
|
+
"WindowCheckingDescriptor",
|
|
65
69
|
]
|
|
@@ -3,6 +3,7 @@ projects use classes from this module to configure experiment runtimes and deter
|
|
|
3
3
|
particular data acquisition and runtime management system (hardware) they run on."""
|
|
4
4
|
|
|
5
5
|
import copy
|
|
6
|
+
from enum import StrEnum
|
|
6
7
|
from pathlib import Path
|
|
7
8
|
from dataclasses import field, dataclass
|
|
8
9
|
|
|
@@ -11,16 +12,23 @@ from ataraxis_base_utilities import LogLevel, console, ensure_directory_exists
|
|
|
11
12
|
from ataraxis_data_structures import YamlConfig
|
|
12
13
|
|
|
13
14
|
|
|
15
|
+
class AcquisitionSystems(StrEnum):
|
|
16
|
+
"""Defines the set of data acquisition systems used in the Sun lab and supported by all data-related libraries."""
|
|
17
|
+
|
|
18
|
+
MESOSCOPE_VR = "mesoscope-vr"
|
|
19
|
+
"""The Mesoscope-VR data acquisition system. It is built around 2-Photon Random Access Mesoscope (2P-RAM) and
|
|
20
|
+
relies on Unity-backed virtual reality task-environments to conduct experiments."""
|
|
21
|
+
|
|
22
|
+
|
|
14
23
|
@dataclass()
|
|
15
24
|
class ExperimentState:
|
|
16
25
|
"""Encapsulates the information used to set and maintain the desired experiment and system state.
|
|
17
26
|
|
|
18
|
-
Broadly, each experiment runtime can be conceptualized as a two state-system. The first
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
'what the hardware is doing'.
|
|
27
|
+
Broadly, each experiment runtime can be conceptualized as a two state-system. The first is the experiment task,
|
|
28
|
+
which reflects the behavior goal, the rules for achieving the goal, and the reward for achieving the goal. The
|
|
29
|
+
second is the data acquisition system state, which is a snapshot of all hardware module states that make up the
|
|
30
|
+
system that acquires the data and controls the task environment. Overall, experiment state is about
|
|
31
|
+
'what the animal is doing', while the system state is about 'what the hardware is doing'.
|
|
24
32
|
|
|
25
33
|
Note:
|
|
26
34
|
This class is acquisition-system-agnostic. It can be used to define the ExperimentConfiguration class for any
|
|
@@ -35,10 +43,52 @@ class ExperimentState:
|
|
|
35
43
|
while maintaining the same experiment state."""
|
|
36
44
|
system_state_code: int
|
|
37
45
|
"""One of the supported system state-codes. Note, the meaning of each system state code depends on the specific
|
|
38
|
-
data acquisition and experiment control system used by the project. For
|
|
39
|
-
|
|
46
|
+
data acquisition and experiment control system used by the project. For details on available system-states, see
|
|
47
|
+
the sl-experiment library documentation."""
|
|
40
48
|
state_duration_s: float
|
|
41
|
-
"""The time, in seconds, to maintain the
|
|
49
|
+
"""The time, in seconds, to maintain the experiment and system state combination specified by this instance."""
|
|
50
|
+
initial_guided_trials: int
|
|
51
|
+
"""The number of trials (laps) at the onset of the experiment state, for which to enable lick guidance. This
|
|
52
|
+
determines the number of trials, counting from the onset of the experiment state, for which the animal will receive
|
|
53
|
+
water rewards from entering the reward zone. Once the specified number of guided trial passes, the system disables
|
|
54
|
+
guidance, requiring the animal to lick in the reward zone to get water rewards."""
|
|
55
|
+
recovery_failed_trial_threshold: int
|
|
56
|
+
"""Specifies the number of failed (non-rewarded) trials (laps), after which the system will re-enable lick guidance
|
|
57
|
+
for the 'recovery_guided_trials' number of following trials. Note, engaging the recovery guided trial system
|
|
58
|
+
requires the specified number of failed trials to occur sequentially."""
|
|
59
|
+
recovery_guided_trials: int
|
|
60
|
+
"""Specifies the number of trials (laps) for which the system should re-enable lick guidance, when the animal
|
|
61
|
+
sequentially fails 'failed_trial_threshold' number of trials. This field works similar to the
|
|
62
|
+
'initial_guided_trials' field, but is triggered by repeated performance failures, rather than experiment state
|
|
63
|
+
onset. After the animal runs this many guided trials, the system automatically disables guidance for the following
|
|
64
|
+
trials."""
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@dataclass()
|
|
68
|
+
class ExperimentTrial:
|
|
69
|
+
"""Encapsulates information about a single experiment trial.
|
|
70
|
+
|
|
71
|
+
All Virtual Reality tasks can be broadly conceptualized as repeating motifs (sequences) of wall cues,
|
|
72
|
+
associated with a specific goal, for which animals receive water rewards. Since some experiments can use multiple
|
|
73
|
+
trial types as part of the same experiment session, multiple instances of this class can be used to specify
|
|
74
|
+
supported trial structures and trial parameters for a given experiment.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
cue_sequence: list[int]
|
|
78
|
+
"""Specifies the sequence of wall cues experienced by the animal while running this trial. Note, the cues must be
|
|
79
|
+
specified as integer-codes, where each code has the same meaning as in the 'cue_map' dictionary of the main
|
|
80
|
+
ExperimentConfiguration class for that experiment."""
|
|
81
|
+
trial_length_cm: float
|
|
82
|
+
"""The length of the trial cue sequence in centimeters."""
|
|
83
|
+
trial_reward_size_ul: float
|
|
84
|
+
"""The volume of water, in microliters, to be dispensed when the animal successfully completes the trial task."""
|
|
85
|
+
reward_zone_start_cm: float
|
|
86
|
+
"""Specifies the starting boundary of the trial reward zone, in centimeters."""
|
|
87
|
+
reward_zone_end_cm: float
|
|
88
|
+
"""Specifies the ending boundary of the trial reward zone, in centimeters."""
|
|
89
|
+
guidance_trigger_location_cm: float
|
|
90
|
+
"""Specifies the location of the invisible boundary (wall) with which the animal must collide to elicit automated
|
|
91
|
+
water reward during guided trials."""
|
|
42
92
|
|
|
43
93
|
|
|
44
94
|
# noinspection PyArgumentList
|
|
@@ -47,10 +97,11 @@ class MesoscopeExperimentConfiguration(YamlConfig):
|
|
|
47
97
|
"""Stores the configuration of a single experiment runtime that uses the Mesoscope_VR data acquisition system.
|
|
48
98
|
|
|
49
99
|
Primarily, this includes the sequence of experiment and system states that defines the flow of the experiment
|
|
50
|
-
runtime
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
100
|
+
runtime and the configuration of various trials supported by the experiment runtime. During runtime, the main
|
|
101
|
+
runtime control function traverses the sequence of states stored in this class instance start-to-end in the exact
|
|
102
|
+
order specified by the user. Together with custom Unity projects that define the task logic (how the system
|
|
103
|
+
responds to animal interactions with the VR system) this class allows flexibly implementing a wide range of
|
|
104
|
+
experiments using the Mesoscope-VR system.
|
|
54
105
|
|
|
55
106
|
Each project should define one or more experiment configurations and save them as .yaml files inside the project
|
|
56
107
|
'configuration' folder. The name for each configuration file is defined by the user and is used to identify and load
|
|
@@ -59,21 +110,70 @@ class MesoscopeExperimentConfiguration(YamlConfig):
|
|
|
59
110
|
Notes:
|
|
60
111
|
This class is designed exclusively for the Mesoscope-VR system. Any other system needs to define a separate
|
|
61
112
|
ExperimentConfiguration class to specify its experiment runtimes and additional data.
|
|
113
|
+
|
|
114
|
+
To create a new experiment configuration, use the 'sl-create-experiment' CLI command.
|
|
62
115
|
"""
|
|
63
116
|
|
|
64
117
|
cue_map: dict[int, float] = field(default_factory=lambda: {0: 30.0, 1: 30.0, 2: 30.0, 3: 30.0, 4: 30.0})
|
|
65
118
|
"""A dictionary that maps each integer-code associated with a wall cue used in the Virtual Reality experiment
|
|
66
119
|
environment to its length in real-world centimeters. It is used to map each VR cue to the distance the animal needs
|
|
67
120
|
to travel to fully traverse the wall cue region from start to end."""
|
|
121
|
+
cue_offset_cm: float = 10.0
|
|
122
|
+
"""Specifies the positive offset distance, in centimeters, by which the animal's running track is shifted
|
|
123
|
+
relative to VR wall cue sequence. Due to how the VR environment is revealed to the animal, most runtimes
|
|
124
|
+
need to shift the animal slightly forward relative to the VR cue sequence origin (0), to prevent it from seeing the
|
|
125
|
+
area before the first VR wall cue when the task starts and when the animal is teleported to the beginning of the
|
|
126
|
+
track. This offset statically shifts the entire track (in centimeters) against the set of VR wall cues used during
|
|
127
|
+
runtime. Storing this static offset as part of experiment configuration is crucial for correctly mapping what the
|
|
128
|
+
animal sees during runtime to the real-world distance it travels on the running wheel."""
|
|
129
|
+
unity_scene_name: str = "IvanScene"
|
|
130
|
+
"""The name of the Virtual Reality task (Unity Scene) used during experiment. This is used as an extra security
|
|
131
|
+
measure to ensure that Unity game engine is running the correct scene when starting the experiment runtime."""
|
|
68
132
|
experiment_states: dict[str, ExperimentState] = field(
|
|
69
133
|
default_factory=lambda: {
|
|
70
|
-
"baseline": ExperimentState(
|
|
71
|
-
|
|
72
|
-
|
|
134
|
+
"baseline": ExperimentState(
|
|
135
|
+
experiment_state_code=1,
|
|
136
|
+
system_state_code=1,
|
|
137
|
+
state_duration_s=30,
|
|
138
|
+
initial_guided_trials=0,
|
|
139
|
+
recovery_failed_trial_threshold=0,
|
|
140
|
+
recovery_guided_trials=0,
|
|
141
|
+
),
|
|
142
|
+
"experiment": ExperimentState(
|
|
143
|
+
experiment_state_code=2,
|
|
144
|
+
system_state_code=2,
|
|
145
|
+
state_duration_s=120,
|
|
146
|
+
initial_guided_trials=3,
|
|
147
|
+
recovery_failed_trial_threshold=6,
|
|
148
|
+
recovery_guided_trials=3,
|
|
149
|
+
),
|
|
150
|
+
"cooldown": ExperimentState(
|
|
151
|
+
experiment_state_code=3,
|
|
152
|
+
system_state_code=1,
|
|
153
|
+
state_duration_s=15,
|
|
154
|
+
initial_guided_trials=1000000,
|
|
155
|
+
recovery_failed_trial_threshold=0,
|
|
156
|
+
recovery_guided_trials=0,
|
|
157
|
+
),
|
|
73
158
|
}
|
|
74
159
|
)
|
|
75
160
|
"""A dictionary that uses human-readable state-names as keys and ExperimentState instances as values. Each
|
|
76
161
|
ExperimentState instance represents a phase of the experiment."""
|
|
162
|
+
trial_structures: dict[str, ExperimentTrial] = field(
|
|
163
|
+
default_factory=lambda: {
|
|
164
|
+
"cyclic_4_cue": ExperimentTrial(
|
|
165
|
+
cue_sequence=[1, 0, 2, 0, 3, 0, 4, 0],
|
|
166
|
+
trial_length_cm=240.0,
|
|
167
|
+
trial_reward_size_ul=5.0,
|
|
168
|
+
reward_zone_start_cm=208.0,
|
|
169
|
+
reward_zone_end_cm=222.0,
|
|
170
|
+
guidance_trigger_location_cm=208.0,
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
"""A dictionary that uses human-readable trial structure names as keys and ExperimentTrial instances as values.
|
|
175
|
+
Each ExperimentTrial instance specifies the Virtual Reality layout and runtime parameters associated with a single
|
|
176
|
+
type of trials supported by the experiment runtime."""
|
|
77
177
|
|
|
78
178
|
|
|
79
179
|
@dataclass()
|
|
@@ -113,6 +213,22 @@ class MesoscopePaths:
|
|
|
113
213
|
"""The path to the GeniCam CTI file used to connect to Harvesters-managed cameras."""
|
|
114
214
|
|
|
115
215
|
|
|
216
|
+
@dataclass()
|
|
217
|
+
class MesoscopeSheets:
|
|
218
|
+
"""Stores the IDs of Google Sheets used by the Mesoscope-VR data acquisition system."""
|
|
219
|
+
|
|
220
|
+
surgery_sheet_id: str = ""
|
|
221
|
+
"""The ID of the Google Sheet file that stores information about surgical interventions performed on all animals
|
|
222
|
+
participating in each lab project. This log sheet is used to parse and write the surgical intervention data for
|
|
223
|
+
each animal into every runtime session raw_data folder, so that the surgery data is always kept together with the
|
|
224
|
+
rest of the training and experiment data."""
|
|
225
|
+
water_log_sheet_id: str = ""
|
|
226
|
+
"""The ID of the Google Sheet file that stores information about water restriction (and behavior tracker)
|
|
227
|
+
information for all animals participating in the managed project. This is used to synchronize the information
|
|
228
|
+
inside the water restriction log with the state of the animal at the end of each training or experiment session.
|
|
229
|
+
"""
|
|
230
|
+
|
|
231
|
+
|
|
116
232
|
@dataclass()
|
|
117
233
|
class MesoscopeCameras:
|
|
118
234
|
"""Stores the configuration parameters for the cameras used by the Mesoscope-VR system to record behavior videos."""
|
|
@@ -152,9 +268,6 @@ class MesoscopeMicroControllers:
|
|
|
152
268
|
"""Determines whether to run the managed acquisition system in the 'debug mode'. This mode should be disabled
|
|
153
269
|
during most runtimes. It is used during initial system calibration and testing and prints a lot of generally
|
|
154
270
|
redundant information into the terminal."""
|
|
155
|
-
mesoscope_ttl_pulse_duration_ms: int = 10
|
|
156
|
-
"""The duration of the HIGH phase of all outgoing TTL pulses that target the Mesoscope (enable or disable mesoscope
|
|
157
|
-
frame acquisition), in milliseconds."""
|
|
158
271
|
minimum_break_strength_g_cm: float = 43.2047
|
|
159
272
|
"""The minimum torque applied by the running wheel break in gram centimeter. This is the torque the break delivers
|
|
160
273
|
at minimum voltage (break is disabled)."""
|
|
@@ -163,7 +276,7 @@ class MesoscopeMicroControllers:
|
|
|
163
276
|
at maximum voltage (break is fully engaged)."""
|
|
164
277
|
wheel_diameter_cm: float = 15.0333
|
|
165
278
|
"""The diameter of the running wheel connected to the break and torque sensor, in centimeters."""
|
|
166
|
-
lick_threshold_adc: int =
|
|
279
|
+
lick_threshold_adc: int = 850
|
|
167
280
|
"""The threshold voltage, in raw analog units recorded by a 12-bit Analog-to-Digital-Converter (ADC), interpreted
|
|
168
281
|
as the animal's tongue contacting the sensor. Note, 12-bit ADC only supports values between 0 and 4095, so setting
|
|
169
282
|
the threshold above 4095 will result in no licks being reported to Unity."""
|
|
@@ -174,8 +287,10 @@ class MesoscopeMicroControllers:
|
|
|
174
287
|
"""The minimum absolute difference in raw analog units recorded by a 12-bit Analog-to-Digital-Converter (ADC) for
|
|
175
288
|
the change to be reported to the PC. This is used to prevent reporting repeated non-lick or lick readouts to the
|
|
176
289
|
PC, conserving communication bandwidth."""
|
|
177
|
-
lick_averaging_pool_size: int =
|
|
178
|
-
"""The number of lick sensor readouts to average together to produce the final lick sensor readout value.
|
|
290
|
+
lick_averaging_pool_size: int = 1
|
|
291
|
+
"""The number of lick sensor readouts to average together to produce the final lick sensor readout value. Note,
|
|
292
|
+
when using a Teensy controller, this number is multiplied by the built-in analog readout averaging (default is 4).
|
|
293
|
+
"""
|
|
179
294
|
torque_baseline_voltage_adc: int = 2046
|
|
180
295
|
"""The voltage level, in raw analog units measured by 3.3v Analog-to-Digital-Converter (ADC) at 12-bit resolution
|
|
181
296
|
after the AD620 amplifier, that corresponds to no (0) torque readout. Usually, for a 3.3v ADC, this would be
|
|
@@ -192,15 +307,17 @@ class MesoscopeMicroControllers:
|
|
|
192
307
|
torque_report_ccw: bool = True
|
|
193
308
|
"""Determines whether the sensor should report torque in the Counter-Clockwise (CCW) direction. This direction
|
|
194
309
|
corresponds to the animal trying to move the wheel forward."""
|
|
195
|
-
torque_signal_threshold_adc: int =
|
|
310
|
+
torque_signal_threshold_adc: int = 100
|
|
196
311
|
"""The minimum voltage, in raw analog units recorded by a 12-bit Analog-to-Digital-Converter (ADC), reported to the
|
|
197
312
|
PC as a non-zero value. Voltages below this level are interpreted as noise and are always pulled to 0."""
|
|
198
|
-
torque_delta_threshold_adc: int =
|
|
313
|
+
torque_delta_threshold_adc: int = 70
|
|
199
314
|
"""The minimum absolute difference in raw analog units recorded by a 12-bit Analog-to-Digital-Converter (ADC) for
|
|
200
315
|
the change to be reported to the PC. This is used to prevent reporting repeated static torque readouts to the
|
|
201
316
|
PC, conserving communication bandwidth."""
|
|
202
|
-
torque_averaging_pool_size: int =
|
|
203
|
-
"""The number of torque sensor readouts to average together to produce the final torque sensor readout value.
|
|
317
|
+
torque_averaging_pool_size: int = 1
|
|
318
|
+
"""The number of torque sensor readouts to average together to produce the final torque sensor readout value. Note,
|
|
319
|
+
when using a Teensy controller, this number is multiplied by the built-in analog readout averaging (default is 4).
|
|
320
|
+
"""
|
|
204
321
|
wheel_encoder_ppr: int = 8192
|
|
205
322
|
"""The resolution of the managed quadrature encoder, in Pulses Per Revolution (PPR). This is the number of
|
|
206
323
|
quadrature pulses the encoder emits per full 360-degree rotation."""
|
|
@@ -230,10 +347,10 @@ class MesoscopeMicroControllers:
|
|
|
230
347
|
encoder uses a dedicated parameter, as the encoder needs to be sampled at a higher frequency than all other sensors.
|
|
231
348
|
"""
|
|
232
349
|
valve_calibration_data: dict[int | float, int | float] | tuple[tuple[int | float, int | float], ...] = (
|
|
233
|
-
(15000, 1.
|
|
234
|
-
(30000, 3.
|
|
235
|
-
(45000,
|
|
236
|
-
(60000,
|
|
350
|
+
(15000, 1.10),
|
|
351
|
+
(30000, 3.00),
|
|
352
|
+
(45000, 6.25),
|
|
353
|
+
(60000, 10.90),
|
|
237
354
|
)
|
|
238
355
|
"""A tuple of tuples that maps water delivery solenoid valve open times, in microseconds, to the dispensed volume
|
|
239
356
|
of water, in microliters. During training and experiment runtimes, this data is used by the ValveModule to translate
|
|
@@ -278,6 +395,8 @@ class MesoscopeSystemConfiguration(YamlConfig):
|
|
|
278
395
|
"""Stores the descriptive name of the data acquisition system."""
|
|
279
396
|
paths: MesoscopePaths = field(default_factory=MesoscopePaths)
|
|
280
397
|
"""Stores the filesystem configuration parameters for the Mesoscope-VR data acquisition system."""
|
|
398
|
+
sheets: MesoscopeSheets = field(default_factory=MesoscopeSheets)
|
|
399
|
+
"""Stores the IDs of Google Sheets used by the Mesoscope-VR data acquisition system."""
|
|
281
400
|
cameras: MesoscopeCameras = field(default_factory=MesoscopeCameras)
|
|
282
401
|
"""Stores the configuration parameters for the cameras used by the Mesoscope-VR system to record behavior videos."""
|
|
283
402
|
microcontrollers: MesoscopeMicroControllers = field(default_factory=MesoscopeMicroControllers)
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
1
2
|
from pathlib import Path
|
|
2
3
|
from dataclasses import field, dataclass
|
|
3
4
|
|
|
4
5
|
from _typeshed import Incomplete
|
|
5
6
|
from ataraxis_data_structures import YamlConfig
|
|
6
7
|
|
|
8
|
+
class AcquisitionSystems(StrEnum):
|
|
9
|
+
"""Defines the set of data acquisition systems used in the Sun lab and supported by all data-related libraries."""
|
|
10
|
+
|
|
11
|
+
MESOSCOPE_VR = "mesoscope-vr"
|
|
12
|
+
|
|
7
13
|
@dataclass()
|
|
8
14
|
class ExperimentState:
|
|
9
15
|
"""Encapsulates the information used to set and maintain the desired experiment and system state.
|
|
10
16
|
|
|
11
|
-
Broadly, each experiment runtime can be conceptualized as a two state-system. The first
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
'what the hardware is doing'.
|
|
17
|
+
Broadly, each experiment runtime can be conceptualized as a two state-system. The first is the experiment task,
|
|
18
|
+
which reflects the behavior goal, the rules for achieving the goal, and the reward for achieving the goal. The
|
|
19
|
+
second is the data acquisition system state, which is a snapshot of all hardware module states that make up the
|
|
20
|
+
system that acquires the data and controls the task environment. Overall, experiment state is about
|
|
21
|
+
'what the animal is doing', while the system state is about 'what the hardware is doing'.
|
|
17
22
|
|
|
18
23
|
Note:
|
|
19
24
|
This class is acquisition-system-agnostic. It can be used to define the ExperimentConfiguration class for any
|
|
@@ -23,16 +28,37 @@ class ExperimentState:
|
|
|
23
28
|
experiment_state_code: int
|
|
24
29
|
system_state_code: int
|
|
25
30
|
state_duration_s: float
|
|
31
|
+
initial_guided_trials: int
|
|
32
|
+
recovery_failed_trial_threshold: int
|
|
33
|
+
recovery_guided_trials: int
|
|
34
|
+
|
|
35
|
+
@dataclass()
|
|
36
|
+
class ExperimentTrial:
|
|
37
|
+
"""Encapsulates information about a single experiment trial.
|
|
38
|
+
|
|
39
|
+
All Virtual Reality tasks can be broadly conceptualized as repeating motifs (sequences) of wall cues,
|
|
40
|
+
associated with a specific goal, for which animals receive water rewards. Since some experiments can use multiple
|
|
41
|
+
trial types as part of the same experiment session, multiple instances of this class can be used to specify
|
|
42
|
+
supported trial structures and trial parameters for a given experiment.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
cue_sequence: list[int]
|
|
46
|
+
trial_length_cm: float
|
|
47
|
+
trial_reward_size_ul: float
|
|
48
|
+
reward_zone_start_cm: float
|
|
49
|
+
reward_zone_end_cm: float
|
|
50
|
+
guidance_trigger_location_cm: float
|
|
26
51
|
|
|
27
52
|
@dataclass()
|
|
28
53
|
class MesoscopeExperimentConfiguration(YamlConfig):
|
|
29
54
|
"""Stores the configuration of a single experiment runtime that uses the Mesoscope_VR data acquisition system.
|
|
30
55
|
|
|
31
56
|
Primarily, this includes the sequence of experiment and system states that defines the flow of the experiment
|
|
32
|
-
runtime
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
57
|
+
runtime and the configuration of various trials supported by the experiment runtime. During runtime, the main
|
|
58
|
+
runtime control function traverses the sequence of states stored in this class instance start-to-end in the exact
|
|
59
|
+
order specified by the user. Together with custom Unity projects that define the task logic (how the system
|
|
60
|
+
responds to animal interactions with the VR system) this class allows flexibly implementing a wide range of
|
|
61
|
+
experiments using the Mesoscope-VR system.
|
|
36
62
|
|
|
37
63
|
Each project should define one or more experiment configurations and save them as .yaml files inside the project
|
|
38
64
|
'configuration' folder. The name for each configuration file is defined by the user and is used to identify and load
|
|
@@ -41,10 +67,15 @@ class MesoscopeExperimentConfiguration(YamlConfig):
|
|
|
41
67
|
Notes:
|
|
42
68
|
This class is designed exclusively for the Mesoscope-VR system. Any other system needs to define a separate
|
|
43
69
|
ExperimentConfiguration class to specify its experiment runtimes and additional data.
|
|
70
|
+
|
|
71
|
+
To create a new experiment configuration, use the 'sl-create-experiment' CLI command.
|
|
44
72
|
"""
|
|
45
73
|
|
|
46
74
|
cue_map: dict[int, float] = field(default_factory=Incomplete)
|
|
75
|
+
cue_offset_cm: float = ...
|
|
76
|
+
unity_scene_name: str = ...
|
|
47
77
|
experiment_states: dict[str, ExperimentState] = field(default_factory=Incomplete)
|
|
78
|
+
trial_structures: dict[str, ExperimentTrial] = field(default_factory=Incomplete)
|
|
48
79
|
|
|
49
80
|
@dataclass()
|
|
50
81
|
class MesoscopePaths:
|
|
@@ -59,6 +90,13 @@ class MesoscopePaths:
|
|
|
59
90
|
mesoscope_directory: Path = ...
|
|
60
91
|
harvesters_cti_path: Path = ...
|
|
61
92
|
|
|
93
|
+
@dataclass()
|
|
94
|
+
class MesoscopeSheets:
|
|
95
|
+
"""Stores the IDs of Google Sheets used by the Mesoscope-VR data acquisition system."""
|
|
96
|
+
|
|
97
|
+
surgery_sheet_id: str = ...
|
|
98
|
+
water_log_sheet_id: str = ...
|
|
99
|
+
|
|
62
100
|
@dataclass()
|
|
63
101
|
class MesoscopeCameras:
|
|
64
102
|
"""Stores the configuration parameters for the cameras used by the Mesoscope-VR system to record behavior videos."""
|
|
@@ -79,7 +117,6 @@ class MesoscopeMicroControllers:
|
|
|
79
117
|
sensor_port: str = ...
|
|
80
118
|
encoder_port: str = ...
|
|
81
119
|
debug: bool = ...
|
|
82
|
-
mesoscope_ttl_pulse_duration_ms: int = ...
|
|
83
120
|
minimum_break_strength_g_cm: float = ...
|
|
84
121
|
maximum_break_strength_g_cm: float = ...
|
|
85
122
|
wheel_diameter_cm: float = ...
|
|
@@ -136,6 +173,7 @@ class MesoscopeSystemConfiguration(YamlConfig):
|
|
|
136
173
|
|
|
137
174
|
name: str = ...
|
|
138
175
|
paths: MesoscopePaths = field(default_factory=MesoscopePaths)
|
|
176
|
+
sheets: MesoscopeSheets = field(default_factory=MesoscopeSheets)
|
|
139
177
|
cameras: MesoscopeCameras = field(default_factory=MesoscopeCameras)
|
|
140
178
|
microcontrollers: MesoscopeMicroControllers = field(default_factory=MesoscopeMicroControllers)
|
|
141
179
|
additional_firmware: MesoscopeAdditionalFirmware = field(default_factory=MesoscopeAdditionalFirmware)
|