sl-shared-assets 1.0.0rc3__tar.gz → 1.0.0rc4__tar.gz

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 (29) hide show
  1. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/PKG-INFO +3 -2
  2. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/README.md +2 -1
  3. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/pyproject.toml +1 -1
  4. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/src/sl_shared_assets/data_classes.py +4 -1
  5. sl_shared_assets-1.0.0rc3/src/sl_shared_assets/data_classes.pyi +0 -646
  6. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/.gitignore +0 -0
  7. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/LICENSE +0 -0
  8. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/docs/Makefile +0 -0
  9. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/docs/make.bat +0 -0
  10. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/docs/source/api.rst +0 -0
  11. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/docs/source/conf.py +0 -0
  12. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/docs/source/index.rst +0 -0
  13. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/docs/source/welcome.rst +0 -0
  14. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/envs/slsa_dev_lin.yml +0 -0
  15. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/envs/slsa_dev_lin_spec.txt +0 -0
  16. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/src/sl_shared_assets/__init__.py +0 -0
  17. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/src/sl_shared_assets/__init__.pyi +0 -0
  18. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/src/sl_shared_assets/cli.py +0 -0
  19. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/src/sl_shared_assets/cli.pyi +0 -0
  20. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/src/sl_shared_assets/packaging_tools.py +0 -0
  21. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/src/sl_shared_assets/packaging_tools.pyi +0 -0
  22. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/src/sl_shared_assets/py.typed +0 -0
  23. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/src/sl_shared_assets/server.py +0 -0
  24. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/src/sl_shared_assets/server.pyi +0 -0
  25. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/src/sl_shared_assets/suite2p.py +0 -0
  26. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/src/sl_shared_assets/suite2p.pyi +0 -0
  27. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/src/sl_shared_assets/transfer_tools.py +0 -0
  28. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/src/sl_shared_assets/transfer_tools.pyi +0 -0
  29. {sl_shared_assets-1.0.0rc3 → sl_shared_assets-1.0.0rc4}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sl-shared-assets
3
- Version: 1.0.0rc3
3
+ Version: 1.0.0rc4
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/
@@ -805,7 +805,7 @@ Note, installation from source is ***highly discouraged*** for everyone who is n
805
805
  wheel into the active python environment.
806
806
 
807
807
  ### pip
808
- Use the following command to install the library using pip: ```pip install sl-experiment```.
808
+ Use the following command to install the library using pip: ```pip install sl-shared-assets```.
809
809
 
810
810
  ---
811
811
 
@@ -834,6 +834,7 @@ ___
834
834
  ## License
835
835
 
836
836
  This project is licensed under the GPL3 License: see the [LICENSE](LICENSE) file for details.
837
+
837
838
  ___
838
839
 
839
840
  ## Acknowledgments
@@ -56,7 +56,7 @@ Note, installation from source is ***highly discouraged*** for everyone who is n
56
56
  wheel into the active python environment.
57
57
 
58
58
  ### pip
59
- Use the following command to install the library using pip: ```pip install sl-experiment```.
59
+ Use the following command to install the library using pip: ```pip install sl-shared-assets```.
60
60
 
61
61
  ---
62
62
 
@@ -85,6 +85,7 @@ ___
85
85
  ## License
86
86
 
87
87
  This project is licensed under the GPL3 License: see the [LICENSE](LICENSE) file for details.
88
+
88
89
  ___
89
90
 
90
91
  ## Acknowledgments
@@ -8,7 +8,7 @@ build-backend = "hatchling.build"
8
8
  # Project metdata section. Provides the genral ID information about the project.
9
9
  [project]
10
10
  name = "sl-shared-assets"
11
- version = "1.0.0rc3"
11
+ version = "1.0.0rc4"
12
12
  description = "Stores assets shared between multiple Sun (NeuroAI) lab data pipelines."
13
13
  readme = "README.md"
14
14
  license = { file = "LICENSE" }
@@ -729,12 +729,14 @@ class SessionData(YamlConfig):
729
729
 
730
730
  animal_id: str
731
731
  """Stores the unique identifier of the animal that participates in the managed session."""
732
+ session_name: str
733
+ """Stores the name (timestamp-based ID) of the managed session."""
732
734
  session_type: str
733
735
  """Stores the type of the session. Primarily, this determines how to read the session_descriptor.yaml file. Has
734
736
  to be set to one of the three supported types: 'Lick training', 'Run training' or 'Experiment'.
735
737
  """
736
738
  experiment_name: str | None
737
- """Stores the name of the experiment configuration file. If the session_name field is set to 'Experiment', this
739
+ """Stores the name of the experiment configuration file. If the session_type field is set to 'Experiment', this
738
740
  field is used to communicate the specific experiment configuration used by the session. During runtime, this is
739
741
  used to load the experiment configuration (to run the experiment) and to save the experiment configuration to the
740
742
  session raw_data folder. If the session is not an experiment session, this is statically set to None."""
@@ -885,6 +887,7 @@ class SessionData(YamlConfig):
885
887
  # Packages the sections generated above into a SessionData instance
886
888
  instance = SessionData(
887
889
  animal_id=animal_id,
890
+ session_name=session_name,
888
891
  session_type=session_type,
889
892
  raw_data=raw_data,
890
893
  processed_data=processed_data,
@@ -1,646 +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). 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
- animal_id: str
317
- session_type: str
318
- experiment_name: str | None
319
- raw_data: RawData | None
320
- processed_data: ProcessedData | None
321
- persistent_data: PersistentData | None
322
- mesoscope_data: MesoscopeData | None
323
- destinations: Destinations | None
324
- @classmethod
325
- def create_session(
326
- cls,
327
- animal_id: str,
328
- session_type: str,
329
- project_configuration: ProjectConfiguration,
330
- experiment_name: str | None = None,
331
- ) -> SessionData:
332
- """Creates a new SessionData object and uses it to generate the session's data structure.
333
-
334
- This method is used to initialize new session runtimes. It always assumes it is called on the VRPC and, as part
335
- of its runtime, resolves and generates the necessary local and ScanImagePC directories to support acquiring and
336
- preprocessing session's data.
337
-
338
- Notes:
339
- To load an already existing session data structure, use the load_session() method instead.
340
-
341
- This method automatically dumps the data of the created SessionData instance into the session_data.yaml file
342
- inside the root raw_data directory of the created hierarchy. It also finds and dumps other configuration
343
- files, such as project_configuration.yaml, suite2p_configuration.yaml, and experiment_configuration.yaml.
344
- This way, if the session's runtime is interrupted unexpectedly, it can still be processed.
345
-
346
- Args:
347
- animal_id: The ID code of the animal for which the data is acquired.
348
- session_type: The type of the session. Primarily, this determines how to read the session_descriptor.yaml
349
- file. Valid options are 'Lick training', 'Run training', or 'Experiment'.
350
- experiment_name: The name of the experiment to be executed as part of this session. This option is only used
351
- for 'Experiment' session types. It is used to find the target experiment configuration .YAML file and
352
- copy it into the session's raw_data directory.
353
- project_configuration: The initialized ProjectConfiguration instance that stores the data for the session's
354
- project. This is used to determine the root directory paths for all PCs used in the data workflow.
355
-
356
- Returns:
357
- An initialized SessionData instance for the newly created session.
358
- """
359
- @classmethod
360
- def load_session(cls, session_path: Path, on_server: bool) -> SessionData:
361
- """Loads the SessionData instance from the session_data.yaml file of the target session.
362
-
363
- This method is used to load the data for an already existing session. This is used to call preprocessing
364
- or processing runtime(s) for the target session. Depending on the call location, the method automatically
365
- resolves all necessary paths and creates the necessary directories.
366
-
367
- Notes:
368
- To create a new session, use the create_session() method instead.
369
-
370
- Args:
371
- session_path: The path to the root directory of an existing session, e.g.: vrpc_root/project/animal/session.
372
- on_server: Determines whether the method is used to initialize an existing session on the VRPC or the
373
- BioHPC server.
374
-
375
- Returns:
376
- An initialized SessionData instance for the session whose data is stored at the provided path.
377
-
378
- Raises:
379
- FileNotFoundError: If the 'session_data.yaml' file is not found after resolving the provided path.
380
- """
381
- def _to_path(self) -> None:
382
- """Saves the instance data to the 'raw_data' directory of the managed session as a 'session_data.yaml' file.
383
-
384
- This is used to save the data stored in the instance to disk, so that it can be reused during preprocessing or
385
- data processing. The method is intended to only be used by the SessionData instance itself during its
386
- create_session() method runtime.
387
- """
388
-
389
- @dataclass()
390
- class ExperimentState:
391
- """Encapsulates the information used to set and maintain the desired experiment and Mesoscope-VR system state.
392
-
393
- Primarily, experiment runtime logic (task logic) is resolved by the Unity game engine. However, the Mesoscope-VR
394
- system configuration may also need to change throughout the experiment to optimize the runtime by disabling or
395
- reconfiguring specific hardware modules. For example, some experiment stages may require the running wheel to be
396
- locked to prevent the animal from running, and other may require the VR screens to be turned off.
397
- """
398
-
399
- experiment_state_code: int
400
- vr_state_code: int
401
- state_duration_s: float
402
-
403
- @dataclass()
404
- class ExperimentConfiguration(YamlConfig):
405
- """Stores the configuration of a single experiment runtime.
406
-
407
- Primarily, this includes the sequence of experiment and Virtual Reality (Mesoscope-VR) states that defines the flow
408
- of the experiment runtime. During runtime, the main runtime control function traverses the sequence of states
409
- stored in this class instance start-to-end in the exact order specified by the user. Together with custom Unity
410
- projects that define the task logic (how the system responds to animal interactions with the VR system) this class
411
- allows flexibly implementing a wide range of experiments.
412
-
413
- Each project should define one or more experiment configurations and save them as .yaml files inside the project
414
- 'configuration' folder. The name for each configuration file is defined by the user and is used to identify and load
415
- the experiment configuration when 'sl-run-experiment' CLI command exposed by the sl-experiment library is executed.
416
- """
417
-
418
- cue_map: dict[int, float] = field(default_factory=Incomplete)
419
- experiment_states: dict[str, ExperimentState] = field(default_factory=Incomplete)
420
-
421
- @dataclass()
422
- class HardwareConfiguration(YamlConfig):
423
- """This class is used to save the runtime hardware configuration parameters as a .yaml file.
424
-
425
- This information is used to read and decode the data saved to the .npz log files during runtime as part of data
426
- processing.
427
-
428
- Notes:
429
- All fields in this dataclass initialize to None. During log processing, any log associated with a hardware
430
- module that provides the data stored in a field will be processed, unless that field is None. Therefore, setting
431
- any field in this dataclass to None also functions as a flag for whether to parse the log associated with the
432
- module that provides this field's information.
433
-
434
- This class is automatically configured by MesoscopeExperiment and BehaviorTraining classes from sl-experiment
435
- library to facilitate log parsing.
436
- """
437
-
438
- cue_map: dict[int, float] | None = ...
439
- cm_per_pulse: float | None = ...
440
- maximum_break_strength: float | None = ...
441
- minimum_break_strength: float | None = ...
442
- lick_threshold: int | None = ...
443
- valve_scale_coefficient: float | None = ...
444
- valve_nonlinearity_exponent: float | None = ...
445
- torque_per_adc_unit: float | None = ...
446
- screens_initially_on: bool | None = ...
447
- recorded_mesoscope_ttl: bool | None = ...
448
-
449
- @dataclass()
450
- class LickTrainingDescriptor(YamlConfig):
451
- """This class is used to save the description information specific to lick training sessions as a .yaml file.
452
-
453
- The information stored in this class instance is filled in two steps. The main runtime function fills most fields
454
- of the class, before it is saved as a .yaml file. After runtime, the experimenter manually fills leftover fields,
455
- such as 'experimenter_notes,' before the class instance is transferred to the long-term storage destination.
456
-
457
- The fully filled instance data is also used during preprocessing to write the water restriction log entry for the
458
- trained animal.
459
- """
460
-
461
- experimenter: str
462
- mouse_weight_g: float
463
- dispensed_water_volume_ml: float
464
- minimum_reward_delay: int
465
- maximum_reward_delay_s: int
466
- maximum_water_volume_ml: float
467
- maximum_training_time_m: int
468
- experimenter_notes: str = ...
469
- experimenter_given_water_volume_ml: float = ...
470
-
471
- @dataclass()
472
- class RunTrainingDescriptor(YamlConfig):
473
- """This class is used to save the description information specific to run training sessions as a .yaml file.
474
-
475
- The information stored in this class instance is filled in two steps. The main runtime function fills most fields
476
- of the class, before it is saved as a .yaml file. After runtime, the experimenter manually fills leftover fields,
477
- such as 'experimenter_notes,' before the class instance is transferred to the long-term storage destination.
478
-
479
- The fully filled instance data is also used during preprocessing to write the water restriction log entry for the
480
- trained animal.
481
- """
482
-
483
- experimenter: str
484
- mouse_weight_g: float
485
- dispensed_water_volume_ml: float
486
- final_run_speed_threshold_cm_s: float
487
- final_run_duration_threshold_s: float
488
- initial_run_speed_threshold_cm_s: float
489
- initial_run_duration_threshold_s: float
490
- increase_threshold_ml: float
491
- run_speed_increase_step_cm_s: float
492
- run_duration_increase_step_s: float
493
- maximum_water_volume_ml: float
494
- maximum_training_time_m: int
495
- experimenter_notes: str = ...
496
- experimenter_given_water_volume_ml: float = ...
497
-
498
- @dataclass()
499
- class MesoscopeExperimentDescriptor(YamlConfig):
500
- """This class is used to save the description information specific to experiment sessions as a .yaml file.
501
-
502
- The information stored in this class instance is filled in two steps. The main runtime function fills most fields
503
- of the class, before it is saved as a .yaml file. After runtime, the experimenter manually fills leftover fields,
504
- such as 'experimenter_notes,' before the class instance is transferred to the long-term storage destination.
505
-
506
- The fully filled instance data is also used during preprocessing to write the water restriction log entry for the
507
- animal participating in the experiment runtime.
508
- """
509
-
510
- experimenter: str
511
- mouse_weight_g: float
512
- dispensed_water_volume_ml: float
513
- experimenter_notes: str = ...
514
- experimenter_given_water_volume_ml: float = ...
515
-
516
- @dataclass()
517
- class ZaberPositions(YamlConfig):
518
- """This class is used to save Zaber motor positions as a .yaml file to reuse them between sessions.
519
-
520
- The class is specifically designed to store, save, and load the positions of the LickPort and HeadBar motors
521
- (axes). It is used to both store Zaber motor positions for each session for future analysis and to restore the same
522
- Zaber motor positions across consecutive runtimes for the same project and animal combination.
523
-
524
- Notes:
525
- All positions are saved using native motor units. All class fields initialize to default placeholders that are
526
- likely NOT safe to apply to the VR system. Do not apply the positions loaded from the file unless you are
527
- certain they are safe to use.
528
-
529
- Exercise caution when working with Zaber motors. The motors are powerful enough to damage the surrounding
530
- equipment and manipulated objects. Do not modify the data stored inside the .yaml file unless you know what you
531
- are doing.
532
- """
533
-
534
- headbar_z: int = ...
535
- headbar_pitch: int = ...
536
- headbar_roll: int = ...
537
- lickport_z: int = ...
538
- lickport_x: int = ...
539
- lickport_y: int = ...
540
-
541
- @dataclass()
542
- class MesoscopePositions(YamlConfig):
543
- """This class is used to save the real and virtual Mesoscope objective positions as a .yaml file to reuse it
544
- between experiment sessions.
545
-
546
- Primarily, the class is used to help the experimenter to position the Mesoscope at the same position across
547
- multiple imaging sessions. It stores both the physical (real) position of the objective along the motorized
548
- X, Y, Z, and Roll axes and the virtual (ScanImage software) tip, tilt, and fastZ focus axes.
549
-
550
- Notes:
551
- Since the API to read and write these positions automatically is currently not available, this class relies on
552
- the experimenter manually entering all positions and setting the mesoscope to these positions when necessary.
553
- """
554
-
555
- mesoscope_x_position: float = ...
556
- mesoscope_y_position: float = ...
557
- mesoscope_roll_position: float = ...
558
- mesoscope_z_position: float = ...
559
- mesoscope_fast_z_position: float = ...
560
- mesoscope_tip_position: float = ...
561
- mesoscope_tilt_position: float = ...
562
-
563
- @dataclass()
564
- class SubjectData:
565
- """Stores the ID information of the surgical intervention's subject (animal)."""
566
-
567
- id: int
568
- ear_punch: str
569
- sex: str
570
- genotype: str
571
- date_of_birth_us: int
572
- weight_g: float
573
- cage: int
574
- location_housed: str
575
- status: str
576
-
577
- @dataclass()
578
- class ProcedureData:
579
- """Stores the general information about the surgical intervention."""
580
-
581
- surgery_start_us: int
582
- surgery_end_us: int
583
- surgeon: str
584
- protocol: str
585
- surgery_notes: str
586
- post_op_notes: str
587
-
588
- @dataclass
589
- class ImplantData:
590
- """Stores the information about a single implantation performed during the surgical intervention.
591
-
592
- Multiple ImplantData instances are used at the same time if the surgery involved multiple implants.
593
- """
594
-
595
- implant: str
596
- implant_target: str
597
- implant_code: int
598
- implant_ap_coordinate_mm: float
599
- implant_ml_coordinate_mm: float
600
- implant_dv_coordinate_mm: float
601
-
602
- @dataclass
603
- class InjectionData:
604
- """Stores the information about a single injection performed during surgical intervention.
605
-
606
- Multiple InjectionData instances are used at the same time if the surgery involved multiple injections.
607
- """
608
-
609
- injection: str
610
- injection_target: str
611
- injection_volume_nl: float
612
- injection_code: int
613
- injection_ap_coordinate_mm: float
614
- injection_ml_coordinate_mm: float
615
- injection_dv_coordinate_mm: float
616
-
617
- @dataclass
618
- class DrugData:
619
- """Stores the information about all drugs administered to the subject before, during, and immediately after the
620
- surgical intervention.
621
- """
622
-
623
- lactated_ringers_solution_volume_ml: float
624
- lactated_ringers_solution_code: int
625
- ketoprofen_volume_ml: float
626
- ketoprofen_code: int
627
- buprenorphine_volume_ml: float
628
- buprenorphine_code: int
629
- dexamethasone_volume_ml: float
630
- dexamethasone_code: int
631
-
632
- @dataclass
633
- class SurgeryData(YamlConfig):
634
- """Stores the data about a single mouse surgical intervention.
635
-
636
- This class aggregates other dataclass instances that store specific data about the surgical procedure. Primarily, it
637
- is used to save the data as a .yaml file to every session's raw_data directory of each animal used in every lab
638
- project. This way, the surgery data is always stored alongside the behavior and brain activity data collected
639
- during the session.
640
- """
641
-
642
- subject: SubjectData
643
- procedure: ProcedureData
644
- drugs: DrugData
645
- implants: list[ImplantData]
646
- injections: list[InjectionData]