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.

Files changed (32) hide show
  1. sl_shared_assets/__init__.py +17 -9
  2. sl_shared_assets/__init__.pyi +12 -8
  3. sl_shared_assets/cli.py +258 -21
  4. sl_shared_assets/cli.pyi +44 -5
  5. sl_shared_assets/data_classes/__init__.py +8 -3
  6. sl_shared_assets/data_classes/__init__.pyi +8 -4
  7. sl_shared_assets/data_classes/configuration_data.py +149 -30
  8. sl_shared_assets/data_classes/configuration_data.pyi +49 -11
  9. sl_shared_assets/data_classes/runtime_data.py +70 -49
  10. sl_shared_assets/data_classes/runtime_data.pyi +41 -33
  11. sl_shared_assets/data_classes/session_data.py +193 -253
  12. sl_shared_assets/data_classes/session_data.pyi +99 -116
  13. sl_shared_assets/data_classes/surgery_data.py +1 -1
  14. sl_shared_assets/server/__init__.py +2 -2
  15. sl_shared_assets/server/__init__.pyi +5 -2
  16. sl_shared_assets/server/job.py +229 -1
  17. sl_shared_assets/server/job.pyi +111 -0
  18. sl_shared_assets/server/server.py +431 -31
  19. sl_shared_assets/server/server.pyi +158 -15
  20. sl_shared_assets/tools/__init__.py +2 -1
  21. sl_shared_assets/tools/__init__.pyi +2 -0
  22. sl_shared_assets/tools/ascension_tools.py +9 -21
  23. sl_shared_assets/tools/ascension_tools.pyi +1 -1
  24. sl_shared_assets/tools/packaging_tools.py +2 -2
  25. sl_shared_assets/tools/project_management_tools.py +147 -41
  26. sl_shared_assets/tools/project_management_tools.pyi +45 -6
  27. {sl_shared_assets-2.0.1.dist-info → sl_shared_assets-3.0.0.dist-info}/METADATA +127 -13
  28. sl_shared_assets-3.0.0.dist-info/RECORD +36 -0
  29. {sl_shared_assets-2.0.1.dist-info → sl_shared_assets-3.0.0.dist-info}/entry_points.txt +2 -0
  30. sl_shared_assets-2.0.1.dist-info/RECORD +0 -36
  31. {sl_shared_assets-2.0.1.dist-info → sl_shared_assets-3.0.0.dist-info}/WHEEL +0 -0
  32. {sl_shared_assets-2.0.1.dist-info → sl_shared_assets-3.0.0.dist-info}/licenses/LICENSE +0 -0
@@ -19,15 +19,15 @@ class MesoscopeHardwareState(YamlConfig):
19
19
 
20
20
  Notes:
21
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.
22
+ session runtime. This is in contrast to MesoscopeExperimentConfiguration class, which reflects the 'dynamic'
23
+ state of the Mesoscope-VR system during each experiment.
24
24
 
25
25
  This class partially overlaps with the MesoscopeSystemConfiguration class, which is also stored in the
26
26
  raw_data folder of each session. The primary reason to keep both classes is to ensure that the math (rounding)
27
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.
28
+ not do any rounding or otherwise attempt to be repeatable, which is in contrast to hardware modules that read
29
+ and apply those parameters. Reading values from this class guarantees the read value exactly matches the value
30
+ used during runtime.
31
31
 
32
32
  Notes:
33
33
  All fields in this dataclass initialize to None. During log processing, any log associated with a hardware
@@ -35,17 +35,14 @@ class MesoscopeHardwareState(YamlConfig):
35
35
  any field in this dataclass to None also functions as a flag for whether to parse the log associated with the
36
36
  module that provides this field's information.
37
37
 
38
- This class is automatically configured by _MesoscopeExperiment and _BehaviorTraining classes from sl-experiment
39
- library to facilitate log parsing.
38
+ This class is automatically configured by _MesoscopeVRSystem class from sl-experiment library to facilitate
39
+ proper log parsing.
40
40
  """
41
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
42
  cm_per_pulse: float | None = None
47
43
  """EncoderInterface instance property. Stores the conversion factor used to translate encoder pulses into
48
- real-world centimeters."""
44
+ real-world centimeters. This conversion factor is fixed for each data acquisition system and does not change
45
+ between experiments."""
49
46
  maximum_break_strength: float | None = None
50
47
  """BreakInterface instance property. Stores the breaking torque, in Newton centimeters, applied by the break to
51
48
  the edge of the running wheel when it is engaged at 100% strength."""
@@ -75,7 +72,11 @@ class MesoscopeHardwareState(YamlConfig):
75
72
  the session runtime."""
76
73
  recorded_mesoscope_ttl: bool | None = None
77
74
  """TTLInterface instance property. A boolean flag that determines whether the processed session recorded brain
78
- activity data with the mesoscope."""
75
+ activity data with the mesoscope. In that case, attempts to parse the Mesoscope frame scanning TTL pulse data to
76
+ synchronize Mesoscope data to behavior data."""
77
+ system_state_codes: dict[str, int] | None = None
78
+ """A _MesoscopeVRSystem instance property. A dictionary that maps integer state-codes used by the Mesoscope-VR
79
+ system to communicate its states (system states) to human-readable state names."""
79
80
 
80
81
 
81
82
  @dataclass()
@@ -87,8 +88,9 @@ class LickTrainingDescriptor(YamlConfig):
87
88
  mouse_weight_g: float
88
89
  """The weight of the animal, in grams, at the beginning of the session."""
89
90
  dispensed_water_volume_ml: float
90
- """Stores the total water volume, in milliliters, dispensed during runtime."""
91
- minimum_reward_delay: int
91
+ """Stores the total water volume, in milliliters, dispensed during runtime. This excludes the water volume
92
+ dispensed during the paused (idle) state."""
93
+ minimum_reward_delay_s: int
92
94
  """Stores the minimum delay, in seconds, that can separate the delivery of two consecutive water rewards."""
93
95
  maximum_reward_delay_s: int
94
96
  """Stores the maximum delay, in seconds, that can separate the delivery of two consecutive water rewards."""
@@ -100,6 +102,8 @@ class LickTrainingDescriptor(YamlConfig):
100
102
  """Stores the maximum number of consecutive rewards that can be delivered without the animal consuming them. If
101
103
  the animal receives this many rewards without licking (consuming) them, reward delivery is paused until the animal
102
104
  consumes the rewards."""
105
+ pause_dispensed_water_volume_ml: float = 0.0
106
+ """Stores the total water volume, in milliliters, dispensed during the paused (idle) state."""
103
107
  experimenter_notes: str = "Replace this with your notes."
104
108
  """This field is not set during runtime. It is expected that each experimenter replaces this field with their
105
109
  notes made during runtime."""
@@ -150,6 +154,8 @@ class RunTrainingDescriptor(YamlConfig):
150
154
  """Stores the maximum time, in seconds, the animal can dip below the running speed threshold to still receive the
151
155
  reward. This allows animals that 'run' by taking a series of large steps, briefly dipping below speed threshold at
152
156
  the end of each step, to still get water rewards."""
157
+ pause_dispensed_water_volume_ml: float = 0.0
158
+ """Stores the total water volume, in milliliters, dispensed during the paused (idle) state."""
153
159
  experimenter_notes: str = "Replace this with your notes."
154
160
  """This field is not set during runtime. It is expected that each experimenter will replace this field with their
155
161
  notes made during runtime."""
@@ -178,6 +184,8 @@ class MesoscopeExperimentDescriptor(YamlConfig):
178
184
  experimenter_notes: str = "Replace this with your notes."
179
185
  """This field is not set during runtime. It is expected that each experimenter will replace this field with their
180
186
  notes made during runtime."""
187
+ pause_dispensed_water_volume_ml: float = 0.0
188
+ """Stores the total water volume, in milliliters, dispensed during the paused (idle) state."""
181
189
  experimenter_given_water_volume_ml: float = 0.0
182
190
  """The additional volume of water, in milliliters, administered by the experimenter to the animal after the session.
183
191
  """
@@ -186,26 +194,40 @@ class MesoscopeExperimentDescriptor(YamlConfig):
186
194
  Sun lab automated processing and analysis."""
187
195
 
188
196
 
197
+ @dataclass()
198
+ class WindowCheckingDescriptor(YamlConfig):
199
+ """Stores the outcome information specific to window checking sessions that use the Mesoscope-VR system.
200
+
201
+ Notes:
202
+ Window Checking sessions are different from all other sessions. Unlike other sessions, their purpose is not to
203
+ generate data, but rather to assess the suitability of the particular animal to be included in training and
204
+ experiment cohorts. These sessions are automatically excluded from any automated data processing and analysis.
205
+ """
206
+
207
+ experimenter: str
208
+ """The ID of the experimenter running the session."""
209
+ experimenter_notes: str = "Replace this with your notes."
210
+ """The notes on the quality of the cranial window and animal's suitability for the target project."""
211
+ surgery_quality: int = 0
212
+ """The quality of the cranial window and surgical intervention on a scale from 0 (non-usable) to
213
+ 3 (high-tier publication grade) inclusive."""
214
+ incomplete: bool = True
215
+ """Window checking sessions are always considered 'incomplete', as they do not contain the full range of
216
+ information collected as part of a 'standard' behavior training or experiment session."""
217
+
218
+
189
219
  @dataclass()
190
220
  class ZaberPositions(YamlConfig):
191
221
  """Stores Zaber motor positions reused between experiment sessions that use the Mesoscope-VR system.
192
222
 
193
- The class is specifically designed to store, save, and load the positions of the LickPort and HeadBar motors
194
- (axes). It is used to both store Zaber motor positions for each session for future analysis and to restore the same
195
- Zaber motor positions across consecutive runtimes for the same project and animal combination.
223
+ The class is specifically designed to store, save, and load the positions of the LickPort, HeadBar, and Wheel motors
224
+ (axes). It is used to both store Zaber motor positions for each session for future analysis and to restore the
225
+ Zaber motors to the same positions across consecutive runtimes for the same project and animal combination.
196
226
 
197
227
  Notes:
198
- The HeadBar axis (connection) also manages the motor that moves the running wheel along the x-axis. While the
199
- motor itself is not part of the HeadBar assembly, it is related to positioning the mouse in the VR system. This
200
- is in contrast to the LickPort group, which is related to positioning the lick tube relative to the mouse.
201
-
202
- All positions are saved using native motor units. All class fields initialize to default placeholders that are
203
- likely NOT safe to apply to the VR system. Do not apply the positions loaded from the file unless you are
204
- certain they are safe to use.
205
-
206
- Exercise caution when working with Zaber motors. The motors are powerful enough to damage the surrounding
207
- equipment and manipulated objects. Do not modify the data stored inside the .yaml file unless you know what you
208
- are doing.
228
+ By default, the class initializes all fields to 0, which is the position of the home sensor for each motor. The
229
+ class assumes that the motor groups are assembled and arranged in a way that ensures all motors can safely move
230
+ to the home sensor positions from any runtime configuration.
209
231
  """
210
232
 
211
233
  headbar_z: int = 0
@@ -214,42 +236,41 @@ class ZaberPositions(YamlConfig):
214
236
  """The absolute position, in native motor units, of the HeadBar pitch-axis motor."""
215
237
  headbar_roll: int = 0
216
238
  """The absolute position, in native motor units, of the HeadBar roll-axis motor."""
217
- wheel_x: int = 0
218
- """The absolute position, in native motor units, of the running wheel platform x-axis motor. Although this motor is
219
- not itself part of the HeadBar assembly, it is controlled through the HeadBar controller port."""
220
239
  lickport_z: int = 0
221
240
  """The absolute position, in native motor units, of the LickPort z-axis motor."""
222
- lickport_x: int = 0
223
- """The absolute position, in native motor units, of the LickPort x-axis motor."""
224
241
  lickport_y: int = 0
225
242
  """The absolute position, in native motor units, of the LickPort y-axis motor."""
243
+ lickport_x: int = 0
244
+ """The absolute position, in native motor units, of the LickPort x-axis motor."""
245
+ wheel_x: int = 0
246
+ """The absolute position, in native motor units, of the running wheel platform x-axis motor."""
226
247
 
227
248
 
228
249
  @dataclass()
229
250
  class MesoscopePositions(YamlConfig):
230
- """Stores real and virtual Mesoscope objective positions reused between experiment sessions that use the
251
+ """Stores the positions of real and virtual Mesoscope objective axes reused between experiment sessions that use the
231
252
  Mesoscope-VR system.
232
253
 
233
- Primarily, the class is used to help the experimenter to position the Mesoscope at the same position across
234
- multiple imaging sessions. It stores both the physical (real) position of the objective along the motorized
235
- X, Y, Z, and Roll axes and the virtual (ScanImage software) tip, tilt, and fastZ focus axes.
236
-
237
- Notes:
238
- Since the API to read and write these positions automatically is currently not available, this class relies on
239
- the experimenter manually entering all positions and setting the mesoscope to these positions when necessary.
254
+ This class is designed to help the experimenter move the Mesoscope to the same imaging plane across imaging
255
+ sessions. It stores both the physical (real) position of the objective along the motorized X, Y, Z, and Roll axes,
256
+ and the virtual (ScanImage software) tip, tilt, and fastZ (virtual zoom) axes.
240
257
  """
241
258
 
242
259
  mesoscope_x: float = 0.0
243
- """The X-axis position, in centimeters, of the Mesoscope objective used during session runtime."""
260
+ """The Mesoscope objective X-axis position, in micrometers."""
244
261
  mesoscope_y: float = 0.0
245
- """The Y-axis position, in centimeters, of the Mesoscope objective used during session runtime."""
262
+ """The Mesoscope objective Y-axis position, in micrometers."""
246
263
  mesoscope_roll: float = 0.0
247
- """The Roll-axis position, in degrees, of the Mesoscope objective used during session runtime."""
264
+ """The Mesoscope objective Roll-axis position, in degrees."""
248
265
  mesoscope_z: float = 0.0
249
- """The Z-axis position, in centimeters, of the Mesoscope objective used during session runtime."""
266
+ """The Mesoscope objective Z-axis position, in micrometers."""
250
267
  mesoscope_fast_z: float = 0.0
251
- """The Fast-Z-axis position, in micrometers, of the Mesoscope objective used during session runtime."""
268
+ """The ScanImage FastZ (virtual Z-axis) position, in micrometers."""
252
269
  mesoscope_tip: float = 0.0
253
- """The Tilt-axis position, in degrees, of the Mesoscope objective used during session runtime."""
270
+ """The ScanImage Tilt position, in degrees.."""
254
271
  mesoscope_tilt: float = 0.0
255
- """The Tip-axis position, in degrees, of the Mesoscope objective used during session runtime."""
272
+ """The ScanImage Tip position, in degrees."""
273
+ laser_power_mw: float = 0.0
274
+ """The laser excitation power at the sample, in milliwatts."""
275
+ red_dot_alignment_z: float = 0.0
276
+ """The Mesoscope objective Z-axis position, in micrometers, used for red-dot alignment procedure."""
@@ -12,15 +12,15 @@ class MesoscopeHardwareState(YamlConfig):
12
12
 
13
13
  Notes:
14
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.
15
+ session runtime. This is in contrast to MesoscopeExperimentConfiguration class, which reflects the 'dynamic'
16
+ state of the Mesoscope-VR system during each experiment.
17
17
 
18
18
  This class partially overlaps with the MesoscopeSystemConfiguration class, which is also stored in the
19
19
  raw_data folder of each session. The primary reason to keep both classes is to ensure that the math (rounding)
20
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.
21
+ not do any rounding or otherwise attempt to be repeatable, which is in contrast to hardware modules that read
22
+ and apply those parameters. Reading values from this class guarantees the read value exactly matches the value
23
+ used during runtime.
24
24
 
25
25
  Notes:
26
26
  All fields in this dataclass initialize to None. During log processing, any log associated with a hardware
@@ -28,11 +28,10 @@ class MesoscopeHardwareState(YamlConfig):
28
28
  any field in this dataclass to None also functions as a flag for whether to parse the log associated with the
29
29
  module that provides this field's information.
30
30
 
31
- This class is automatically configured by _MesoscopeExperiment and _BehaviorTraining classes from sl-experiment
32
- library to facilitate log parsing.
31
+ This class is automatically configured by _MesoscopeVRSystem class from sl-experiment library to facilitate
32
+ proper log parsing.
33
33
  """
34
34
 
35
- cue_map: dict[int, float] | None = ...
36
35
  cm_per_pulse: float | None = ...
37
36
  maximum_break_strength: float | None = ...
38
37
  minimum_break_strength: float | None = ...
@@ -42,6 +41,7 @@ class MesoscopeHardwareState(YamlConfig):
42
41
  torque_per_adc_unit: float | None = ...
43
42
  screens_initially_on: bool | None = ...
44
43
  recorded_mesoscope_ttl: bool | None = ...
44
+ system_state_codes: dict[str, int] | None = ...
45
45
 
46
46
  @dataclass()
47
47
  class LickTrainingDescriptor(YamlConfig):
@@ -50,11 +50,12 @@ class LickTrainingDescriptor(YamlConfig):
50
50
  experimenter: str
51
51
  mouse_weight_g: float
52
52
  dispensed_water_volume_ml: float
53
- minimum_reward_delay: int
53
+ minimum_reward_delay_s: int
54
54
  maximum_reward_delay_s: int
55
55
  maximum_water_volume_ml: float
56
56
  maximum_training_time_m: int
57
57
  maximum_unconsumed_rewards: int = ...
58
+ pause_dispensed_water_volume_ml: float = ...
58
59
  experimenter_notes: str = ...
59
60
  experimenter_given_water_volume_ml: float = ...
60
61
  incomplete: bool = ...
@@ -77,6 +78,7 @@ class RunTrainingDescriptor(YamlConfig):
77
78
  maximum_training_time_m: int
78
79
  maximum_unconsumed_rewards: int = ...
79
80
  maximum_idle_time_s: float = ...
81
+ pause_dispensed_water_volume_ml: float = ...
80
82
  experimenter_notes: str = ...
81
83
  experimenter_given_water_volume_ml: float = ...
82
84
  incomplete: bool = ...
@@ -90,51 +92,55 @@ class MesoscopeExperimentDescriptor(YamlConfig):
90
92
  dispensed_water_volume_ml: float
91
93
  maximum_unconsumed_rewards: int = ...
92
94
  experimenter_notes: str = ...
95
+ pause_dispensed_water_volume_ml: float = ...
93
96
  experimenter_given_water_volume_ml: float = ...
94
97
  incomplete: bool = ...
95
98
 
99
+ @dataclass()
100
+ class WindowCheckingDescriptor(YamlConfig):
101
+ """Stores the outcome information specific to window checking sessions that use the Mesoscope-VR system.
102
+
103
+ Notes:
104
+ Window Checking sessions are different from all other sessions. Unlike other sessions, their purpose is not to
105
+ generate data, but rather to assess the suitability of the particular animal to be included in training and
106
+ experiment cohorts. These sessions are automatically excluded from any automated data processing and analysis.
107
+ """
108
+
109
+ experimenter: str
110
+ experimenter_notes: str = ...
111
+ surgery_quality: int = ...
112
+ incomplete: bool = ...
113
+
96
114
  @dataclass()
97
115
  class ZaberPositions(YamlConfig):
98
116
  """Stores Zaber motor positions reused between experiment sessions that use the Mesoscope-VR system.
99
117
 
100
- The class is specifically designed to store, save, and load the positions of the LickPort and HeadBar motors
101
- (axes). It is used to both store Zaber motor positions for each session for future analysis and to restore the same
102
- Zaber motor positions across consecutive runtimes for the same project and animal combination.
118
+ The class is specifically designed to store, save, and load the positions of the LickPort, HeadBar, and Wheel motors
119
+ (axes). It is used to both store Zaber motor positions for each session for future analysis and to restore the
120
+ Zaber motors to the same positions across consecutive runtimes for the same project and animal combination.
103
121
 
104
122
  Notes:
105
- The HeadBar axis (connection) also manages the motor that moves the running wheel along the x-axis. While the
106
- motor itself is not part of the HeadBar assembly, it is related to positioning the mouse in the VR system. This
107
- is in contrast to the LickPort group, which is related to positioning the lick tube relative to the mouse.
108
-
109
- All positions are saved using native motor units. All class fields initialize to default placeholders that are
110
- likely NOT safe to apply to the VR system. Do not apply the positions loaded from the file unless you are
111
- certain they are safe to use.
112
-
113
- Exercise caution when working with Zaber motors. The motors are powerful enough to damage the surrounding
114
- equipment and manipulated objects. Do not modify the data stored inside the .yaml file unless you know what you
115
- are doing.
123
+ By default, the class initializes all fields to 0, which is the position of the home sensor for each motor. The
124
+ class assumes that the motor groups are assembled and arranged in a way that ensures all motors can safely move
125
+ to the home sensor positions from any runtime configuration.
116
126
  """
117
127
 
118
128
  headbar_z: int = ...
119
129
  headbar_pitch: int = ...
120
130
  headbar_roll: int = ...
121
- wheel_x: int = ...
122
131
  lickport_z: int = ...
123
- lickport_x: int = ...
124
132
  lickport_y: int = ...
133
+ lickport_x: int = ...
134
+ wheel_x: int = ...
125
135
 
126
136
  @dataclass()
127
137
  class MesoscopePositions(YamlConfig):
128
- """Stores real and virtual Mesoscope objective positions reused between experiment sessions that use the
138
+ """Stores the positions of real and virtual Mesoscope objective axes reused between experiment sessions that use the
129
139
  Mesoscope-VR system.
130
140
 
131
- Primarily, the class is used to help the experimenter to position the Mesoscope at the same position across
132
- multiple imaging sessions. It stores both the physical (real) position of the objective along the motorized
133
- X, Y, Z, and Roll axes and the virtual (ScanImage software) tip, tilt, and fastZ focus axes.
134
-
135
- Notes:
136
- Since the API to read and write these positions automatically is currently not available, this class relies on
137
- the experimenter manually entering all positions and setting the mesoscope to these positions when necessary.
141
+ This class is designed to help the experimenter move the Mesoscope to the same imaging plane across imaging
142
+ sessions. It stores both the physical (real) position of the objective along the motorized X, Y, Z, and Roll axes,
143
+ and the virtual (ScanImage software) tip, tilt, and fastZ (virtual zoom) axes.
138
144
  """
139
145
 
140
146
  mesoscope_x: float = ...
@@ -144,3 +150,5 @@ class MesoscopePositions(YamlConfig):
144
150
  mesoscope_fast_z: float = ...
145
151
  mesoscope_tip: float = ...
146
152
  mesoscope_tilt: float = ...
153
+ laser_power_mw: float = ...
154
+ red_dot_alignment_z: float = ...