sl-shared-assets 1.0.0rc14__py3-none-any.whl → 1.0.0rc15__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of sl-shared-assets might be problematic. Click here for more details.

Files changed (42) hide show
  1. sl_shared_assets/__init__.py +21 -9
  2. sl_shared_assets/__init__.pyi +26 -6
  3. sl_shared_assets/cli.py +1 -1
  4. sl_shared_assets/cli.pyi +1 -1
  5. sl_shared_assets/data_classes/__init__.py +63 -0
  6. sl_shared_assets/data_classes/__init__.pyi +61 -0
  7. sl_shared_assets/data_classes/configuration_data.py +64 -0
  8. sl_shared_assets/data_classes/configuration_data.pyi +37 -0
  9. sl_shared_assets/data_classes/runtime_data.py +233 -0
  10. sl_shared_assets/data_classes/runtime_data.pyi +145 -0
  11. sl_shared_assets/{data_classes.py → data_classes/session_data.py} +47 -472
  12. sl_shared_assets/{data_classes.pyi → data_classes/session_data.pyi} +10 -282
  13. sl_shared_assets/data_classes/surgery_data.py +152 -0
  14. sl_shared_assets/data_classes/surgery_data.pyi +89 -0
  15. sl_shared_assets/server/__init__.py +8 -0
  16. sl_shared_assets/server/__init__.pyi +8 -0
  17. sl_shared_assets/server/job.py +140 -0
  18. sl_shared_assets/server/job.pyi +94 -0
  19. sl_shared_assets/server/server.py +213 -0
  20. sl_shared_assets/server/server.pyi +95 -0
  21. sl_shared_assets/suite2p/__init__.py +8 -0
  22. sl_shared_assets/suite2p/__init__.pyi +4 -0
  23. sl_shared_assets/suite2p/multi_day.py +193 -0
  24. sl_shared_assets/suite2p/multi_day.pyi +99 -0
  25. sl_shared_assets/{suite2p.py → suite2p/single_day.py} +55 -32
  26. sl_shared_assets/{suite2p.pyi → suite2p/single_day.pyi} +23 -19
  27. sl_shared_assets/tools/__init__.py +8 -0
  28. sl_shared_assets/tools/__init__.pyi +5 -0
  29. sl_shared_assets/{ascension_tools.py → tools/ascension_tools.py} +3 -2
  30. sl_shared_assets/{ascension_tools.pyi → tools/ascension_tools.pyi} +1 -1
  31. {sl_shared_assets-1.0.0rc14.dist-info → sl_shared_assets-1.0.0rc15.dist-info}/METADATA +1 -1
  32. sl_shared_assets-1.0.0rc15.dist-info/RECORD +40 -0
  33. sl_shared_assets/server.py +0 -300
  34. sl_shared_assets/server.pyi +0 -117
  35. sl_shared_assets-1.0.0rc14.dist-info/RECORD +0 -22
  36. /sl_shared_assets/{packaging_tools.py → tools/packaging_tools.py} +0 -0
  37. /sl_shared_assets/{packaging_tools.pyi → tools/packaging_tools.pyi} +0 -0
  38. /sl_shared_assets/{transfer_tools.py → tools/transfer_tools.py} +0 -0
  39. /sl_shared_assets/{transfer_tools.pyi → tools/transfer_tools.pyi} +0 -0
  40. {sl_shared_assets-1.0.0rc14.dist-info → sl_shared_assets-1.0.0rc15.dist-info}/WHEEL +0 -0
  41. {sl_shared_assets-1.0.0rc14.dist-info → sl_shared_assets-1.0.0rc15.dist-info}/entry_points.txt +0 -0
  42. {sl_shared_assets-1.0.0rc14.dist-info → sl_shared_assets-1.0.0rc15.dist-info}/licenses/LICENSE +0 -0
@@ -1,7 +1,9 @@
1
- """This module provides classes used to store various data used by other Sun lab data acquisition and processing
2
- libraries.This includes classes used to store the data generated during acquisition and preprocessing and classes used
3
- to manage the runtime of other libraries (configuration data classes). Most classes from these modules are used by the
4
- major libraries 'sl-experiment' and 'sl-forgery'."""
1
+ """This module contains classes jointly responsible for maintaining the Sun lab project data hierarchy across all
2
+ machines used to acquire, process, and store the data. Every valid experiment or training session conducted in the
3
+ lab generates a specific directory structure. This structure is defined via the ProjectConfiguration and SessionData
4
+ classes, which are also stored as .yaml files inside each session's raw_data and processed_data directories. Jointly,
5
+ these classes contain all necessary information to restore the data hierarchy on any machine. All other Sun lab
6
+ libraries use these classes to work with all lab-generated data."""
5
7
 
6
8
  import re
7
9
  import copy
@@ -14,6 +16,8 @@ from ataraxis_base_utilities import LogLevel, console, ensure_directory_exists
14
16
  from ataraxis_data_structures import YamlConfig
15
17
  from ataraxis_time.time_helpers import get_timestamp
16
18
 
19
+ from .configuration_data import ExperimentConfiguration
20
+
17
21
 
18
22
  def replace_root_path(path: Path) -> None:
19
23
  """Replaces the path to the local root directory used to store all Sun lab projects with the provided path.
@@ -401,7 +405,7 @@ class RawData:
401
405
  """Stores the path to the project_configuration.yaml file. This file contains the snapshot of the configuration
402
406
  parameters for the session's project."""
403
407
  session_data_path: Path = Path()
404
- """Stores the path to the session_data.yaml file. This path is used b y the SessionData instance to save itself to
408
+ """Stores the path to the session_data.yaml file. This path is used by the SessionData instance to save itself to
405
409
  disk as a .yaml file. The file contains all paths used during data acquisition and processing on both the VRPC and
406
410
  the BioHPC server."""
407
411
  experiment_configuration_path: Path = Path()
@@ -599,12 +603,13 @@ class ProcessedData:
599
603
  server-side data processing pipeline runtimes. Since we use SLURM job manager to execute multiple compute jobs on
600
604
  the BioHPC server, all information sent to the terminal during runtime is redirected to text files stored in this
601
605
  directory."""
602
- processing_tracker_path: Path = Path()
603
- """Stores the path to the processing_tracker.yaml file stored inside the sessions' root processed_data directory.
604
- This file is used to track which processing pipelines need to be applied to the target session and the status
605
- (success / failure) each of these pipelines. Primarily, this is used to optimize data processing to avoid redundant
606
- operations.
607
- """
606
+ project_configuration_path: Path = Path()
607
+ """Stores the path to the project_configuration.yaml file. This file contains the snapshot of the configuration
608
+ parameters for the session's project."""
609
+ session_data_path: Path = Path()
610
+ """Stores the path to the session_data.yaml file. This path is used by the SessionData instance to save itself to
611
+ disk as a .yaml file. The file contains all paths used during data acquisition and processing on both the VRPC and
612
+ the BioHPC server."""
608
613
 
609
614
  def resolve_paths(self, root_directory_path: Path) -> None:
610
615
  """Resolves all paths managed by the class instance based on the input root directory path.
@@ -623,14 +628,14 @@ class ProcessedData:
623
628
  self.mesoscope_data_path = self.processed_data_path.joinpath("mesoscope_data")
624
629
  self.behavior_data_path = self.processed_data_path.joinpath("behavior_data")
625
630
  self.job_logs_path = self.processed_data_path.joinpath("job_logs")
626
- self.processing_tracker_path = self.processed_data_path.joinpath("processing_tracker.yaml")
631
+ self.project_configuration_path = self.processed_data_path.joinpath("project_configuration.yaml")
632
+ self.session_data_path = self.processed_data_path.joinpath("session_data.yaml")
627
633
 
628
634
  def make_directories(self) -> None:
629
635
  """Ensures that all major subdirectories and the root directory exist."""
630
636
 
631
637
  ensure_directory_exists(self.processed_data_path)
632
638
  ensure_directory_exists(self.camera_data_path)
633
- ensure_directory_exists(self.mesoscope_data_path)
634
639
  ensure_directory_exists(self.behavior_data_path)
635
640
  ensure_directory_exists(self.job_logs_path)
636
641
 
@@ -1027,7 +1032,8 @@ class SessionData(YamlConfig):
1027
1032
 
1028
1033
  configuration_data = ConfigurationData()
1029
1034
  configuration_data.resolve_paths(
1030
- root_directory_path=vrpc_root.joinpath(project_name, "configuration"), experiment_name=experiment_name
1035
+ root_directory_path=vrpc_root.joinpath(project_name, "configuration"),
1036
+ experiment_name=experiment_name,
1031
1037
  )
1032
1038
  configuration_data.make_directories()
1033
1039
 
@@ -1079,12 +1085,17 @@ class SessionData(YamlConfig):
1079
1085
  # classes is not exhaustive. More classes are saved as part of the session runtime management class start() and
1080
1086
  # __init__() method runtimes:
1081
1087
 
1082
- # Discovers and saves the necessary configuration class instances to the raw_data folder of the managed session:
1088
+ # Discovers and saves the necessary configuration class instances to the raw_data and the processed_data folders
1089
+ # of the managed session:
1083
1090
  # Project Configuration
1084
1091
  sh.copy2(
1085
1092
  src=instance.configuration_data.project_configuration_path,
1086
1093
  dst=instance.raw_data.project_configuration_path,
1087
1094
  )
1095
+ sh.copy2(
1096
+ src=instance.configuration_data.project_configuration_path,
1097
+ dst=instance.processed_data.project_configuration_path,
1098
+ ) # ProjectConfiguration and SessionData are saved to both raw and processed data folders.
1088
1099
  # Experiment Configuration, if the session type is Experiment.
1089
1100
  if experiment_name is not None:
1090
1101
  sh.copy2(
@@ -1110,6 +1121,10 @@ class SessionData(YamlConfig):
1110
1121
  Notes:
1111
1122
  To create a new session, use the create() method instead.
1112
1123
 
1124
+ Although session_data.yaml is stored both inside raw_data and processed_data subfolders, this method
1125
+ always searches only inside the raw_data folder. Storing session data in both folders is only used to ensure
1126
+ human experimenters can always trace all data in the lab back to the proper project, animal, and session.
1127
+
1113
1128
  Args:
1114
1129
  session_path: The path to the root directory of an existing session, e.g.: vrpc_root/project/animal/session.
1115
1130
  on_server: Determines whether the method is used to initialize an existing session on the BioHPC server or
@@ -1160,7 +1175,8 @@ class SessionData(YamlConfig):
1160
1175
  # CONFIGURATION
1161
1176
  new_root = local_root.joinpath(instance.project_name, "configuration")
1162
1177
  instance.configuration_data.resolve_paths(
1163
- root_directory_path=new_root, experiment_name=instance.experiment_name
1178
+ root_directory_path=new_root,
1179
+ experiment_name=instance.experiment_name,
1164
1180
  )
1165
1181
 
1166
1182
  # DEEPLABCUT
@@ -1224,6 +1240,18 @@ class SessionData(YamlConfig):
1224
1240
  )
1225
1241
  )
1226
1242
 
1243
+ # Ensures that project configuration and session data classes are present in both raw_data and processed_data
1244
+ # directories. This ensures that all data of the session can always be traced to the parent project, animal,
1245
+ # and session.
1246
+ sh.copy2(
1247
+ src=instance.raw_data.session_data_path,
1248
+ dst=instance.processed_data.session_data_path,
1249
+ )
1250
+ sh.copy2(
1251
+ src=instance.raw_data.project_configuration_path,
1252
+ dst=instance.processed_data.project_configuration_path,
1253
+ )
1254
+
1227
1255
  # Generates data directory hierarchies that may be missing on the local machine
1228
1256
  instance.raw_data.make_directories()
1229
1257
  instance.configuration_data.make_directories()
@@ -1234,7 +1262,8 @@ class SessionData(YamlConfig):
1234
1262
  return instance
1235
1263
 
1236
1264
  def _save(self) -> None:
1237
- """Saves the instance data to the 'raw_data' directory of the managed session as a 'session_data.yaml' file.
1265
+ """Saves the instance data to the 'raw_data' directory and the 'processed_data' directory of the managed session
1266
+ as a 'session_data.yaml' file.
1238
1267
 
1239
1268
  This is used to save the data stored in the instance to disk, so that it can be reused during preprocessing or
1240
1269
  data processing. The method is intended to only be used by the SessionData instance itself during its
@@ -1243,458 +1272,4 @@ class SessionData(YamlConfig):
1243
1272
 
1244
1273
  # Saves instance data as a .YAML file
1245
1274
  self.to_yaml(file_path=self.raw_data.session_data_path)
1246
-
1247
-
1248
- @dataclass()
1249
- class ExperimentState:
1250
- """Encapsulates the information used to set and maintain the desired experiment and Mesoscope-VR system state.
1251
-
1252
- Primarily, experiment runtime logic (task logic) is resolved by the Unity game engine. However, the Mesoscope-VR
1253
- system configuration may also need to change throughout the experiment to optimize the runtime by disabling or
1254
- reconfiguring specific hardware modules. For example, some experiment stages may require the running wheel to be
1255
- locked to prevent the animal from running, and other may require the VR screens to be turned off.
1256
- """
1257
-
1258
- experiment_state_code: int
1259
- """The integer code of the experiment state. Experiment states do not have a predefined meaning, Instead, each
1260
- project is expected to define and follow its own experiment state code mapping. Typically, the experiment state
1261
- code is used to denote major experiment stages, such as 'baseline', 'task', 'cooldown', etc. Note, the same
1262
- experiment state code can be used by multiple sequential ExperimentState instances to change the VR system states
1263
- while maintaining the same experiment state."""
1264
- vr_state_code: int
1265
- """One of the supported VR system state-codes. Currently, the Mesoscope-VR system supports two state codes. State
1266
- code '1' denotes 'REST' state and code '2' denotes 'RUN' state. Note, multiple consecutive ExperimentState
1267
- instances with different experiment state codes can reuse the same VR state code."""
1268
- state_duration_s: float
1269
- """The time, in seconds, to maintain the current combination of the experiment and VR states."""
1270
-
1271
-
1272
- @dataclass()
1273
- class ExperimentConfiguration(YamlConfig):
1274
- """Stores the configuration of a single experiment runtime.
1275
-
1276
- Primarily, this includes the sequence of experiment and Virtual Reality (Mesoscope-VR) states that defines the flow
1277
- of the experiment runtime. During runtime, the main runtime control function traverses the sequence of states
1278
- stored in this class instance start-to-end in the exact order specified by the user. Together with custom Unity
1279
- projects that define the task logic (how the system responds to animal interactions with the VR system) this class
1280
- allows flexibly implementing a wide range of experiments.
1281
-
1282
- Each project should define one or more experiment configurations and save them as .yaml files inside the project
1283
- 'configuration' folder. The name for each configuration file is defined by the user and is used to identify and load
1284
- the experiment configuration when 'sl-run-experiment' CLI command exposed by the sl-experiment library is executed.
1285
- """
1286
-
1287
- cue_map: dict[int, float] = field(default_factory=lambda: {0: 30.0, 1: 30.0, 2: 30.0, 3: 30.0, 4: 30.0})
1288
- """A dictionary that maps each integer-code associated with a wall cue used in the Virtual Reality experiment
1289
- environment to its length in real-world centimeters. It is used to map each VR cue to the distance the animal needs
1290
- to travel to fully traverse the wall cue region from start to end."""
1291
- experiment_states: dict[str, ExperimentState] = field(
1292
- default_factory=lambda: {
1293
- "baseline": ExperimentState(experiment_state_code=1, vr_state_code=1, state_duration_s=30),
1294
- "experiment": ExperimentState(experiment_state_code=2, vr_state_code=2, state_duration_s=120),
1295
- "cooldown": ExperimentState(experiment_state_code=3, vr_state_code=1, state_duration_s=15),
1296
- }
1297
- )
1298
- """A dictionary that uses human-readable state-names as keys and ExperimentState instances as values. Each
1299
- ExperimentState instance represents a phase of the experiment."""
1300
-
1301
-
1302
- @dataclass()
1303
- class HardwareConfiguration(YamlConfig):
1304
- """This class is used to save the runtime hardware configuration parameters as a .yaml file.
1305
-
1306
- This information is used to read and decode the data saved to the .npz log files during runtime as part of data
1307
- processing.
1308
-
1309
- Notes:
1310
- All fields in this dataclass initialize to None. During log processing, any log associated with a hardware
1311
- module that provides the data stored in a field will be processed, unless that field is None. Therefore, setting
1312
- any field in this dataclass to None also functions as a flag for whether to parse the log associated with the
1313
- module that provides this field's information.
1314
-
1315
- This class is automatically configured by MesoscopeExperiment and BehaviorTraining classes from sl-experiment
1316
- library to facilitate log parsing.
1317
- """
1318
-
1319
- cue_map: dict[int, float] | None = None
1320
- """MesoscopeExperiment instance property. Stores the dictionary that maps the integer id-codes associated with each
1321
- wall cue in the Virtual Reality task environment with distances in real-world centimeters animals should run on the
1322
- wheel to fully traverse the cue region on a linearized track."""
1323
- cm_per_pulse: float | None = None
1324
- """EncoderInterface instance property. Stores the conversion factor used to translate encoder pulses into
1325
- real-world centimeters."""
1326
- maximum_break_strength: float | None = None
1327
- """BreakInterface instance property. Stores the breaking torque, in Newton centimeters, applied by the break to
1328
- the edge of the running wheel when it is engaged at 100% strength."""
1329
- minimum_break_strength: float | None = None
1330
- """BreakInterface instance property. Stores the breaking torque, in Newton centimeters, applied by the break to
1331
- the edge of the running wheel when it is engaged at 0% strength (completely disengaged)."""
1332
- lick_threshold: int | None = None
1333
- """LickInterface instance property. Determines the threshold, in 12-bit Analog to Digital Converter (ADC) units,
1334
- above which an interaction value reported by the lick sensor is considered a lick (compared to noise or non-lick
1335
- touch)."""
1336
- valve_scale_coefficient: float | None = None
1337
- """ValveInterface instance property. To dispense precise water volumes during runtime, ValveInterface uses power
1338
- law equation applied to valve calibration data to determine how long to keep the valve open. This stores the
1339
- scale_coefficient of the power law equation that describes the relationship between valve open time and dispensed
1340
- water volume, derived from calibration data."""
1341
- valve_nonlinearity_exponent: float | None = None
1342
- """ValveInterface instance property. To dispense precise water volumes during runtime, ValveInterface uses power
1343
- law equation applied to valve calibration data to determine how long to keep the valve open. This stores the
1344
- nonlinearity_exponent of the power law equation that describes the relationship between valve open time and
1345
- dispensed water volume, derived from calibration data."""
1346
- torque_per_adc_unit: float | None = None
1347
- """TorqueInterface instance property. Stores the conversion factor used to translate torque values reported by the
1348
- sensor as 12-bit Analog to Digital Converter (ADC) units, into real-world Newton centimeters (N·cm) of torque that
1349
- had to be applied to the edge of the running wheel to produce the observed ADC value."""
1350
- screens_initially_on: bool | None = None
1351
- """ScreenInterface instance property. Stores the initial state of the Virtual Reality screens at the beginning of
1352
- the session runtime."""
1353
- recorded_mesoscope_ttl: bool | None = None
1354
- """TTLInterface instance property. A boolean flag that determines whether the processed session recorded brain
1355
- activity data with the mesoscope."""
1356
-
1357
-
1358
- @dataclass()
1359
- class LickTrainingDescriptor(YamlConfig):
1360
- """This class is used to save the description information specific to lick training sessions as a .yaml file.
1361
-
1362
- The information stored in this class instance is filled in two steps. The main runtime function fills most fields
1363
- of the class, before it is saved as a .yaml file. After runtime, the experimenter manually fills leftover fields,
1364
- such as 'experimenter_notes,' before the class instance is transferred to the long-term storage destination.
1365
-
1366
- The fully filled instance data is also used during preprocessing to write the water restriction log entry for the
1367
- trained animal.
1368
- """
1369
-
1370
- experimenter: str
1371
- """The ID of the experimenter running the session."""
1372
- mouse_weight_g: float
1373
- """The weight of the animal, in grams, at the beginning of the session."""
1374
- dispensed_water_volume_ml: float
1375
- """Stores the total water volume, in milliliters, dispensed during runtime."""
1376
- minimum_reward_delay: int
1377
- """Stores the minimum delay, in seconds, that can separate the delivery of two consecutive water rewards."""
1378
- maximum_reward_delay_s: int
1379
- """Stores the maximum delay, in seconds, that can separate the delivery of two consecutive water rewards."""
1380
- maximum_water_volume_ml: float
1381
- """Stores the maximum volume of water the system is allowed to dispense during training."""
1382
- maximum_training_time_m: int
1383
- """Stores the maximum time, in minutes, the system is allowed to run the training for."""
1384
- experimenter_notes: str = "Replace this with your notes."
1385
- """This field is not set during runtime. It is expected that each experimenter replaces this field with their
1386
- notes made during runtime."""
1387
- experimenter_given_water_volume_ml: float = 0.0
1388
- """The additional volume of water, in milliliters, administered by the experimenter to the animal after the session.
1389
- """
1390
-
1391
-
1392
- @dataclass()
1393
- class RunTrainingDescriptor(YamlConfig):
1394
- """This class is used to save the description information specific to run training sessions as a .yaml file.
1395
-
1396
- The information stored in this class instance is filled in two steps. The main runtime function fills most fields
1397
- of the class, before it is saved as a .yaml file. After runtime, the experimenter manually fills leftover fields,
1398
- such as 'experimenter_notes,' before the class instance is transferred to the long-term storage destination.
1399
-
1400
- The fully filled instance data is also used during preprocessing to write the water restriction log entry for the
1401
- trained animal.
1402
- """
1403
-
1404
- experimenter: str
1405
- """The ID of the experimenter running the session."""
1406
- mouse_weight_g: float
1407
- """The weight of the animal, in grams, at the beginning of the session."""
1408
- dispensed_water_volume_ml: float
1409
- """Stores the total water volume, in milliliters, dispensed during runtime."""
1410
- final_run_speed_threshold_cm_s: float
1411
- """Stores the final running speed threshold, in centimeters per second, that was active at the end of training."""
1412
- final_run_duration_threshold_s: float
1413
- """Stores the final running duration threshold, in seconds, that was active at the end of training."""
1414
- initial_run_speed_threshold_cm_s: float
1415
- """Stores the initial running speed threshold, in centimeters per second, used during training."""
1416
- initial_run_duration_threshold_s: float
1417
- """Stores the initial running duration threshold, in seconds, used during training."""
1418
- increase_threshold_ml: float
1419
- """Stores the volume of water delivered to the animal, in milliliters, that triggers the increase in the running
1420
- speed and duration thresholds."""
1421
- run_speed_increase_step_cm_s: float
1422
- """Stores the value, in centimeters per second, used by the system to increment the running speed threshold each
1423
- time the animal receives 'increase_threshold' volume of water."""
1424
- run_duration_increase_step_s: float
1425
- """Stores the value, in seconds, used by the system to increment the duration threshold each time the animal
1426
- receives 'increase_threshold' volume of water."""
1427
- maximum_water_volume_ml: float
1428
- """Stores the maximum volume of water the system is allowed to dispense during training."""
1429
- maximum_training_time_m: int
1430
- """Stores the maximum time, in minutes, the system is allowed to run the training for."""
1431
- experimenter_notes: str = "Replace this with your notes."
1432
- """This field is not set during runtime. It is expected that each experimenter will replace this field with their
1433
- notes made during runtime."""
1434
- experimenter_given_water_volume_ml: float = 0.0
1435
- """The additional volume of water, in milliliters, administered by the experimenter to the animal after the session.
1436
- """
1437
-
1438
-
1439
- @dataclass()
1440
- class MesoscopeExperimentDescriptor(YamlConfig):
1441
- """This class is used to save the description information specific to experiment sessions as a .yaml file.
1442
-
1443
- The information stored in this class instance is filled in two steps. The main runtime function fills most fields
1444
- of the class, before it is saved as a .yaml file. After runtime, the experimenter manually fills leftover fields,
1445
- such as 'experimenter_notes,' before the class instance is transferred to the long-term storage destination.
1446
-
1447
- The fully filled instance data is also used during preprocessing to write the water restriction log entry for the
1448
- animal participating in the experiment runtime.
1449
- """
1450
-
1451
- experimenter: str
1452
- """The ID of the experimenter running the session."""
1453
- mouse_weight_g: float
1454
- """The weight of the animal, in grams, at the beginning of the session."""
1455
- dispensed_water_volume_ml: float
1456
- """Stores the total water volume, in milliliters, dispensed during runtime."""
1457
- experimenter_notes: str = "Replace this with your notes."
1458
- """This field is not set during runtime. It is expected that each experimenter will replace this field with their
1459
- notes made during runtime."""
1460
- experimenter_given_water_volume_ml: float = 0.0
1461
- """The additional volume of water, in milliliters, administered by the experimenter to the animal after the session.
1462
- """
1463
-
1464
-
1465
- @dataclass()
1466
- class ZaberPositions(YamlConfig):
1467
- """This class is used to save Zaber motor positions as a .yaml file to reuse them between sessions.
1468
-
1469
- The class is specifically designed to store, save, and load the positions of the LickPort and HeadBar motors
1470
- (axes). It is used to both store Zaber motor positions for each session for future analysis and to restore the same
1471
- Zaber motor positions across consecutive runtimes for the same project and animal combination.
1472
-
1473
- Notes:
1474
- All positions are saved using native motor units. All class fields initialize to default placeholders that are
1475
- likely NOT safe to apply to the VR system. Do not apply the positions loaded from the file unless you are
1476
- certain they are safe to use.
1477
-
1478
- Exercise caution when working with Zaber motors. The motors are powerful enough to damage the surrounding
1479
- equipment and manipulated objects. Do not modify the data stored inside the .yaml file unless you know what you
1480
- are doing.
1481
- """
1482
-
1483
- headbar_z: int = 0
1484
- """The absolute position, in native motor units, of the HeadBar z-axis motor."""
1485
- headbar_pitch: int = 0
1486
- """The absolute position, in native motor units, of the HeadBar pitch-axis motor."""
1487
- headbar_roll: int = 0
1488
- """The absolute position, in native motor units, of the HeadBar roll-axis motor."""
1489
- lickport_z: int = 0
1490
- """The absolute position, in native motor units, of the LickPort z-axis motor."""
1491
- lickport_x: int = 0
1492
- """The absolute position, in native motor units, of the LickPort x-axis motor."""
1493
- lickport_y: int = 0
1494
- """The absolute position, in native motor units, of the LickPort y-axis motor."""
1495
-
1496
-
1497
- @dataclass()
1498
- class MesoscopePositions(YamlConfig):
1499
- """This class is used to save the real and virtual Mesoscope objective positions as a .yaml file to reuse it
1500
- between experiment sessions.
1501
-
1502
- Primarily, the class is used to help the experimenter to position the Mesoscope at the same position across
1503
- multiple imaging sessions. It stores both the physical (real) position of the objective along the motorized
1504
- X, Y, Z, and Roll axes and the virtual (ScanImage software) tip, tilt, and fastZ focus axes.
1505
-
1506
- Notes:
1507
- Since the API to read and write these positions automatically is currently not available, this class relies on
1508
- the experimenter manually entering all positions and setting the mesoscope to these positions when necessary.
1509
- """
1510
-
1511
- mesoscope_x_position: float = 0.0
1512
- """The X-axis position, in centimeters, of the Mesoscope objective used during session runtime."""
1513
- mesoscope_y_position: float = 0.0
1514
- """The Y-axis position, in centimeters, of the Mesoscope objective used during session runtime."""
1515
- mesoscope_roll_position: float = 0.0
1516
- """The Roll-axis position, in degrees, of the Mesoscope objective used during session runtime."""
1517
- mesoscope_z_position: float = 0.0
1518
- """The Z-axis position, in centimeters, of the Mesoscope objective used during session runtime."""
1519
- mesoscope_fast_z_position: float = 0.0
1520
- """The Fast-Z-axis position, in micrometers, of the Mesoscope objective used during session runtime."""
1521
- mesoscope_tip_position: float = 0.0
1522
- """The Tilt-axis position, in degrees, of the Mesoscope objective used during session runtime."""
1523
- mesoscope_tilt_position: float = 0.0
1524
- """The Tip-axis position, in degrees, of the Mesoscope objective used during session runtime."""
1525
-
1526
-
1527
- @dataclass()
1528
- class SubjectData:
1529
- """Stores the ID information of the surgical intervention's subject (animal)."""
1530
-
1531
- id: int
1532
- """Stores the unique ID (name) of the subject. Assumes all animals are given a numeric ID, rather than a string
1533
- name."""
1534
- ear_punch: str
1535
- """Stores the ear tag location of the subject."""
1536
- sex: str
1537
- """Stores the gender of the subject."""
1538
- genotype: str
1539
- """Stores the genotype of the subject."""
1540
- date_of_birth_us: int
1541
- """Stores the date of birth of the subject as the number of microseconds elapsed since UTC epoch onset."""
1542
- weight_g: float
1543
- """Stores the weight of the subject pre-surgery, in grams."""
1544
- cage: int
1545
- """Stores the number of the cage used to house the subject after surgery."""
1546
- location_housed: str
1547
- """Stores the location used to house the subject after the surgery."""
1548
- status: str
1549
- """Stores the current status of the subject (alive / deceased)."""
1550
-
1551
-
1552
- @dataclass()
1553
- class ProcedureData:
1554
- """Stores the general information about the surgical intervention."""
1555
-
1556
- surgery_start_us: int
1557
- """Stores the date and time when the surgery has started as microseconds elapsed since UTC epoch onset."""
1558
- surgery_end_us: int
1559
- """Stores the date and time when the surgery has ended as microseconds elapsed since UTC epoch onset."""
1560
- surgeon: str
1561
- """Stores the name or ID of the surgeon. If the intervention was carried out by multiple surgeons, all participating
1562
- surgeon names and IDs are stored as part of the same string."""
1563
- protocol: str
1564
- """Stores the experiment protocol number (ID) used during the surgery."""
1565
- surgery_notes: str
1566
- """Stores surgeon's notes taken during the surgery."""
1567
- post_op_notes: str
1568
- """Stores surgeon's notes taken during the post-surgery recovery period."""
1569
- surgery_quality: int = 0
1570
- """Stores the quality of the surgical intervention as a numeric level. 0 indicates unusable (bad) result, 1
1571
- indicates usable result that is not good enough to be included in a publication, 2 indicates publication-grade
1572
- result."""
1573
-
1574
-
1575
- @dataclass
1576
- class ImplantData:
1577
- """Stores the information about a single implantation performed during the surgical intervention.
1578
-
1579
- Multiple ImplantData instances are used at the same time if the surgery involved multiple implants.
1580
- """
1581
-
1582
- implant: str
1583
- """The descriptive name of the implant."""
1584
- implant_target: str
1585
- """The name of the brain region or cranium section targeted by the implant."""
1586
- implant_code: int
1587
- """The manufacturer code or internal reference code for the implant. This code is used to identify the implant in
1588
- additional datasheets and lab ordering documents."""
1589
- implant_ap_coordinate_mm: float
1590
- """Stores implant's antero-posterior stereotactic coordinate, in millimeters, relative to bregma."""
1591
- implant_ml_coordinate_mm: float
1592
- """Stores implant's medial-lateral stereotactic coordinate, in millimeters, relative to bregma."""
1593
- implant_dv_coordinate_mm: float
1594
- """Stores implant's dorsal-ventral stereotactic coordinate, in millimeters, relative to bregma."""
1595
-
1596
-
1597
- @dataclass
1598
- class InjectionData:
1599
- """Stores the information about a single injection performed during surgical intervention.
1600
-
1601
- Multiple InjectionData instances are used at the same time if the surgery involved multiple injections.
1602
- """
1603
-
1604
- injection: str
1605
- """The descriptive name of the injection."""
1606
- injection_target: str
1607
- """The name of the brain region targeted by the injection."""
1608
- injection_volume_nl: float
1609
- """The volume of substance, in nanoliters, delivered during the injection."""
1610
- injection_code: int
1611
- """The manufacturer code or internal reference code for the injected substance. This code is used to identify the
1612
- substance in additional datasheets and lab ordering documents."""
1613
- injection_ap_coordinate_mm: float
1614
- """Stores injection's antero-posterior stereotactic coordinate, in millimeters, relative to bregma."""
1615
- injection_ml_coordinate_mm: float
1616
- """Stores injection's medial-lateral stereotactic coordinate, in millimeters, relative to bregma."""
1617
- injection_dv_coordinate_mm: float
1618
- """Stores injection's dorsal-ventral stereotactic coordinate, in millimeters, relative to bregma."""
1619
-
1620
-
1621
- @dataclass
1622
- class DrugData:
1623
- """Stores the information about all drugs administered to the subject before, during, and immediately after the
1624
- surgical intervention.
1625
- """
1626
-
1627
- lactated_ringers_solution_volume_ml: float
1628
- """Stores the volume of Lactated Ringer's Solution (LRS) administered during surgery, in ml."""
1629
- lactated_ringers_solution_code: int
1630
- """Stores the manufacturer code or internal reference code for Lactated Ringer's Solution (LRS). This code is used
1631
- to identify the LRS batch in additional datasheets and lab ordering documents."""
1632
- ketoprofen_volume_ml: float
1633
- """Stores the volume of ketoprofen diluted with saline administered during surgery, in ml."""
1634
- ketoprofen_code: int
1635
- """Stores the manufacturer code or internal reference code for ketoprofen. This code is used to identify the
1636
- ketoprofen batch in additional datasheets and lab ordering documents."""
1637
- buprenorphine_volume_ml: float
1638
- """Stores the volume of buprenorphine diluted with saline administered during surgery, in ml."""
1639
- buprenorphine_code: int
1640
- """Stores the manufacturer code or internal reference code for buprenorphine. This code is used to identify the
1641
- buprenorphine batch in additional datasheets and lab ordering documents."""
1642
- dexamethasone_volume_ml: float
1643
- """Stores the volume of dexamethasone diluted with saline administered during surgery, in ml."""
1644
- dexamethasone_code: int
1645
- """Stores the manufacturer code or internal reference code for dexamethasone. This code is used to identify the
1646
- dexamethasone batch in additional datasheets and lab ordering documents."""
1647
-
1648
-
1649
- @dataclass
1650
- class SurgeryData(YamlConfig):
1651
- """Stores the data about a single mouse surgical intervention.
1652
-
1653
- This class aggregates other dataclass instances that store specific data about the surgical procedure. Primarily, it
1654
- is used to save the data as a .yaml file to every session's raw_data directory of each animal used in every lab
1655
- project. This way, the surgery data is always stored alongside the behavior and brain activity data collected
1656
- during the session.
1657
- """
1658
-
1659
- subject: SubjectData
1660
- """Stores the ID information about the subject (mouse)."""
1661
- procedure: ProcedureData
1662
- """Stores general data about the surgical intervention."""
1663
- drugs: DrugData
1664
- """Stores the data about the substances subcutaneously injected into the subject before, during and immediately
1665
- after the surgical intervention."""
1666
- implants: list[ImplantData]
1667
- """Stores the data for all cranial and transcranial implants introduced to the subject during the surgical
1668
- intervention."""
1669
- injections: list[InjectionData]
1670
- """Stores the data about all substances infused into the brain of the subject during the surgical intervention."""
1671
-
1672
-
1673
- @dataclass()
1674
- class ProcessingTracker(YamlConfig):
1675
- """Tracks the data processing status for a single session.
1676
-
1677
- This class is used during BioHPC-server data processing runtimes to track which processing steps are enabled and
1678
- have been successfully applied to a given session. This is used to optimize data processing and avoid unnecessary
1679
- processing step repetitions where possible.
1680
-
1681
- Notes:
1682
- This class uses a similar mechanism for determining whether a particular option is enabled as the
1683
- HardwareConfiguration class. Specifically, if any field of the class is set to None (null), the processing
1684
- associated with that field is disabled. Otherwise, if the field is False, that session has not been processed
1685
- and, if True, the session has been processed.
1686
- """
1687
-
1688
- checksum: bool | None = None
1689
- """Tracks whether session data integrity has been verified using checksum recalculation method. This step should
1690
- be enabled for all sessions to ensure their data was transmitted intact."""
1691
- log_extractions: bool | None = None
1692
- """Tracks whether session's behavior and runtime logs have been parsed to extract the relevant data. This step
1693
- should be enabled for all sessions other than the 'Window checking' session type, which does not generate any log
1694
- data."""
1695
- suite2p: bool | None = None
1696
- """Tracks whether the Mesoscope-acquired brain activity data has been processed (registered) using sl-suite2p.
1697
- This step should eb enabled for all experiment sessions that collect brain activity data."""
1698
- deeplabcut: bool | None = None
1699
- """Tracks whether session's videos have been processed using DeepLabCut to extract pose estimation and various
1700
- animal body part tracking. This step should only be enabled for projects that need to track this data."""
1275
+ self.to_yaml(file_path=self.processed_data.session_data_path)