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

@@ -727,6 +727,8 @@ class SessionData(YamlConfig):
727
727
  data through acquisition, preprocessing and processing stages of the Sun lab data workflow.
728
728
  """
729
729
 
730
+ project_name: str
731
+ """Stores the name of the managed session's project."""
730
732
  animal_id: str
731
733
  """Stores the unique identifier of the animal that participates in the managed session."""
732
734
  session_name: str
@@ -740,20 +742,20 @@ class SessionData(YamlConfig):
740
742
  field is used to communicate the specific experiment configuration used by the session. During runtime, this is
741
743
  used to load the experiment configuration (to run the experiment) and to save the experiment configuration to the
742
744
  session raw_data folder. If the session is not an experiment session, this is statically set to None."""
743
- raw_data: RawData | None
745
+ raw_data: RawData
744
746
  """Stores the paths to various directories and files used to store raw and preprocessed session data. Depending on
745
747
  class initialization location (VRPC or BioHPC server), the class automatically resolves the root directory path to
746
748
  either the VRPC project directory or the BioHPC cluster storage volume."""
747
- processed_data: ProcessedData | None
749
+ processed_data: ProcessedData
748
750
  """Stores the paths to various directories used to store processed session data. This is automatically
749
751
  resolved to the fast BioHPC volume (workdir) in all cases, as processed data should only exist on the server."""
750
- persistent_data: PersistentData | None
752
+ persistent_data: PersistentData
751
753
  """Stores the paths to various files and directories kept on VRPC and ScanImagePC after the session data is
752
754
  transferred to long-term storage destinations."""
753
- mesoscope_data: MesoscopeData | None
755
+ mesoscope_data: MesoscopeData
754
756
  """Stores the paths to various directories used by the ScanImagePC to store mesoscope-acquired session data,
755
757
  before it is moved to the VRPC during preprocessing."""
756
- destinations: Destinations | None
758
+ destinations: Destinations
757
759
  """Stores the paths to the destination directories on the BioHPC server and Synology NAS, to which the data is
758
760
  copied as part of preprocessing. Both of these directories should be accessible for the VRPC's filesystem via an
759
761
  SMB or equivalent protocol."""
@@ -886,6 +888,7 @@ class SessionData(YamlConfig):
886
888
 
887
889
  # Packages the sections generated above into a SessionData instance
888
890
  instance = SessionData(
891
+ project_name=project_configuration.project_name,
889
892
  animal_id=animal_id,
890
893
  session_name=session_name,
891
894
  session_type=session_type,
@@ -901,10 +904,6 @@ class SessionData(YamlConfig):
901
904
  # preprocessing
902
905
  instance._to_path()
903
906
 
904
- # Removes the processed_data section, as it is not used on the VRPC. This makes it impossible to accidentally
905
- # interact with this section without errors.
906
- instance.processed_data = None
907
-
908
907
  # Extracts and saves the necessary configuration classes to the session raw_data folder. Note, this list of
909
908
  # classes is not exhaustive. More classes are saved as part of the session runtime management class start() and
910
909
  # __init__() method runtimes:
@@ -916,13 +915,13 @@ class SessionData(YamlConfig):
916
915
  # Project Configuration
917
916
  sh.copy2(
918
917
  src=vrpc_configuration_path.joinpath("project_configuration.yaml"),
919
- dst=instance.raw_data.project_configuration_path, # type: ignore
918
+ dst=instance.raw_data.project_configuration_path,
920
919
  )
921
920
  # Experiment Configuration, if the session type is Experiment.
922
921
  if experiment_name is not None:
923
922
  sh.copy2(
924
923
  src=vrpc_configuration_path.joinpath(f"{experiment_name}.yaml"),
925
- dst=instance.raw_data.experiment_configuration_path, # type: ignore
924
+ dst=instance.raw_data.experiment_configuration_path,
926
925
  )
927
926
 
928
927
  # Returns the initialized SessionData instance to caller
@@ -974,18 +973,12 @@ class SessionData(YamlConfig):
974
973
  # well-configured. This is because the class is always created on the VRPC and, when it leaves VRPC, it is
975
974
  # never used on VRPC again. Therefore, additional processing is ONLY done when on_server is True.
976
975
  if on_server:
977
- # Disables VRPC-only sections. This makes it impossible to call these sections on BioHPC server without
978
- # runtime interruption.
979
- instance.mesoscope_data = None
980
- instance.persistent_data = None
981
- instance.destinations = None
982
-
983
976
  # Reconfigures the raw_data section to use the root provided as part of the session_path.
984
- instance.raw_data.switch_root(new_root=session_path) # type: ignore
977
+ instance.raw_data.switch_root(new_root=session_path)
985
978
 
986
979
  # Processed Data section is always configured to use the BioHPC server root. Calls its' make_dirs() method
987
980
  # to setup directories
988
- instance.processed_data.make_dirs() # type: ignore
981
+ instance.processed_data.make_dirs()
989
982
 
990
983
  # Returns the initialized SessionData instance to caller
991
984
  return instance
@@ -0,0 +1,648 @@
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). Since this is the only subclass used by both the VRPC and the BioHPC server, this method is
167
+ only implemented for this class.
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 on the BioHPC server. These pipelines use raw data to generate processed data, and the processed data is
180
+ usually only stored on the BioHPC server. Processed data represents an intermediate step between raw data and the
181
+ dataset used in the data analysis.
182
+ """
183
+
184
+ processed_data_path: str | Path
185
+ camera_data_path: str | Path
186
+ mesoscope_data_path: str | Path
187
+ behavior_data_path: str | Path
188
+ deeplabcut_root_path: str | Path
189
+ suite2p_configuration_path: str | Path
190
+ def __post_init__(self) -> None:
191
+ """This method is automatically called after class instantiation and ensures that all path fields of the class
192
+ are converted to Path objects.
193
+ """
194
+ def make_string(self) -> None:
195
+ """Converts all Path objects stored inside the class to strings.
196
+
197
+ This transformation is required to support dumping class data into a .YAML file so that the data can be stored
198
+ on disk.
199
+ """
200
+ def make_dirs(self) -> None:
201
+ """Ensures that all major subdirectories of the processed_data directory exist.
202
+
203
+ This method is used by the BioHPC server to generate the processed_data directory as part of the sl-forgery
204
+ library runtime.
205
+ """
206
+
207
+ @dataclass()
208
+ class PersistentData:
209
+ """Stores the paths to the directories and files that make up the 'persistent_data' directories of the VRPC and
210
+ the ScanImagePC.
211
+
212
+ Persistent data directories are used to keep certain files on the VRPC and the ScanImagePC. Typically, this data
213
+ is reused during the following sessions. For example, a copy of Zaber motor positions is persisted on the VRPC for
214
+ each animal after every session to support automatically restoring Zaber motors to the positions used during the
215
+ previous session.
216
+
217
+ Notes:
218
+ Persistent data includes the project and experiment configuration data. Some persistent data is overwritten
219
+ after each session, other data is generated once and kept through the animal's lifetime. Primarily, this data is
220
+ only used internally by the sl-experiment or sl-forgery libraries and is not intended for end-users.
221
+ """
222
+
223
+ zaber_positions_path: str | Path
224
+ mesoscope_positions_path: str | Path
225
+ motion_estimator_path: str | Path
226
+ def __post_init__(self) -> None:
227
+ """This method is automatically called after class instantiation and ensures that all path fields of the class
228
+ are converted to Path objects.
229
+ """
230
+ def make_string(self) -> None:
231
+ """Converts all Path objects stored inside the class to strings.
232
+
233
+ This transformation is required to support dumping class data into a .YAML file so that the data can be stored
234
+ on disk.
235
+ """
236
+ def make_dirs(self) -> None:
237
+ """Ensures that the VRPC and the ScanImagePC persistent_data directories exist."""
238
+
239
+ @dataclass()
240
+ class MesoscopeData:
241
+ """Stores the paths to the directories used by the ScanImagePC to save mesoscope-generated data during session
242
+ runtime.
243
+
244
+ The ScanImagePC is largely isolated from the VRPC during runtime. For the VRPC to pull the data acquired by the
245
+ ScanImagePC, it has to use the predefined directory structure to save the data. This class stores the predefined
246
+ path to various directories where ScanImagePC is expected to save the data and store it after acquisition.sers.
247
+ """
248
+
249
+ root_data_path: str | Path
250
+ mesoscope_data_path: str | Path
251
+ session_specific_mesoscope_data_path: str | Path
252
+ def __post_init__(self) -> None:
253
+ """This method is automatically called after class instantiation and ensures that all path fields of the class
254
+ are converted to Path objects.
255
+ """
256
+ def make_string(self) -> None:
257
+ """Converts all Path objects stored inside the class to strings.
258
+
259
+ This transformation is required to support dumping class data into a .YAML file so that the data can be stored
260
+ on disk.
261
+ """
262
+ def make_dirs(self) -> None:
263
+ """Ensures that the ScanImagePC data acquisition directories exist."""
264
+
265
+ @dataclass()
266
+ class Destinations:
267
+ """Stores the paths to the VRPC filesystem-mounted Synology NAS and BioHPC server directories.
268
+
269
+ These directories are used during data preprocessing to transfer the preprocessed raw_data directory from the
270
+ VRPC to the long-term storage destinations.
271
+ """
272
+
273
+ nas_raw_data_path: str | Path
274
+ server_raw_data_path: str | Path
275
+ def __post_init__(self) -> None:
276
+ """This method is automatically called after class instantiation and ensures that all path fields of the class
277
+ are converted to Path objects.
278
+ """
279
+ def make_string(self) -> None:
280
+ """Converts all Path objects stored inside the class to strings.
281
+
282
+ This transformation is required to support dumping class data into a .YAML file so that the data can be stored
283
+ on disk.
284
+ """
285
+ def make_dirs(self) -> None:
286
+ """Ensures that all destination directories exist."""
287
+
288
+ @dataclass
289
+ class SessionData(YamlConfig):
290
+ """Provides methods for managing the data of a single experiment or training session across all destinations.
291
+
292
+ The primary purpose of this class is to maintain the session data structure across all supported destinations. It
293
+ generates the paths used by all other classes from this library and classes from sl-experiment and sl-forgery
294
+ libraries.
295
+
296
+ If necessary, the class can be used to either generate a new session or to load an already existing session's data.
297
+ When the class is used to create a new session, it automatically resolves the new session's name using the current
298
+ UTC timestamp, down to microseconds. This ensures that each session name is unique and preserves the overall
299
+ session order.
300
+
301
+ Notes:
302
+ If this class is instantiated on the VRPC, it is expected that the BioHPC server, Synology NAS, and ScanImagePC
303
+ data directories are mounted on the local host-machine via the SMB or equivalent protocol. All manipulations
304
+ with these destinations are carried out with the assumption that the OS has full access to these directories
305
+ and filesystems.
306
+
307
+ If this class is instantiated on the BioHPC server, some methods from this class will not work as expected. It
308
+ is essential that this class is not used outside the default sl-experiment and sl-forgery library runtimes to
309
+ ensure it is used safely.
310
+
311
+ This class is specifically designed for working with the data from a single session, performed by a single
312
+ animal under the specific experiment. The class is used to manage both raw and processed data. It follows the
313
+ data through acquisition, preprocessing and processing stages of the Sun lab data workflow.
314
+ """
315
+
316
+ project_name: str
317
+ animal_id: str
318
+ session_name: str
319
+ session_type: str
320
+ experiment_name: str | None
321
+ raw_data: RawData
322
+ processed_data: ProcessedData
323
+ persistent_data: PersistentData
324
+ mesoscope_data: MesoscopeData
325
+ destinations: Destinations
326
+ @classmethod
327
+ def create_session(
328
+ cls,
329
+ animal_id: str,
330
+ session_type: str,
331
+ project_configuration: ProjectConfiguration,
332
+ experiment_name: str | None = None,
333
+ ) -> SessionData:
334
+ """Creates a new SessionData object and uses it to generate the session's data structure.
335
+
336
+ This method is used to initialize new session runtimes. It always assumes it is called on the VRPC and, as part
337
+ of its runtime, resolves and generates the necessary local and ScanImagePC directories to support acquiring and
338
+ preprocessing session's data.
339
+
340
+ Notes:
341
+ To load an already existing session data structure, use the load_session() method instead.
342
+
343
+ This method automatically dumps the data of the created SessionData instance into the session_data.yaml file
344
+ inside the root raw_data directory of the created hierarchy. It also finds and dumps other configuration
345
+ files, such as project_configuration.yaml, suite2p_configuration.yaml, and experiment_configuration.yaml.
346
+ This way, if the session's runtime is interrupted unexpectedly, it can still be processed.
347
+
348
+ Args:
349
+ animal_id: The ID code of the animal for which the data is acquired.
350
+ session_type: The type of the session. Primarily, this determines how to read the session_descriptor.yaml
351
+ file. Valid options are 'Lick training', 'Run training', or 'Experiment'.
352
+ experiment_name: The name of the experiment to be executed as part of this session. This option is only used
353
+ for 'Experiment' session types. It is used to find the target experiment configuration .YAML file and
354
+ copy it into the session's raw_data directory.
355
+ project_configuration: The initialized ProjectConfiguration instance that stores the data for the session's
356
+ project. This is used to determine the root directory paths for all PCs used in the data workflow.
357
+
358
+ Returns:
359
+ An initialized SessionData instance for the newly created session.
360
+ """
361
+ @classmethod
362
+ def load_session(cls, session_path: Path, on_server: bool) -> SessionData:
363
+ """Loads the SessionData instance from the session_data.yaml file of the target session.
364
+
365
+ This method is used to load the data for an already existing session. This is used to call preprocessing
366
+ or processing runtime(s) for the target session. Depending on the call location, the method automatically
367
+ resolves all necessary paths and creates the necessary directories.
368
+
369
+ Notes:
370
+ To create a new session, use the create_session() method instead.
371
+
372
+ Args:
373
+ session_path: The path to the root directory of an existing session, e.g.: vrpc_root/project/animal/session.
374
+ on_server: Determines whether the method is used to initialize an existing session on the VRPC or the
375
+ BioHPC server.
376
+
377
+ Returns:
378
+ An initialized SessionData instance for the session whose data is stored at the provided path.
379
+
380
+ Raises:
381
+ FileNotFoundError: If the 'session_data.yaml' file is not found after resolving the provided path.
382
+ """
383
+ def _to_path(self) -> None:
384
+ """Saves the instance data to the 'raw_data' directory of the managed session as a 'session_data.yaml' file.
385
+
386
+ This is used to save the data stored in the instance to disk, so that it can be reused during preprocessing or
387
+ data processing. The method is intended to only be used by the SessionData instance itself during its
388
+ create_session() method runtime.
389
+ """
390
+
391
+ @dataclass()
392
+ class ExperimentState:
393
+ """Encapsulates the information used to set and maintain the desired experiment and Mesoscope-VR system state.
394
+
395
+ Primarily, experiment runtime logic (task logic) is resolved by the Unity game engine. However, the Mesoscope-VR
396
+ system configuration may also need to change throughout the experiment to optimize the runtime by disabling or
397
+ reconfiguring specific hardware modules. For example, some experiment stages may require the running wheel to be
398
+ locked to prevent the animal from running, and other may require the VR screens to be turned off.
399
+ """
400
+
401
+ experiment_state_code: int
402
+ vr_state_code: int
403
+ state_duration_s: float
404
+
405
+ @dataclass()
406
+ class ExperimentConfiguration(YamlConfig):
407
+ """Stores the configuration of a single experiment runtime.
408
+
409
+ Primarily, this includes the sequence of experiment and Virtual Reality (Mesoscope-VR) states that defines the flow
410
+ of the experiment runtime. During runtime, the main runtime control function traverses the sequence of states
411
+ stored in this class instance start-to-end in the exact order specified by the user. Together with custom Unity
412
+ projects that define the task logic (how the system responds to animal interactions with the VR system) this class
413
+ allows flexibly implementing a wide range of experiments.
414
+
415
+ Each project should define one or more experiment configurations and save them as .yaml files inside the project
416
+ 'configuration' folder. The name for each configuration file is defined by the user and is used to identify and load
417
+ the experiment configuration when 'sl-run-experiment' CLI command exposed by the sl-experiment library is executed.
418
+ """
419
+
420
+ cue_map: dict[int, float] = field(default_factory=Incomplete)
421
+ experiment_states: dict[str, ExperimentState] = field(default_factory=Incomplete)
422
+
423
+ @dataclass()
424
+ class HardwareConfiguration(YamlConfig):
425
+ """This class is used to save the runtime hardware configuration parameters as a .yaml file.
426
+
427
+ This information is used to read and decode the data saved to the .npz log files during runtime as part of data
428
+ processing.
429
+
430
+ Notes:
431
+ All fields in this dataclass initialize to None. During log processing, any log associated with a hardware
432
+ module that provides the data stored in a field will be processed, unless that field is None. Therefore, setting
433
+ any field in this dataclass to None also functions as a flag for whether to parse the log associated with the
434
+ module that provides this field's information.
435
+
436
+ This class is automatically configured by MesoscopeExperiment and BehaviorTraining classes from sl-experiment
437
+ library to facilitate log parsing.
438
+ """
439
+
440
+ cue_map: dict[int, float] | None = ...
441
+ cm_per_pulse: float | None = ...
442
+ maximum_break_strength: float | None = ...
443
+ minimum_break_strength: float | None = ...
444
+ lick_threshold: int | None = ...
445
+ valve_scale_coefficient: float | None = ...
446
+ valve_nonlinearity_exponent: float | None = ...
447
+ torque_per_adc_unit: float | None = ...
448
+ screens_initially_on: bool | None = ...
449
+ recorded_mesoscope_ttl: bool | None = ...
450
+
451
+ @dataclass()
452
+ class LickTrainingDescriptor(YamlConfig):
453
+ """This class is used to save the description information specific to lick training sessions as a .yaml file.
454
+
455
+ The information stored in this class instance is filled in two steps. The main runtime function fills most fields
456
+ of the class, before it is saved as a .yaml file. After runtime, the experimenter manually fills leftover fields,
457
+ such as 'experimenter_notes,' before the class instance is transferred to the long-term storage destination.
458
+
459
+ The fully filled instance data is also used during preprocessing to write the water restriction log entry for the
460
+ trained animal.
461
+ """
462
+
463
+ experimenter: str
464
+ mouse_weight_g: float
465
+ dispensed_water_volume_ml: float
466
+ minimum_reward_delay: int
467
+ maximum_reward_delay_s: int
468
+ maximum_water_volume_ml: float
469
+ maximum_training_time_m: int
470
+ experimenter_notes: str = ...
471
+ experimenter_given_water_volume_ml: float = ...
472
+
473
+ @dataclass()
474
+ class RunTrainingDescriptor(YamlConfig):
475
+ """This class is used to save the description information specific to run training sessions as a .yaml file.
476
+
477
+ The information stored in this class instance is filled in two steps. The main runtime function fills most fields
478
+ of the class, before it is saved as a .yaml file. After runtime, the experimenter manually fills leftover fields,
479
+ such as 'experimenter_notes,' before the class instance is transferred to the long-term storage destination.
480
+
481
+ The fully filled instance data is also used during preprocessing to write the water restriction log entry for the
482
+ trained animal.
483
+ """
484
+
485
+ experimenter: str
486
+ mouse_weight_g: float
487
+ dispensed_water_volume_ml: float
488
+ final_run_speed_threshold_cm_s: float
489
+ final_run_duration_threshold_s: float
490
+ initial_run_speed_threshold_cm_s: float
491
+ initial_run_duration_threshold_s: float
492
+ increase_threshold_ml: float
493
+ run_speed_increase_step_cm_s: float
494
+ run_duration_increase_step_s: float
495
+ maximum_water_volume_ml: float
496
+ maximum_training_time_m: int
497
+ experimenter_notes: str = ...
498
+ experimenter_given_water_volume_ml: float = ...
499
+
500
+ @dataclass()
501
+ class MesoscopeExperimentDescriptor(YamlConfig):
502
+ """This class is used to save the description information specific to experiment sessions as a .yaml file.
503
+
504
+ The information stored in this class instance is filled in two steps. The main runtime function fills most fields
505
+ of the class, before it is saved as a .yaml file. After runtime, the experimenter manually fills leftover fields,
506
+ such as 'experimenter_notes,' before the class instance is transferred to the long-term storage destination.
507
+
508
+ The fully filled instance data is also used during preprocessing to write the water restriction log entry for the
509
+ animal participating in the experiment runtime.
510
+ """
511
+
512
+ experimenter: str
513
+ mouse_weight_g: float
514
+ dispensed_water_volume_ml: float
515
+ experimenter_notes: str = ...
516
+ experimenter_given_water_volume_ml: float = ...
517
+
518
+ @dataclass()
519
+ class ZaberPositions(YamlConfig):
520
+ """This class is used to save Zaber motor positions as a .yaml file to reuse them between sessions.
521
+
522
+ The class is specifically designed to store, save, and load the positions of the LickPort and HeadBar motors
523
+ (axes). It is used to both store Zaber motor positions for each session for future analysis and to restore the same
524
+ Zaber motor positions across consecutive runtimes for the same project and animal combination.
525
+
526
+ Notes:
527
+ All positions are saved using native motor units. All class fields initialize to default placeholders that are
528
+ likely NOT safe to apply to the VR system. Do not apply the positions loaded from the file unless you are
529
+ certain they are safe to use.
530
+
531
+ Exercise caution when working with Zaber motors. The motors are powerful enough to damage the surrounding
532
+ equipment and manipulated objects. Do not modify the data stored inside the .yaml file unless you know what you
533
+ are doing.
534
+ """
535
+
536
+ headbar_z: int = ...
537
+ headbar_pitch: int = ...
538
+ headbar_roll: int = ...
539
+ lickport_z: int = ...
540
+ lickport_x: int = ...
541
+ lickport_y: int = ...
542
+
543
+ @dataclass()
544
+ class MesoscopePositions(YamlConfig):
545
+ """This class is used to save the real and virtual Mesoscope objective positions as a .yaml file to reuse it
546
+ between experiment sessions.
547
+
548
+ Primarily, the class is used to help the experimenter to position the Mesoscope at the same position across
549
+ multiple imaging sessions. It stores both the physical (real) position of the objective along the motorized
550
+ X, Y, Z, and Roll axes and the virtual (ScanImage software) tip, tilt, and fastZ focus axes.
551
+
552
+ Notes:
553
+ Since the API to read and write these positions automatically is currently not available, this class relies on
554
+ the experimenter manually entering all positions and setting the mesoscope to these positions when necessary.
555
+ """
556
+
557
+ mesoscope_x_position: float = ...
558
+ mesoscope_y_position: float = ...
559
+ mesoscope_roll_position: float = ...
560
+ mesoscope_z_position: float = ...
561
+ mesoscope_fast_z_position: float = ...
562
+ mesoscope_tip_position: float = ...
563
+ mesoscope_tilt_position: float = ...
564
+
565
+ @dataclass()
566
+ class SubjectData:
567
+ """Stores the ID information of the surgical intervention's subject (animal)."""
568
+
569
+ id: int
570
+ ear_punch: str
571
+ sex: str
572
+ genotype: str
573
+ date_of_birth_us: int
574
+ weight_g: float
575
+ cage: int
576
+ location_housed: str
577
+ status: str
578
+
579
+ @dataclass()
580
+ class ProcedureData:
581
+ """Stores the general information about the surgical intervention."""
582
+
583
+ surgery_start_us: int
584
+ surgery_end_us: int
585
+ surgeon: str
586
+ protocol: str
587
+ surgery_notes: str
588
+ post_op_notes: str
589
+
590
+ @dataclass
591
+ class ImplantData:
592
+ """Stores the information about a single implantation performed during the surgical intervention.
593
+
594
+ Multiple ImplantData instances are used at the same time if the surgery involved multiple implants.
595
+ """
596
+
597
+ implant: str
598
+ implant_target: str
599
+ implant_code: int
600
+ implant_ap_coordinate_mm: float
601
+ implant_ml_coordinate_mm: float
602
+ implant_dv_coordinate_mm: float
603
+
604
+ @dataclass
605
+ class InjectionData:
606
+ """Stores the information about a single injection performed during surgical intervention.
607
+
608
+ Multiple InjectionData instances are used at the same time if the surgery involved multiple injections.
609
+ """
610
+
611
+ injection: str
612
+ injection_target: str
613
+ injection_volume_nl: float
614
+ injection_code: int
615
+ injection_ap_coordinate_mm: float
616
+ injection_ml_coordinate_mm: float
617
+ injection_dv_coordinate_mm: float
618
+
619
+ @dataclass
620
+ class DrugData:
621
+ """Stores the information about all drugs administered to the subject before, during, and immediately after the
622
+ surgical intervention.
623
+ """
624
+
625
+ lactated_ringers_solution_volume_ml: float
626
+ lactated_ringers_solution_code: int
627
+ ketoprofen_volume_ml: float
628
+ ketoprofen_code: int
629
+ buprenorphine_volume_ml: float
630
+ buprenorphine_code: int
631
+ dexamethasone_volume_ml: float
632
+ dexamethasone_code: int
633
+
634
+ @dataclass
635
+ class SurgeryData(YamlConfig):
636
+ """Stores the data about a single mouse surgical intervention.
637
+
638
+ This class aggregates other dataclass instances that store specific data about the surgical procedure. Primarily, it
639
+ is used to save the data as a .yaml file to every session's raw_data directory of each animal used in every lab
640
+ project. This way, the surgery data is always stored alongside the behavior and brain activity data collected
641
+ during the session.
642
+ """
643
+
644
+ subject: SubjectData
645
+ procedure: ProcedureData
646
+ drugs: DrugData
647
+ implants: list[ImplantData]
648
+ injections: list[InjectionData]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sl-shared-assets
3
- Version: 1.0.0rc4
3
+ Version: 1.0.0rc5
4
4
  Summary: Stores assets shared between multiple Sun (NeuroAI) lab data pipelines.
5
5
  Project-URL: Homepage, https://github.com/Sun-Lab-NBB/sl-shared-assets
6
6
  Project-URL: Documentation, https://sl-shared-assets-api-docs.netlify.app/
@@ -2,7 +2,8 @@ sl_shared_assets/__init__.py,sha256=V7EvTTSB_GhetCbyYPg2RoiG1etDVeML5EBWgGvUo7E,
2
2
  sl_shared_assets/__init__.pyi,sha256=U5Sma4zenITe0-eI_heTUYh_9P0puhgM3hAdcf-qozk,2532
3
3
  sl_shared_assets/cli.py,sha256=CjfuXXj7CeDA2pbCwe5Rad6RDjIqGDud14IUDMdzx_w,2639
4
4
  sl_shared_assets/cli.pyi,sha256=X5UdXpkzUw71_ftaIXMsnttIeR15SPVLiECuPge_zw8,1032
5
- sl_shared_assets/data_classes.py,sha256=cPH4J5c1Rvqt1hvXwmBG3KWkiaWbS9ba-PdiILbp_jQ,84888
5
+ sl_shared_assets/data_classes.py,sha256=iCZ2hD8HRjeGotCT2Cxr4QXQwWgkuxP9mvJC2srGUgM,84440
6
+ sl_shared_assets/data_classes.pyi,sha256=EjOW9Vpp3KPtbFYgfJWGDlLDrnL1ngolPMzbYj4uB8M,31126
6
7
  sl_shared_assets/packaging_tools.py,sha256=3kAXFK37Lv4JA1YhjcoBz1x2Ell8ObCqe9pwxAts4m4,6709
7
8
  sl_shared_assets/packaging_tools.pyi,sha256=hlAP9AxF7NHtFIPKjj5ehm8Vr9qIn6xDk4VvL0JuAmk,3055
8
9
  sl_shared_assets/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -12,8 +13,8 @@ sl_shared_assets/suite2p.py,sha256=sQ5Zj0TJFD-gUHqtWnRvapBpr8QgmaiVil123cWxGxc,2
12
13
  sl_shared_assets/suite2p.pyi,sha256=Uyv8ov--etwJIc6e2UVgs0jYXwnK2CD-kICfXo5KpcI,6331
13
14
  sl_shared_assets/transfer_tools.py,sha256=J26kwOp_NpPSY0-xu5FTw9udte-rm_mW1FJyaTNoqQI,6606
14
15
  sl_shared_assets/transfer_tools.pyi,sha256=FoH7eYZe7guGHfPr0MK5ggO62uXKwD2aJ7h1Bu7PaEE,3294
15
- sl_shared_assets-1.0.0rc4.dist-info/METADATA,sha256=WIdMETLfEyRh4I7rbWWg0hd_mNzeZ9Kb0cbhsOZ58wM,47806
16
- sl_shared_assets-1.0.0rc4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
17
- sl_shared_assets-1.0.0rc4.dist-info/entry_points.txt,sha256=3VPr5RkWBkusNN9OhWXtC-DN0utu7uMrUulazIK2VNA,166
18
- sl_shared_assets-1.0.0rc4.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
19
- sl_shared_assets-1.0.0rc4.dist-info/RECORD,,
16
+ sl_shared_assets-1.0.0rc5.dist-info/METADATA,sha256=Z2EQqTxU20tJ_D80GR_YXR4QjZEUoPWvmv8nhi9I0js,47806
17
+ sl_shared_assets-1.0.0rc5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
+ sl_shared_assets-1.0.0rc5.dist-info/entry_points.txt,sha256=3VPr5RkWBkusNN9OhWXtC-DN0utu7uMrUulazIK2VNA,166
19
+ sl_shared_assets-1.0.0rc5.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
20
+ sl_shared_assets-1.0.0rc5.dist-info/RECORD,,