sl-shared-assets 1.0.0rc8__py3-none-any.whl → 1.0.0rc10__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.

@@ -1,667 +0,0 @@
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
- def replace_root_path(path: Path) -> None:
8
- """Replaces the path to the local root directory used to store all Sun lab projects with the provided path.
9
-
10
- When ProjectConfiguration class is instantiated for the first time on a new machine, it asks the user to provide
11
- the path to the local directory where to save all Sun lab projects. This path is then stored inside the default
12
- user data directory as a .yaml file to be reused for all future projects. To support replacing this path without
13
- searching for the user data directory, which is usually hidden, this function finds and updates the contents of the
14
- file that stores the local root path.
15
-
16
- Args:
17
- path: The path to the new local root directory.
18
- """
19
- @dataclass()
20
- class ProjectConfiguration(YamlConfig):
21
- """Stores the project-specific configuration parameters that do not change between different animals and runtime
22
- sessions.
23
-
24
- An instance of this class is generated and saved as a .yaml file in the \'configuration\' directory of each project
25
- when it is created. After that, the stored data is reused for every runtime (training or experiment session) carried
26
- out for each animal of the project.
27
-
28
- Notes:
29
- This class allows flexibly configuring sl_experiment and sl_forgery libraries for different projects in the
30
- Sun lab. This allows hiding most inner workings of all libraries from the end-users, while providing a robust,
31
- machine-independent way to interface with all data acquisition and processing libraries.
32
-
33
- Most lab projects only need to adjust the "surgery_sheet_id" and "water_log_sheet_id" fields of the class.
34
- """
35
-
36
- project_name: str = ...
37
- surgery_sheet_id: str = ...
38
- water_log_sheet_id: str = ...
39
- google_credentials_path: str | Path = ...
40
- server_credentials_path: str | Path = ...
41
- local_root_directory: str | Path = ...
42
- local_server_directory: str | Path = ...
43
- local_nas_directory: str | Path = ...
44
- local_mesoscope_directory: str | Path = ...
45
- remote_storage_directory: str | Path = ...
46
- remote_working_directory: str | Path = ...
47
- face_camera_index: int = ...
48
- left_camera_index: int = ...
49
- right_camera_index: int = ...
50
- harvesters_cti_path: str | Path = ...
51
- actor_port: str = ...
52
- sensor_port: str = ...
53
- encoder_port: str = ...
54
- headbar_port: str = ...
55
- lickport_port: str = ...
56
- unity_ip: str = ...
57
- unity_port: int = ...
58
- valve_calibration_data: dict[int | float, int | float] | tuple[tuple[int | float, int | float], ...] = ...
59
- @classmethod
60
- def load(cls, project_name: str, configuration_path: None | Path = None) -> ProjectConfiguration:
61
- """Loads the project configuration parameters from a project_configuration.yaml file and uses the loaded data
62
- to initialize the ProjectConfiguration instance.
63
-
64
- This method is called for each session runtime to reuse the configuration parameters generated at project
65
- creation. When it is called for the first time (during new project creation), the method generates the default
66
- configuration file and prompts the user to update the configuration before proceeding with the runtime.
67
-
68
- Notes:
69
- As part of its runtime, the method may prompt the user to provide the path to the local root directory.
70
- This directory stores all project subdirectories and acts as the top level of the local data hierarchy.
71
- The path to the directory will be saved inside user's default data directory, so that it can be reused for
72
- all future projects. Use sl-replace_root_path CLI to replace the path that is saved in this way.
73
-
74
- Since this class is used during both data acquisition and processing on different machines, this method
75
- supports multiple ways of initializing the class. Use the project_name on the VRPC (via the sl_experiment
76
- library). Use the configuration path on the BioHPC server (via the sl_forgery library).
77
-
78
- Args:
79
- project_name: The name of the project whose configuration file needs to be discovered and loaded. Note, this
80
- way of resolving the project is the default way on the VRPC. When processing data on the server, the
81
- pipeline preferentially uses the configuration_path.
82
- configuration_path: The path to the project_configuration.yaml file from which to load the data. This is
83
- an optional way of resolving the configuration data source that always takes precedence over the
84
- project_name when both are provided.
85
-
86
- Returns:
87
- An initialized ProjectConfiguration instance.
88
- """
89
- def _to_path(self, path: Path) -> None:
90
- """Saves the instance data to disk as a project_configuration.yaml file.
91
-
92
- This method is automatically called when the project is created. All future runtimes should use the load()
93
- method to load and reuse the configuration data saved to the .yaml file.
94
-
95
- Notes:
96
- This method also generates and dumps multiple other 'precursor' configuration files into the folder. This
97
- includes the example 'default' experiment configuration and the DeepLabCut and Suite2P configuration files
98
- used during data processing.
99
-
100
- Args:
101
- path: The path to the .yaml file to save the data to.
102
- """
103
- def _verify_data(self) -> None:
104
- """Verifies the data loaded from the project_configuration.yaml file to ensure its validity.
105
-
106
- Since this class is explicitly designed to be modified by the user, this verification step is carried out to
107
- ensure that the loaded data matches expectations. This reduces the potential for user errors to impact the
108
- runtime behavior of the library. This internal method is automatically called by the load() method.
109
-
110
- Notes:
111
- The method does not verify all fields loaded from the configuration file and instead focuses on fields that
112
- do not have valid default values. Since these fields are expected to be frequently modified by users, they
113
- are the ones that require additional validation.
114
-
115
- Raises:
116
- ValueError: If the loaded data does not match expected formats or values.
117
- """
118
-
119
- @dataclass()
120
- class RawData:
121
- """Stores the paths to the directories and files that make up the 'raw_data' session directory.
122
-
123
- The raw_data directory stores the data acquired during the session runtime before and after preprocessing. Since
124
- preprocessing does not alter the data, any data in that folder is considered 'raw'. The raw_data folder is initially
125
- created on the VRPC and, after preprocessing, is copied to the BioHPC server and the Synology NAS for long-term
126
- storage and further processing.
127
-
128
- Notes:
129
- The overall structure of the raw_data directory remains fixed for the entire lifetime of the data. It is reused
130
- across all destinations.
131
- """
132
-
133
- raw_data_path: str | Path
134
- camera_data_path: str | Path
135
- mesoscope_data_path: str | Path
136
- behavior_data_path: str | Path
137
- zaber_positions_path: str | Path
138
- session_descriptor_path: str | Path
139
- hardware_configuration_path: str | Path
140
- surgery_metadata_path: str | Path
141
- project_configuration_path: str | Path
142
- session_data_path: str | Path
143
- experiment_configuration_path: str | Path
144
- mesoscope_positions_path: str | Path
145
- window_screenshot_path: str | Path
146
- def __post_init__(self) -> None:
147
- """This method is automatically called after class instantiation and ensures that all path fields of the class
148
- are converted to Path objects.
149
- """
150
- def make_string(self) -> None:
151
- """Converts all Path objects stored inside the class to strings.
152
-
153
- This transformation is required to support dumping class data into a .YAML file so that the data can be stored
154
- on disk.
155
- """
156
- def make_dirs(self) -> None:
157
- """Ensures that all major subdirectories and the root raw_data directory exist.
158
-
159
- This method is used by the VRPC to generate the raw_data directory when it creates a new session.
160
- """
161
- def switch_root(self, new_root: Path) -> None:
162
- """Changes the root of the managed raw_data directory to the provided root path.
163
-
164
- This service method is used by the SessionData class to convert all paths in this class to be relative to the
165
- new root. This is used to adjust the SessionData instance to work for the VRPC (one root) or the BioHPC server
166
- (another root). This method is only implemented for subclasses intended to be used both locally and on the
167
- BioHPC server.
168
-
169
- Args:
170
- new_root: The new root directory to use for all paths inside the instance. This has to be the path to the
171
- root session directory: pc_root/project/animal/session.
172
- """
173
-
174
- @dataclass()
175
- class ProcessedData:
176
- """Stores the paths to the directories and files that make up the 'processed_data' session directory.
177
-
178
- The processed_data directory stores the processed session data, which is generated by running various processing
179
- pipelines. These pipelines use raw data to generate processed data, which represents an intermediate step between
180
- raw data and the dataset used in the data analysis.
181
-
182
- Notes:
183
- The paths from this section are typically used only on the BioHPC server. This is because most data processing
184
- in the lab is performed using the processing server's resources. On the server, processed data is stored on
185
- the fast volume, in contrast to raw data, which is stored on the slow volume. However, to support local testing,
186
- the class resolves the paths in this section both locally and globally (on the server).
187
-
188
- """
189
-
190
- processed_data_path: str | Path
191
- camera_data_path: str | Path
192
- mesoscope_data_path: str | Path
193
- behavior_data_path: str | Path
194
- deeplabcut_root_path: str | Path
195
- suite2p_configuration_path: str | Path
196
- def __post_init__(self) -> None:
197
- """This method is automatically called after class instantiation and ensures that all path fields of the class
198
- are converted to Path objects.
199
- """
200
- def make_string(self) -> None:
201
- """Converts all Path objects stored inside the class to strings.
202
-
203
- This transformation is required to support dumping class data into a .YAML file so that the data can be stored
204
- on disk.
205
- """
206
- def make_dirs(self) -> None:
207
- """Ensures that all major subdirectories of the processed_data directory exist.
208
-
209
- This method is used by the BioHPC server to generate the processed_data directory as part of the sl-forgery
210
- library runtime.
211
- """
212
- def switch_root(self, new_root: Path) -> None:
213
- """Changes the root of the managed processed_data directory to the provided root path.
214
-
215
- This service method is used by the SessionData class to convert all paths in this class to be relative to the
216
- new root. This is used to adjust the SessionData instance to work for the VRPC (one root) or the BioHPC server
217
- (another root). This method is only implemented for subclasses intended to be used both locally and on the
218
- BioHPC server.
219
-
220
- Args:
221
- new_root: The new root directory to use for all paths inside the instance. This has to be the path to the
222
- root session directory: pc_root/project/animal/session.
223
- """
224
-
225
- @dataclass()
226
- class PersistentData:
227
- """Stores the paths to the directories and files that make up the 'persistent_data' directories of the VRPC and
228
- the ScanImagePC.
229
-
230
- Persistent data directories are used to keep certain files on the VRPC and the ScanImagePC. Typically, this data
231
- is reused during the following sessions. For example, a copy of Zaber motor positions is persisted on the VRPC for
232
- each animal after every session to support automatically restoring Zaber motors to the positions used during the
233
- previous session.
234
-
235
- Notes:
236
- Persistent data includes the project and experiment configuration data. Some persistent data is overwritten
237
- after each session, other data is generated once and kept through the animal's lifetime. Primarily, this data is
238
- only used internally by the sl-experiment or sl-forgery libraries and is not intended for end-users.
239
- """
240
-
241
- zaber_positions_path: str | Path
242
- mesoscope_positions_path: str | Path
243
- motion_estimator_path: str | Path
244
- def __post_init__(self) -> None:
245
- """This method is automatically called after class instantiation and ensures that all path fields of the class
246
- are converted to Path objects.
247
- """
248
- def make_string(self) -> None:
249
- """Converts all Path objects stored inside the class to strings.
250
-
251
- This transformation is required to support dumping class data into a .YAML file so that the data can be stored
252
- on disk.
253
- """
254
- def make_dirs(self) -> None:
255
- """Ensures that the VRPC and the ScanImagePC persistent_data directories exist."""
256
-
257
- @dataclass()
258
- class MesoscopeData:
259
- """Stores the paths to the directories used by the ScanImagePC to save mesoscope-generated data during session
260
- runtime.
261
-
262
- The ScanImagePC is largely isolated from the VRPC during runtime. For the VRPC to pull the data acquired by the
263
- ScanImagePC, it has to use the predefined directory structure to save the data. This class stores the predefined
264
- path to various directories where ScanImagePC is expected to save the data and store it after acquisition.sers.
265
- """
266
-
267
- root_data_path: str | Path
268
- mesoscope_data_path: str | Path
269
- session_specific_mesoscope_data_path: str | Path
270
- def __post_init__(self) -> None:
271
- """This method is automatically called after class instantiation and ensures that all path fields of the class
272
- are converted to Path objects.
273
- """
274
- def make_string(self) -> None:
275
- """Converts all Path objects stored inside the class to strings.
276
-
277
- This transformation is required to support dumping class data into a .YAML file so that the data can be stored
278
- on disk.
279
- """
280
- def make_dirs(self) -> None:
281
- """Ensures that the ScanImagePC data acquisition directories exist."""
282
-
283
- @dataclass()
284
- class Destinations:
285
- """Stores the paths to the VRPC filesystem-mounted Synology NAS and BioHPC server directories.
286
-
287
- These directories are used during data preprocessing to transfer the preprocessed raw_data directory from the
288
- VRPC to the long-term storage destinations.
289
- """
290
-
291
- nas_raw_data_path: str | Path
292
- server_raw_data_path: str | Path
293
- def __post_init__(self) -> None:
294
- """This method is automatically called after class instantiation and ensures that all path fields of the class
295
- are converted to Path objects.
296
- """
297
- def make_string(self) -> None:
298
- """Converts all Path objects stored inside the class to strings.
299
-
300
- This transformation is required to support dumping class data into a .YAML file so that the data can be stored
301
- on disk.
302
- """
303
- def make_dirs(self) -> None:
304
- """Ensures that all destination directories exist."""
305
-
306
- @dataclass
307
- class SessionData(YamlConfig):
308
- """Provides methods for managing the data of a single experiment or training session across all destinations.
309
-
310
- The primary purpose of this class is to maintain the session data structure across all supported destinations. It
311
- generates the paths used by all other classes from this library and classes from sl-experiment and sl-forgery
312
- libraries.
313
-
314
- If necessary, the class can be used to either generate a new session or to load an already existing session's data.
315
- When the class is used to create a new session, it automatically resolves the new session's name using the current
316
- UTC timestamp, down to microseconds. This ensures that each session name is unique and preserves the overall
317
- session order.
318
-
319
- Notes:
320
- If this class is instantiated on the VRPC, it is expected that the BioHPC server, Synology NAS, and ScanImagePC
321
- data directories are mounted on the local host-machine via the SMB or equivalent protocol. All manipulations
322
- with these destinations are carried out with the assumption that the OS has full access to these directories
323
- and filesystems.
324
-
325
- If this class is instantiated on the BioHPC server, some methods from this class will not work as expected. It
326
- is essential that this class is not used outside the default sl-experiment and sl-forgery library runtimes to
327
- ensure it is used safely.
328
-
329
- This class is specifically designed for working with the data from a single session, performed by a single
330
- animal under the specific experiment. The class is used to manage both raw and processed data. It follows the
331
- data through acquisition, preprocessing and processing stages of the Sun lab data workflow.
332
- """
333
-
334
- project_name: str
335
- animal_id: str
336
- session_name: str
337
- session_type: str
338
- experiment_name: str | None
339
- raw_data: RawData
340
- processed_data: ProcessedData
341
- persistent_data: PersistentData
342
- mesoscope_data: MesoscopeData
343
- destinations: Destinations
344
- @classmethod
345
- def create_session(
346
- cls,
347
- animal_id: str,
348
- session_type: str,
349
- project_configuration: ProjectConfiguration,
350
- experiment_name: str | None = None,
351
- ) -> SessionData:
352
- """Creates a new SessionData object and uses it to generate the session's data structure.
353
-
354
- This method is used to initialize new session runtimes. It always assumes it is called on the VRPC and, as part
355
- of its runtime, resolves and generates the necessary local and ScanImagePC directories to support acquiring and
356
- preprocessing session's data.
357
-
358
- Notes:
359
- To load an already existing session data structure, use the load_session() method instead.
360
-
361
- This method automatically dumps the data of the created SessionData instance into the session_data.yaml file
362
- inside the root raw_data directory of the created hierarchy. It also finds and dumps other configuration
363
- files, such as project_configuration.yaml, suite2p_configuration.yaml, and experiment_configuration.yaml.
364
- This way, if the session's runtime is interrupted unexpectedly, it can still be processed.
365
-
366
- Args:
367
- animal_id: The ID code of the animal for which the data is acquired.
368
- session_type: The type of the session. Primarily, this determines how to read the session_descriptor.yaml
369
- file. Valid options are 'Lick training', 'Run training', or 'Experiment'.
370
- experiment_name: The name of the experiment to be executed as part of this session. This option is only used
371
- for 'Experiment' session types. It is used to find the target experiment configuration .YAML file and
372
- copy it into the session's raw_data directory.
373
- project_configuration: The initialized ProjectConfiguration instance that stores the data for the session's
374
- project. This is used to determine the root directory paths for all PCs used in the data workflow.
375
-
376
- Returns:
377
- An initialized SessionData instance for the newly created session.
378
- """
379
- @classmethod
380
- def load_session(cls, session_path: Path, on_server: bool) -> SessionData:
381
- """Loads the SessionData instance from the session_data.yaml file of the target session.
382
-
383
- This method is used to load the data for an already existing session. This is used to call preprocessing
384
- or processing runtime(s) for the target session. Depending on the call location, the method automatically
385
- resolves all necessary paths and creates the necessary directories.
386
-
387
- Notes:
388
- To create a new session, use the create_session() method instead.
389
-
390
- Args:
391
- session_path: The path to the root directory of an existing session, e.g.: vrpc_root/project/animal/session.
392
- on_server: Determines whether the method is used to initialize an existing session on the VRPC or the
393
- BioHPC server.
394
-
395
- Returns:
396
- An initialized SessionData instance for the session whose data is stored at the provided path.
397
-
398
- Raises:
399
- FileNotFoundError: If the 'session_data.yaml' file is not found after resolving the provided path.
400
- """
401
- def _to_path(self) -> None:
402
- """Saves the instance data to the 'raw_data' directory of the managed session as a 'session_data.yaml' file.
403
-
404
- This is used to save the data stored in the instance to disk, so that it can be reused during preprocessing or
405
- data processing. The method is intended to only be used by the SessionData instance itself during its
406
- create_session() method runtime.
407
- """
408
-
409
- @dataclass()
410
- class ExperimentState:
411
- """Encapsulates the information used to set and maintain the desired experiment and Mesoscope-VR system state.
412
-
413
- Primarily, experiment runtime logic (task logic) is resolved by the Unity game engine. However, the Mesoscope-VR
414
- system configuration may also need to change throughout the experiment to optimize the runtime by disabling or
415
- reconfiguring specific hardware modules. For example, some experiment stages may require the running wheel to be
416
- locked to prevent the animal from running, and other may require the VR screens to be turned off.
417
- """
418
-
419
- experiment_state_code: int
420
- vr_state_code: int
421
- state_duration_s: float
422
-
423
- @dataclass()
424
- class ExperimentConfiguration(YamlConfig):
425
- """Stores the configuration of a single experiment runtime.
426
-
427
- Primarily, this includes the sequence of experiment and Virtual Reality (Mesoscope-VR) states that defines the flow
428
- of the experiment runtime. During runtime, the main runtime control function traverses the sequence of states
429
- stored in this class instance start-to-end in the exact order specified by the user. Together with custom Unity
430
- projects that define the task logic (how the system responds to animal interactions with the VR system) this class
431
- allows flexibly implementing a wide range of experiments.
432
-
433
- Each project should define one or more experiment configurations and save them as .yaml files inside the project
434
- 'configuration' folder. The name for each configuration file is defined by the user and is used to identify and load
435
- the experiment configuration when 'sl-run-experiment' CLI command exposed by the sl-experiment library is executed.
436
- """
437
-
438
- cue_map: dict[int, float] = field(default_factory=Incomplete)
439
- experiment_states: dict[str, ExperimentState] = field(default_factory=Incomplete)
440
-
441
- @dataclass()
442
- class HardwareConfiguration(YamlConfig):
443
- """This class is used to save the runtime hardware configuration parameters as a .yaml file.
444
-
445
- This information is used to read and decode the data saved to the .npz log files during runtime as part of data
446
- processing.
447
-
448
- Notes:
449
- All fields in this dataclass initialize to None. During log processing, any log associated with a hardware
450
- module that provides the data stored in a field will be processed, unless that field is None. Therefore, setting
451
- any field in this dataclass to None also functions as a flag for whether to parse the log associated with the
452
- module that provides this field's information.
453
-
454
- This class is automatically configured by MesoscopeExperiment and BehaviorTraining classes from sl-experiment
455
- library to facilitate log parsing.
456
- """
457
-
458
- cue_map: dict[int, float] | None = ...
459
- cm_per_pulse: float | None = ...
460
- maximum_break_strength: float | None = ...
461
- minimum_break_strength: float | None = ...
462
- lick_threshold: int | None = ...
463
- valve_scale_coefficient: float | None = ...
464
- valve_nonlinearity_exponent: float | None = ...
465
- torque_per_adc_unit: float | None = ...
466
- screens_initially_on: bool | None = ...
467
- recorded_mesoscope_ttl: bool | None = ...
468
-
469
- @dataclass()
470
- class LickTrainingDescriptor(YamlConfig):
471
- """This class is used to save the description information specific to lick training sessions as a .yaml file.
472
-
473
- The information stored in this class instance is filled in two steps. The main runtime function fills most fields
474
- of the class, before it is saved as a .yaml file. After runtime, the experimenter manually fills leftover fields,
475
- such as 'experimenter_notes,' before the class instance is transferred to the long-term storage destination.
476
-
477
- The fully filled instance data is also used during preprocessing to write the water restriction log entry for the
478
- trained animal.
479
- """
480
-
481
- experimenter: str
482
- mouse_weight_g: float
483
- dispensed_water_volume_ml: float
484
- minimum_reward_delay: int
485
- maximum_reward_delay_s: int
486
- maximum_water_volume_ml: float
487
- maximum_training_time_m: int
488
- experimenter_notes: str = ...
489
- experimenter_given_water_volume_ml: float = ...
490
-
491
- @dataclass()
492
- class RunTrainingDescriptor(YamlConfig):
493
- """This class is used to save the description information specific to run training sessions as a .yaml file.
494
-
495
- The information stored in this class instance is filled in two steps. The main runtime function fills most fields
496
- of the class, before it is saved as a .yaml file. After runtime, the experimenter manually fills leftover fields,
497
- such as 'experimenter_notes,' before the class instance is transferred to the long-term storage destination.
498
-
499
- The fully filled instance data is also used during preprocessing to write the water restriction log entry for the
500
- trained animal.
501
- """
502
-
503
- experimenter: str
504
- mouse_weight_g: float
505
- dispensed_water_volume_ml: float
506
- final_run_speed_threshold_cm_s: float
507
- final_run_duration_threshold_s: float
508
- initial_run_speed_threshold_cm_s: float
509
- initial_run_duration_threshold_s: float
510
- increase_threshold_ml: float
511
- run_speed_increase_step_cm_s: float
512
- run_duration_increase_step_s: float
513
- maximum_water_volume_ml: float
514
- maximum_training_time_m: int
515
- experimenter_notes: str = ...
516
- experimenter_given_water_volume_ml: float = ...
517
-
518
- @dataclass()
519
- class MesoscopeExperimentDescriptor(YamlConfig):
520
- """This class is used to save the description information specific to experiment sessions as a .yaml file.
521
-
522
- The information stored in this class instance is filled in two steps. The main runtime function fills most fields
523
- of the class, before it is saved as a .yaml file. After runtime, the experimenter manually fills leftover fields,
524
- such as 'experimenter_notes,' before the class instance is transferred to the long-term storage destination.
525
-
526
- The fully filled instance data is also used during preprocessing to write the water restriction log entry for the
527
- animal participating in the experiment runtime.
528
- """
529
-
530
- experimenter: str
531
- mouse_weight_g: float
532
- dispensed_water_volume_ml: float
533
- experimenter_notes: str = ...
534
- experimenter_given_water_volume_ml: float = ...
535
-
536
- @dataclass()
537
- class ZaberPositions(YamlConfig):
538
- """This class is used to save Zaber motor positions as a .yaml file to reuse them between sessions.
539
-
540
- The class is specifically designed to store, save, and load the positions of the LickPort and HeadBar motors
541
- (axes). It is used to both store Zaber motor positions for each session for future analysis and to restore the same
542
- Zaber motor positions across consecutive runtimes for the same project and animal combination.
543
-
544
- Notes:
545
- All positions are saved using native motor units. All class fields initialize to default placeholders that are
546
- likely NOT safe to apply to the VR system. Do not apply the positions loaded from the file unless you are
547
- certain they are safe to use.
548
-
549
- Exercise caution when working with Zaber motors. The motors are powerful enough to damage the surrounding
550
- equipment and manipulated objects. Do not modify the data stored inside the .yaml file unless you know what you
551
- are doing.
552
- """
553
-
554
- headbar_z: int = ...
555
- headbar_pitch: int = ...
556
- headbar_roll: int = ...
557
- lickport_z: int = ...
558
- lickport_x: int = ...
559
- lickport_y: int = ...
560
-
561
- @dataclass()
562
- class MesoscopePositions(YamlConfig):
563
- """This class is used to save the real and virtual Mesoscope objective positions as a .yaml file to reuse it
564
- between experiment sessions.
565
-
566
- Primarily, the class is used to help the experimenter to position the Mesoscope at the same position across
567
- multiple imaging sessions. It stores both the physical (real) position of the objective along the motorized
568
- X, Y, Z, and Roll axes and the virtual (ScanImage software) tip, tilt, and fastZ focus axes.
569
-
570
- Notes:
571
- Since the API to read and write these positions automatically is currently not available, this class relies on
572
- the experimenter manually entering all positions and setting the mesoscope to these positions when necessary.
573
- """
574
-
575
- mesoscope_x_position: float = ...
576
- mesoscope_y_position: float = ...
577
- mesoscope_roll_position: float = ...
578
- mesoscope_z_position: float = ...
579
- mesoscope_fast_z_position: float = ...
580
- mesoscope_tip_position: float = ...
581
- mesoscope_tilt_position: float = ...
582
-
583
- @dataclass()
584
- class SubjectData:
585
- """Stores the ID information of the surgical intervention's subject (animal)."""
586
-
587
- id: int
588
- ear_punch: str
589
- sex: str
590
- genotype: str
591
- date_of_birth_us: int
592
- weight_g: float
593
- cage: int
594
- location_housed: str
595
- status: str
596
-
597
- @dataclass()
598
- class ProcedureData:
599
- """Stores the general information about the surgical intervention."""
600
-
601
- surgery_start_us: int
602
- surgery_end_us: int
603
- surgeon: str
604
- protocol: str
605
- surgery_notes: str
606
- post_op_notes: str
607
- surgery_quality: int = ...
608
-
609
- @dataclass
610
- class ImplantData:
611
- """Stores the information about a single implantation performed during the surgical intervention.
612
-
613
- Multiple ImplantData instances are used at the same time if the surgery involved multiple implants.
614
- """
615
-
616
- implant: str
617
- implant_target: str
618
- implant_code: int
619
- implant_ap_coordinate_mm: float
620
- implant_ml_coordinate_mm: float
621
- implant_dv_coordinate_mm: float
622
-
623
- @dataclass
624
- class InjectionData:
625
- """Stores the information about a single injection performed during surgical intervention.
626
-
627
- Multiple InjectionData instances are used at the same time if the surgery involved multiple injections.
628
- """
629
-
630
- injection: str
631
- injection_target: str
632
- injection_volume_nl: float
633
- injection_code: int
634
- injection_ap_coordinate_mm: float
635
- injection_ml_coordinate_mm: float
636
- injection_dv_coordinate_mm: float
637
-
638
- @dataclass
639
- class DrugData:
640
- """Stores the information about all drugs administered to the subject before, during, and immediately after the
641
- surgical intervention.
642
- """
643
-
644
- lactated_ringers_solution_volume_ml: float
645
- lactated_ringers_solution_code: int
646
- ketoprofen_volume_ml: float
647
- ketoprofen_code: int
648
- buprenorphine_volume_ml: float
649
- buprenorphine_code: int
650
- dexamethasone_volume_ml: float
651
- dexamethasone_code: int
652
-
653
- @dataclass
654
- class SurgeryData(YamlConfig):
655
- """Stores the data about a single mouse surgical intervention.
656
-
657
- This class aggregates other dataclass instances that store specific data about the surgical procedure. Primarily, it
658
- is used to save the data as a .yaml file to every session's raw_data directory of each animal used in every lab
659
- project. This way, the surgery data is always stored alongside the behavior and brain activity data collected
660
- during the session.
661
- """
662
-
663
- subject: SubjectData
664
- procedure: ProcedureData
665
- drugs: DrugData
666
- implants: list[ImplantData]
667
- injections: list[InjectionData]