sl-shared-assets 5.0.1__py3-none-any.whl → 5.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of sl-shared-assets might be problematic. Click here for more details.
- sl_shared_assets/__init__.py +4 -0
- sl_shared_assets/command_line_interfaces/manage.py +53 -0
- sl_shared_assets/data_classes/__init__.py +3 -3
- sl_shared_assets/data_classes/configuration_data.py +105 -138
- sl_shared_assets/data_classes/runtime_data.py +2 -4
- sl_shared_assets/data_classes/session_data.py +116 -86
- sl_shared_assets/data_classes/surgery_data.py +44 -44
- sl_shared_assets/server/__init__.py +1 -2
- sl_shared_assets/server/job.py +43 -50
- sl_shared_assets/server/pipeline.py +108 -119
- sl_shared_assets/server/server.py +45 -104
- sl_shared_assets/tools/__init__.py +4 -0
- sl_shared_assets/tools/packaging_tools.py +1 -1
- sl_shared_assets/tools/project_management_tools.py +67 -12
- {sl_shared_assets-5.0.1.dist-info → sl_shared_assets-5.1.0.dist-info}/METADATA +1 -1
- sl_shared_assets-5.1.0.dist-info/RECORD +23 -0
- sl_shared_assets-5.0.1.dist-info/RECORD +0 -23
- {sl_shared_assets-5.0.1.dist-info → sl_shared_assets-5.1.0.dist-info}/WHEEL +0 -0
- {sl_shared_assets-5.0.1.dist-info → sl_shared_assets-5.1.0.dist-info}/entry_points.txt +0 -0
- {sl_shared_assets-5.0.1.dist-info → sl_shared_assets-5.1.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
"""This module
|
|
2
|
-
machines used to acquire, process, and store the data.
|
|
3
|
-
|
|
4
|
-
|
|
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."""
|
|
1
|
+
"""This module provides classes jointly responsible for maintaining the Sun lab project data hierarchy across all
|
|
2
|
+
machines used to acquire, process, and store the data. Primarily, classes from this module are used to manage the
|
|
3
|
+
access to the data acquired as part of a single data acquisition session in a thread-safe and location-agnostic
|
|
4
|
+
fashion."""
|
|
7
5
|
|
|
8
6
|
import copy
|
|
9
7
|
from enum import StrEnum
|
|
@@ -17,33 +15,32 @@ from ataraxis_data_structures import YamlConfig
|
|
|
17
15
|
from ataraxis_time.time_helpers import get_timestamp
|
|
18
16
|
|
|
19
17
|
from .configuration_data import AcquisitionSystems, get_system_configuration_data
|
|
18
|
+
from ..tools.transfer_tools import delete_directory
|
|
20
19
|
|
|
21
20
|
|
|
22
21
|
class SessionTypes(StrEnum):
|
|
23
|
-
"""
|
|
24
|
-
Sun lab.
|
|
22
|
+
"""Stores the data acquisition session types supported by all data acquisition systems used in the Sun lab.
|
|
25
23
|
|
|
26
|
-
A data acquisition session
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
A data acquisition session is typically carried out to acquire experiment data, train the animal for the upcoming
|
|
25
|
+
experiment sessions, or to assess the quality of surgical or other pre-experiment interventions. After acquisition,
|
|
26
|
+
the session is treated as a uniform package whose components can be accessed via the SessionData class.
|
|
29
27
|
|
|
30
28
|
Notes:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
enumeration.
|
|
29
|
+
Different acquisition systems support different session types and may not be suited for acquiring some of the
|
|
30
|
+
session types listed in this enumeration.
|
|
34
31
|
"""
|
|
35
32
|
|
|
36
33
|
LICK_TRAINING = "lick training"
|
|
37
|
-
"""Mesoscope-VR session designed to teach animals to use the water delivery port while being head-fixed."""
|
|
34
|
+
"""A Mesoscope-VR session designed to teach animals to use the water delivery port while being head-fixed."""
|
|
38
35
|
RUN_TRAINING = "run training"
|
|
39
|
-
"""Mesoscope-VR session designed to teach animals
|
|
36
|
+
"""A Mesoscope-VR session designed to teach animals to run on the treadmill while being head-fixed."""
|
|
40
37
|
MESOSCOPE_EXPERIMENT = "mesoscope experiment"
|
|
41
|
-
"""Mesoscope-VR experiment session. The session uses Unity game engine to run
|
|
42
|
-
|
|
38
|
+
"""A Mesoscope-VR experiment session. The session uses Unity game engine to run virtual reality tasks and collects
|
|
39
|
+
brain activity data using 2-Photon Random Access Mesoscope (2P-RAM)."""
|
|
43
40
|
WINDOW_CHECKING = "window checking"
|
|
44
|
-
"""A
|
|
45
|
-
|
|
46
|
-
activity data."""
|
|
41
|
+
"""A Mesoscope-VR session designed to evaluate the quality of the cranial window implantation procedure and the
|
|
42
|
+
suitability of the animal for being imaged with the Mesoscope. The session uses the Mesoscope to assess the quality
|
|
43
|
+
of the cell activity data."""
|
|
47
44
|
|
|
48
45
|
|
|
49
46
|
@dataclass()
|
|
@@ -247,18 +244,18 @@ class ProcessedData:
|
|
|
247
244
|
class TrackingData:
|
|
248
245
|
"""Stores the paths to the directories and files that make up the 'tracking_data' session-specific directory.
|
|
249
246
|
|
|
250
|
-
|
|
251
|
-
|
|
247
|
+
This directory was added in version 5.0.0 to store the ProcessingTracker files and .lock files for pipelines and
|
|
248
|
+
tasks used to work with session's data after acquisition.
|
|
252
249
|
"""
|
|
253
250
|
|
|
254
251
|
tracking_data_path: Path = Path()
|
|
255
252
|
"""Stores the path to the root tracking_data directory of the session. This directory stores the .yaml
|
|
256
253
|
ProcessingTracker files and the .lock FileLock files that jointly ensure that session's data is accessed in a
|
|
257
|
-
|
|
254
|
+
thread-safe way while being processed by multiple different processes and pipelines."""
|
|
258
255
|
session_lock_path: Path = Path()
|
|
259
|
-
"""Stores the path to the session_lock.yaml file
|
|
260
|
-
manager process has exclusive access to the session's data on the remote compute server. This
|
|
261
|
-
data processing pipelines
|
|
256
|
+
"""Stores the path to the session's session_lock.yaml file. This file is used to ensure that only a single
|
|
257
|
+
manager process has exclusive access to the session's data on the remote compute server. This allows multiple
|
|
258
|
+
data processing pipelines to safely run for the same session without compromising session data integrity. This
|
|
262
259
|
file is intended to be used through the SessionLock class."""
|
|
263
260
|
|
|
264
261
|
def resolve_paths(self, root_directory_path: Path) -> None:
|
|
@@ -289,17 +286,20 @@ class TrackingData:
|
|
|
289
286
|
class SessionData(YamlConfig):
|
|
290
287
|
"""Stores and manages the data layout of a single Sun lab data acquisition session.
|
|
291
288
|
|
|
292
|
-
The primary purpose of this class is to maintain the session data structure across all supported destinations
|
|
293
|
-
provide a unified data access interface shared by all Sun lab libraries.
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
289
|
+
The primary purpose of this class is to maintain the session data structure across all supported destinations
|
|
290
|
+
and to provide a unified data access interface shared by all Sun lab libraries. It is specifically designed for
|
|
291
|
+
working with the data from a single session, performed by a single animal under the specific project. The class is
|
|
292
|
+
used to manage both raw and processed data: it follows the data through acquisition, preprocessing, and processing
|
|
293
|
+
stages of the Sun lab data workflow. This class serves as an entry point for all interactions with the managed
|
|
294
|
+
session's data.
|
|
297
295
|
|
|
298
296
|
Notes:
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
297
|
+
The class is not designed to be instantiated directly. Instead, use the create() method to generate a new
|
|
298
|
+
session or load() method to access the data of an already existing session.
|
|
299
|
+
|
|
300
|
+
When the class is used to create a new session, it generates the new session's name using the current UTC
|
|
301
|
+
timestamp, accurate to microseconds. This ensures that each session 'name' is unique and preserves the overall
|
|
302
|
+
session order.
|
|
303
303
|
"""
|
|
304
304
|
|
|
305
305
|
project_name: str
|
|
@@ -370,10 +370,10 @@ class SessionData(YamlConfig):
|
|
|
370
370
|
project_name: str,
|
|
371
371
|
animal_id: str,
|
|
372
372
|
session_type: SessionTypes | str,
|
|
373
|
+
python_version: str,
|
|
374
|
+
sl_experiment_version: str,
|
|
373
375
|
experiment_name: str | None = None,
|
|
374
376
|
session_name: str | None = None,
|
|
375
|
-
python_version: str = "3.11.13",
|
|
376
|
-
sl_experiment_version: str = "2.0.0",
|
|
377
377
|
) -> "SessionData":
|
|
378
378
|
"""Creates a new SessionData object and generates the new session's data structure on the local PC.
|
|
379
379
|
|
|
@@ -394,6 +394,10 @@ class SessionData(YamlConfig):
|
|
|
394
394
|
animal_id: The ID code of the animal participating in the session.
|
|
395
395
|
session_type: The type of the session. Has to be one of the supported session types exposed by the
|
|
396
396
|
SessionTypes enumeration.
|
|
397
|
+
python_version: The string that specifies the Python version used to collect session data. Has to be
|
|
398
|
+
specified using the major.minor.patch version format.
|
|
399
|
+
sl_experiment_version: The string that specifies the version of the sl-experiment library used to collect
|
|
400
|
+
session data. Has to be specified using the major.minor.patch version format.
|
|
397
401
|
experiment_name: The name of the experiment executed during the session. This optional argument is only
|
|
398
402
|
used for experiment sessions. Note! The name passed to this argument has to match the name of the
|
|
399
403
|
experiment configuration .yaml file.
|
|
@@ -401,10 +405,6 @@ class SessionData(YamlConfig):
|
|
|
401
405
|
sessions. When provided, the method uses this name instead of generating a new timestamp-based name.
|
|
402
406
|
This is only used during the 'ascension' runtime to convert old data structures to the modern
|
|
403
407
|
lab standards.
|
|
404
|
-
python_version: The string that specifies the Python version used to collect session data. Has to be
|
|
405
|
-
specified using the major.minor.patch version format.
|
|
406
|
-
sl_experiment_version: The string that specifies the version of the sl-experiment library used to collect
|
|
407
|
-
session data. Has to be specified using the major.minor.patch version format.
|
|
408
408
|
|
|
409
409
|
Returns:
|
|
410
410
|
An initialized SessionData instance that stores the layout of the newly created session's data.
|
|
@@ -597,26 +597,53 @@ class SessionData(YamlConfig):
|
|
|
597
597
|
)
|
|
598
598
|
)
|
|
599
599
|
|
|
600
|
-
#
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
600
|
+
# If the processed data root is different from the raw data root, resolves the path to the 'source' and
|
|
601
|
+
# 'archive' data directories. Otherwise, uses the same paths as 'raw' and 'processed' data directories.
|
|
602
|
+
if processed_data_root != local_root:
|
|
603
|
+
# SOURCE DATA
|
|
604
|
+
instance.source_data.resolve_paths(
|
|
605
|
+
root_directory_path=processed_data_root.joinpath(
|
|
606
|
+
instance.project_name, instance.animal_id, instance.session_name, "source_data"
|
|
607
|
+
)
|
|
604
608
|
)
|
|
605
|
-
|
|
606
|
-
# Note, since source data is populated as part of the 'preparation' runtime, does not make the directories.
|
|
609
|
+
# Note, since source data is populated as part of the 'preparation' runtime, does not make the directories.
|
|
607
610
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
611
|
+
# ARCHIVED DATA
|
|
612
|
+
instance.archived_data.resolve_paths(
|
|
613
|
+
root_directory_path=local_root.joinpath(
|
|
614
|
+
instance.project_name, instance.animal_id, instance.session_name, "archived_data"
|
|
615
|
+
)
|
|
612
616
|
)
|
|
613
|
-
|
|
617
|
+
|
|
618
|
+
# If the session has been processed with the processed data root previously matching the raw data root,
|
|
619
|
+
# ensures that there is no 'processed_data' directory on the raw data root. In other words, ensures that
|
|
620
|
+
# the session data always has only a single copy of the 'processed_data' directory.
|
|
621
|
+
old_processed_data_path = local_root.joinpath(
|
|
622
|
+
instance.project_name, instance.animal_id, instance.session_name, "processed_data"
|
|
623
|
+
)
|
|
624
|
+
delete_directory(old_processed_data_path)
|
|
625
|
+
|
|
626
|
+
else:
|
|
627
|
+
# SOURCE DATA
|
|
628
|
+
instance.source_data.resolve_paths(
|
|
629
|
+
root_directory_path=processed_data_root.joinpath(
|
|
630
|
+
instance.project_name, instance.animal_id, instance.session_name, "raw_data"
|
|
631
|
+
)
|
|
632
|
+
)
|
|
633
|
+
|
|
634
|
+
# ARCHIVED DATA
|
|
635
|
+
instance.archived_data.resolve_paths(
|
|
636
|
+
root_directory_path=local_root.joinpath(
|
|
637
|
+
instance.project_name, instance.animal_id, instance.session_name, "processed_data"
|
|
638
|
+
)
|
|
639
|
+
)
|
|
640
|
+
|
|
614
641
|
# Similar to source_data, archived data is populated as part of the 'archiving' pipeline, so directories for
|
|
615
642
|
# this data are not resolved.
|
|
616
643
|
|
|
617
644
|
# If there is no archived processed data, ensures that processed data hierarchy exists.
|
|
618
645
|
if not instance.archived_data.processed_data_path.exists():
|
|
619
|
-
instance.processed_data.make_directories()
|
|
646
|
+
instance.processed_data.make_directories()
|
|
620
647
|
|
|
621
648
|
# TRACKING DATA
|
|
622
649
|
instance.tracking_data.resolve_paths(
|
|
@@ -671,11 +698,13 @@ class SessionData(YamlConfig):
|
|
|
671
698
|
class SessionLock(YamlConfig):
|
|
672
699
|
"""Provides thread-safe session locking to ensure exclusive access during data processing.
|
|
673
700
|
|
|
674
|
-
This class manages a lock file that tracks which manager process currently has exclusive access to a
|
|
675
|
-
It prevents race conditions when multiple manager processes attempt to modify session
|
|
701
|
+
This class manages a lock file that tracks which manager process currently has exclusive access to a data
|
|
702
|
+
acquisition session's data. It prevents race conditions when multiple manager processes attempt to modify session
|
|
703
|
+
data simultaneously. Primarily, this class is used on remote compute server(s).
|
|
676
704
|
|
|
677
|
-
|
|
678
|
-
|
|
705
|
+
Notes:
|
|
706
|
+
The lock owner is identified by a manager process ID, allowing distributed processing across
|
|
707
|
+
multiple jobs while maintaining data integrity.
|
|
679
708
|
"""
|
|
680
709
|
|
|
681
710
|
file_path: Path
|
|
@@ -712,7 +741,7 @@ class SessionLock(YamlConfig):
|
|
|
712
741
|
original.to_yaml(file_path=self.file_path)
|
|
713
742
|
|
|
714
743
|
def acquire(self, manager_id: int) -> None:
|
|
715
|
-
"""Acquires the session lock
|
|
744
|
+
"""Acquires the session access lock.
|
|
716
745
|
|
|
717
746
|
Args:
|
|
718
747
|
manager_id: The unique identifier of the manager process requesting the lock.
|
|
@@ -729,10 +758,11 @@ class SessionLock(YamlConfig):
|
|
|
729
758
|
# Checks if the session is already locked by another process
|
|
730
759
|
if self._manager_id != -1 and self._manager_id != manager_id:
|
|
731
760
|
message = (
|
|
732
|
-
f"
|
|
733
|
-
f"
|
|
734
|
-
f"{self._manager_id}
|
|
735
|
-
f"
|
|
761
|
+
f"Unable to acquire the {self.file_path.parents[1].name} session's lock for the manager with "
|
|
762
|
+
f"id {manager_id}. The lock file indicates that the lock is already held by the process with id "
|
|
763
|
+
f"{self._manager_id}, preventing other processes from interfacing with the session lock. Call the "
|
|
764
|
+
f"command that produced this error with the '--reset-tracker' flag to override this safety "
|
|
765
|
+
f"feature or wait for the lock to be released."
|
|
736
766
|
)
|
|
737
767
|
console.error(message=message, error=RuntimeError)
|
|
738
768
|
raise RuntimeError(message)
|
|
@@ -743,7 +773,7 @@ class SessionLock(YamlConfig):
|
|
|
743
773
|
self._save_state()
|
|
744
774
|
|
|
745
775
|
def release(self, manager_id: int) -> None:
|
|
746
|
-
"""Releases the session lock.
|
|
776
|
+
"""Releases the session access lock.
|
|
747
777
|
|
|
748
778
|
Args:
|
|
749
779
|
manager_id: The unique identifier of the manager process releasing the lock.
|
|
@@ -759,9 +789,9 @@ class SessionLock(YamlConfig):
|
|
|
759
789
|
|
|
760
790
|
if self._manager_id != manager_id:
|
|
761
791
|
message = (
|
|
762
|
-
f"Unable to release the session lock from the manager with
|
|
763
|
-
f"{
|
|
764
|
-
f"
|
|
792
|
+
f"Unable to release the {self.file_path.parents[1].name} session's lock from the manager with "
|
|
793
|
+
f"id {manager_id}. The lock file indicates that the lock is held by the process with id "
|
|
794
|
+
f"{self._manager_id}, preventing other processes from interfacing with the session lock."
|
|
765
795
|
)
|
|
766
796
|
console.error(message=message, error=RuntimeError)
|
|
767
797
|
raise RuntimeError(message) # Fallback to appease mypy, should not be reachable
|
|
@@ -771,10 +801,11 @@ class SessionLock(YamlConfig):
|
|
|
771
801
|
self._save_state()
|
|
772
802
|
|
|
773
803
|
def force_release(self) -> None:
|
|
774
|
-
"""Forcibly releases the lock regardless of ownership.
|
|
804
|
+
"""Forcibly releases the session access lock regardless of ownership.
|
|
775
805
|
|
|
776
|
-
This method should only be used for emergency recovery
|
|
777
|
-
to unlock
|
|
806
|
+
This method should only be used for emergency recovery from improper processing shutdowns. It can be called by
|
|
807
|
+
any process to unlock any session, but it does not attempt to terminate the processes that the lock's owner
|
|
808
|
+
might have deployed to work with the session's data.
|
|
778
809
|
|
|
779
810
|
Raises:
|
|
780
811
|
TimeoutError: If the .lock file cannot be acquired for a long period of time due to being held by another
|
|
@@ -782,32 +813,31 @@ class SessionLock(YamlConfig):
|
|
|
782
813
|
"""
|
|
783
814
|
lock = FileLock(self._lock_path)
|
|
784
815
|
with lock.acquire(timeout=10.0):
|
|
816
|
+
# Hard reset regardless of the current tracker state
|
|
785
817
|
self._manager_id = -1
|
|
786
818
|
self._save_state()
|
|
787
819
|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
"""Returns True if the session is currently locked by any process, False otherwise.
|
|
820
|
+
def check_owner(self, manager_id: int) -> None:
|
|
821
|
+
"""Ensures that the managed session is locked for processing by the specified manager process.
|
|
791
822
|
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
process.
|
|
795
|
-
"""
|
|
796
|
-
lock = FileLock(self._lock_path)
|
|
797
|
-
with lock.acquire(timeout=10.0):
|
|
798
|
-
self._load_state()
|
|
799
|
-
return self._manager_id != -1
|
|
823
|
+
This method is used by worker functions to ensure it is safe to interact with the session's data. It is designed
|
|
824
|
+
to abort the runtime with an error if the session's lock file is owned by a different manager process.
|
|
800
825
|
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
"""Returns the unique identifier of the manager process that holds the lock if the session is locked or None if
|
|
804
|
-
the session is unlocked.
|
|
826
|
+
Args:
|
|
827
|
+
manager_id: The unique identifier of the manager process attempting to access the session's data.
|
|
805
828
|
|
|
806
829
|
Raises:
|
|
807
830
|
TimeoutError: If the .lock file cannot be acquired for a long period of time due to being held by another
|
|
808
831
|
process.
|
|
832
|
+
ValueError: If the lock file is held by a different manager process.
|
|
809
833
|
"""
|
|
810
834
|
lock = FileLock(self._lock_path)
|
|
811
835
|
with lock.acquire(timeout=10.0):
|
|
812
836
|
self._load_state()
|
|
813
|
-
|
|
837
|
+
if self._manager_id != manager_id:
|
|
838
|
+
message = (
|
|
839
|
+
f"Unable to access the {self.file_path.parents[1].name} session's data from manager process "
|
|
840
|
+
f"{manager_id}, as the session is currently locked by another manager process with ID "
|
|
841
|
+
f"{self._manager_id}."
|
|
842
|
+
)
|
|
843
|
+
console.error(message=message, error=ValueError)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
"""This module provides
|
|
2
|
-
|
|
1
|
+
"""This module provides dataclasses used to store animal surgery data extracted from the Sun lab surgery log. Typically,
|
|
2
|
+
this is done as part of every data acquisition session to ensure that runtime and surgical intervention data is always
|
|
3
|
+
kept together and available for analysis."""
|
|
3
4
|
|
|
4
5
|
from dataclasses import dataclass
|
|
5
6
|
|
|
@@ -8,13 +9,13 @@ from ataraxis_data_structures import YamlConfig
|
|
|
8
9
|
|
|
9
10
|
@dataclass()
|
|
10
11
|
class SubjectData:
|
|
11
|
-
"""Stores the
|
|
12
|
+
"""Stores information about the subject of the surgical intervention (animal)."""
|
|
12
13
|
|
|
13
14
|
id: int
|
|
14
15
|
"""Stores the unique ID (name) of the subject. Assumes all animals are given a numeric ID, rather than a string
|
|
15
16
|
name."""
|
|
16
17
|
ear_punch: str
|
|
17
|
-
"""Stores the
|
|
18
|
+
"""Stores the location and the number of ear-tags used to distinguish teh animal from its cage-mates."""
|
|
18
19
|
sex: str
|
|
19
20
|
"""Stores the gender of the subject."""
|
|
20
21
|
genotype: str
|
|
@@ -22,26 +23,26 @@ class SubjectData:
|
|
|
22
23
|
date_of_birth_us: int
|
|
23
24
|
"""Stores the date of birth of the subject as the number of microseconds elapsed since UTC epoch onset."""
|
|
24
25
|
weight_g: float
|
|
25
|
-
"""Stores the weight of the subject
|
|
26
|
+
"""Stores the pre-surgery weight of the subject, in grams."""
|
|
26
27
|
cage: int
|
|
27
|
-
"""Stores the number
|
|
28
|
+
"""Stores the unique identifier (number) for the cage used to house the subject after surgery."""
|
|
28
29
|
location_housed: str
|
|
29
|
-
"""Stores the location used to house the subject
|
|
30
|
+
"""Stores the location (room) used to house the subject."""
|
|
30
31
|
status: str
|
|
31
32
|
"""Stores the current status of the subject (alive / deceased)."""
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
@dataclass()
|
|
35
36
|
class ProcedureData:
|
|
36
|
-
"""Stores
|
|
37
|
+
"""Stores general information about the surgical intervention."""
|
|
37
38
|
|
|
38
39
|
surgery_start_us: int
|
|
39
|
-
"""Stores the date and time
|
|
40
|
+
"""Stores the surgery's start date and time as microseconds elapsed since UTC epoch onset."""
|
|
40
41
|
surgery_end_us: int
|
|
41
|
-
"""Stores the date and time
|
|
42
|
+
"""Stores the surgery's stop date and time as microseconds elapsed since UTC epoch onset."""
|
|
42
43
|
surgeon: str
|
|
43
|
-
"""Stores the name or ID of the surgeon. If the intervention was carried out by multiple surgeons,
|
|
44
|
-
|
|
44
|
+
"""Stores the name or ID of the surgeon. If the intervention was carried out by multiple surgeons, the data
|
|
45
|
+
for all participants is stored as part of the same string."""
|
|
45
46
|
protocol: str
|
|
46
47
|
"""Stores the experiment protocol number (ID) used during the surgery."""
|
|
47
48
|
surgery_notes: str
|
|
@@ -50,60 +51,60 @@ class ProcedureData:
|
|
|
50
51
|
"""Stores surgeon's notes taken during the post-surgery recovery period."""
|
|
51
52
|
surgery_quality: int = 0
|
|
52
53
|
"""Stores the quality of the surgical intervention as a numeric level. 0 indicates unusable (bad) result, 1
|
|
53
|
-
indicates usable result that
|
|
54
|
+
indicates usable result that does not meet the publication threshold, 2 indicates publication-grade
|
|
54
55
|
result, 3 indicates high-tier publication grade result."""
|
|
55
56
|
|
|
56
57
|
|
|
57
58
|
@dataclass
|
|
58
59
|
class ImplantData:
|
|
59
|
-
"""Stores
|
|
60
|
+
"""Stores information about a single implantation procedure performed during the surgical intervention.
|
|
60
61
|
|
|
61
|
-
Multiple ImplantData instances
|
|
62
|
+
Multiple ImplantData instances can be used at the same time if the surgery involves multiple implants.
|
|
62
63
|
"""
|
|
63
64
|
|
|
64
65
|
implant: str
|
|
65
|
-
"""
|
|
66
|
+
"""Stores the descriptive name of the implant."""
|
|
66
67
|
implant_target: str
|
|
67
|
-
"""
|
|
68
|
+
"""Stores the name of the brain region or cranium section targeted by the implant."""
|
|
68
69
|
implant_code: str
|
|
69
|
-
"""
|
|
70
|
-
additional datasheets and lab ordering documents."""
|
|
70
|
+
"""Stores the manufacturer code or internal reference code for the implant. This code is used to identify the
|
|
71
|
+
implant in additional datasheets and lab ordering documents."""
|
|
71
72
|
implant_ap_coordinate_mm: float
|
|
72
|
-
"""Stores implant's antero-posterior stereotactic coordinate, in millimeters, relative to bregma."""
|
|
73
|
+
"""Stores the implant's antero-posterior stereotactic coordinate, in millimeters, relative to bregma."""
|
|
73
74
|
implant_ml_coordinate_mm: float
|
|
74
|
-
"""Stores implant's medial-lateral stereotactic coordinate, in millimeters, relative to bregma."""
|
|
75
|
+
"""Stores the implant's medial-lateral stereotactic coordinate, in millimeters, relative to bregma."""
|
|
75
76
|
implant_dv_coordinate_mm: float
|
|
76
|
-
"""Stores implant's dorsal-ventral stereotactic coordinate, in millimeters, relative to bregma."""
|
|
77
|
+
"""Stores the implant's dorsal-ventral stereotactic coordinate, in millimeters, relative to bregma."""
|
|
77
78
|
|
|
78
79
|
|
|
79
80
|
@dataclass
|
|
80
81
|
class InjectionData:
|
|
81
|
-
"""Stores
|
|
82
|
+
"""Stores information about a single injection performed during the surgical intervention.
|
|
82
83
|
|
|
83
|
-
Multiple InjectionData instances
|
|
84
|
+
Multiple InjectionData instances can be used at the same time if the surgery involves multiple injections.
|
|
84
85
|
"""
|
|
85
86
|
|
|
86
87
|
injection: str
|
|
87
|
-
"""
|
|
88
|
+
"""Stores the descriptive name of the injection."""
|
|
88
89
|
injection_target: str
|
|
89
|
-
"""
|
|
90
|
+
"""Stores the name of the brain region targeted by the injection."""
|
|
90
91
|
injection_volume_nl: float
|
|
91
|
-
"""
|
|
92
|
+
"""Stores the volume of substance, in nanoliters, delivered during the injection."""
|
|
92
93
|
injection_code: str
|
|
93
|
-
"""
|
|
94
|
-
substance in additional datasheets and lab ordering documents."""
|
|
94
|
+
"""Stores the manufacturer code or internal reference code for the injected substance. This code is used to
|
|
95
|
+
identify the substance in additional datasheets and lab ordering documents."""
|
|
95
96
|
injection_ap_coordinate_mm: float
|
|
96
|
-
"""Stores injection's antero-posterior stereotactic coordinate, in millimeters, relative to bregma."""
|
|
97
|
+
"""Stores the injection's antero-posterior stereotactic coordinate, in millimeters, relative to bregma."""
|
|
97
98
|
injection_ml_coordinate_mm: float
|
|
98
|
-
"""Stores injection's medial-lateral stereotactic coordinate, in millimeters, relative to bregma."""
|
|
99
|
+
"""Stores the injection's medial-lateral stereotactic coordinate, in millimeters, relative to bregma."""
|
|
99
100
|
injection_dv_coordinate_mm: float
|
|
100
|
-
"""Stores injection's dorsal-ventral stereotactic coordinate, in millimeters, relative to bregma."""
|
|
101
|
+
"""Stores the injection's dorsal-ventral stereotactic coordinate, in millimeters, relative to bregma."""
|
|
101
102
|
|
|
102
103
|
|
|
103
104
|
@dataclass
|
|
104
105
|
class DrugData:
|
|
105
|
-
"""Stores the information about all drugs administered to the subject before, during, and
|
|
106
|
-
surgical intervention.
|
|
106
|
+
"""Stores the information about all medical substances (drugs) administered to the subject before, during, and
|
|
107
|
+
immediately after the surgical intervention.
|
|
107
108
|
"""
|
|
108
109
|
|
|
109
110
|
lactated_ringers_solution_volume_ml: float
|
|
@@ -130,23 +131,22 @@ class DrugData:
|
|
|
130
131
|
|
|
131
132
|
@dataclass
|
|
132
133
|
class SurgeryData(YamlConfig):
|
|
133
|
-
"""Stores the data about
|
|
134
|
+
"""Stores the data about the surgical intervention performed on an animal before data acquisition session(s).
|
|
134
135
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
during the session.
|
|
136
|
+
Primarily, this class is used to ensure that each data acquisition session contains a copy of the surgical
|
|
137
|
+
intervention data as a .yaml file. In turn, this improves the experimenter's experience during data analysis by
|
|
138
|
+
allowing quickly referencing the surgical intervention data.
|
|
139
139
|
"""
|
|
140
140
|
|
|
141
141
|
subject: SubjectData
|
|
142
|
-
"""Stores
|
|
142
|
+
"""Stores information about the subject (mouse)."""
|
|
143
143
|
procedure: ProcedureData
|
|
144
|
-
"""Stores general
|
|
144
|
+
"""Stores general information about the surgical intervention."""
|
|
145
145
|
drugs: DrugData
|
|
146
|
-
"""Stores
|
|
146
|
+
"""Stores information about the medical substances administered to the subject before, during, and immediately
|
|
147
147
|
after the surgical intervention."""
|
|
148
148
|
implants: list[ImplantData]
|
|
149
|
-
"""Stores
|
|
149
|
+
"""Stores information about cranial and transcranial implants introduced to the subject as part of the surgical
|
|
150
150
|
intervention."""
|
|
151
151
|
injections: list[InjectionData]
|
|
152
|
-
"""Stores
|
|
152
|
+
"""Stores information about substances infused into the brain of the subject as part the surgical intervention."""
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"""This package provides the classes and methods used by all Sun lab libraries to work with the data stored on remote
|
|
2
|
-
compute servers
|
|
3
|
-
processing pipelines and interactively working with the data via a Jupyter lab server."""
|
|
2
|
+
compute servers."""
|
|
4
3
|
|
|
5
4
|
from .job import Job, JupyterJob
|
|
6
5
|
from .server import Server, ServerCredentials, generate_server_credentials
|