sl-shared-assets 1.0.0rc5__py3-none-any.whl → 1.0.0rc7__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/data_classes.py +78 -41
- sl_shared_assets/data_classes.pyi +24 -5
- {sl_shared_assets-1.0.0rc5.dist-info → sl_shared_assets-1.0.0rc7.dist-info}/METADATA +1 -1
- {sl_shared_assets-1.0.0rc5.dist-info → sl_shared_assets-1.0.0rc7.dist-info}/RECORD +7 -7
- {sl_shared_assets-1.0.0rc5.dist-info → sl_shared_assets-1.0.0rc7.dist-info}/WHEEL +0 -0
- {sl_shared_assets-1.0.0rc5.dist-info → sl_shared_assets-1.0.0rc7.dist-info}/entry_points.txt +0 -0
- {sl_shared_assets-1.0.0rc5.dist-info → sl_shared_assets-1.0.0rc7.dist-info}/licenses/LICENSE +0 -0
sl_shared_assets/data_classes.py
CHANGED
|
@@ -87,7 +87,7 @@ class ProjectConfiguration(YamlConfig):
|
|
|
87
87
|
local_root_directory: str | Path = Path("/media/Data/Experiments")
|
|
88
88
|
"""The absolute path to the root directory where all projects are stored on the local host-machine (VRPC). Note,
|
|
89
89
|
overwriting the value of this field is pointless, as it is automatically set each time the class is instantiated."""
|
|
90
|
-
local_server_directory: str | Path = Path("/
|
|
90
|
+
local_server_directory: str | Path = Path("/home/cybermouse/server/storage/sun_data")
|
|
91
91
|
"""The absolute path to the locally-mapped (via SMB protocol) root BioHPC server machine directory where to store
|
|
92
92
|
all projects."""
|
|
93
93
|
local_nas_directory: str | Path = Path("/home/cybermouse/nas/rawdata")
|
|
@@ -205,12 +205,9 @@ class ProjectConfiguration(YamlConfig):
|
|
|
205
205
|
with open(path_file, "w") as f:
|
|
206
206
|
f.write(str(root_path))
|
|
207
207
|
|
|
208
|
-
#
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
# Reads the root path from the file
|
|
212
|
-
with open(path_file, "r") as f:
|
|
213
|
-
root_path = Path(f.read().strip())
|
|
208
|
+
# Once the location of the path storage file is resolved, reads the root path from the file
|
|
209
|
+
with open(path_file, "r") as f:
|
|
210
|
+
root_path = Path(f.read().strip())
|
|
214
211
|
|
|
215
212
|
# Uses the root experiment directory path to generate the path to the target project's configuration file.
|
|
216
213
|
configuration_path = root_path.joinpath(project_name, "configuration", "project_configuration.yaml")
|
|
@@ -459,8 +456,8 @@ class RawData:
|
|
|
459
456
|
|
|
460
457
|
This service method is used by the SessionData class to convert all paths in this class to be relative to the
|
|
461
458
|
new root. This is used to adjust the SessionData instance to work for the VRPC (one root) or the BioHPC server
|
|
462
|
-
(another root).
|
|
463
|
-
|
|
459
|
+
(another root). This method is only implemented for subclasses intended to be used both locally and on the
|
|
460
|
+
BioHPC server.
|
|
464
461
|
|
|
465
462
|
Args:
|
|
466
463
|
new_root: The new root directory to use for all paths inside the instance. This has to be the path to the
|
|
@@ -494,15 +491,20 @@ class ProcessedData:
|
|
|
494
491
|
"""Stores the paths to the directories and files that make up the 'processed_data' session directory.
|
|
495
492
|
|
|
496
493
|
The processed_data directory stores the processed session data, which is generated by running various processing
|
|
497
|
-
pipelines
|
|
498
|
-
|
|
499
|
-
|
|
494
|
+
pipelines. These pipelines use raw data to generate processed data, which represents an intermediate step between
|
|
495
|
+
raw data and the dataset used in the data analysis.
|
|
496
|
+
|
|
497
|
+
Notes:
|
|
498
|
+
The paths from this section are typically used only on the BioHPC server. This is because most data processing
|
|
499
|
+
in the lab is performed using the processing server's resources. On the server, processed data is stored on
|
|
500
|
+
the fast volume, in contrast to raw data, which is stored on the slow volume. However, to support local testing,
|
|
501
|
+
the class resolves the paths in this section both locally and globally (on the server).
|
|
502
|
+
|
|
500
503
|
"""
|
|
501
504
|
|
|
502
505
|
processed_data_path: str | Path
|
|
503
506
|
"""Stores the path to the root processed_data directory of the session. This directory stores the processed data
|
|
504
|
-
as it is generated by various
|
|
505
|
-
server and is not intended to be used directly for data analysis."""
|
|
507
|
+
as it is generated by various data processing pipelines."""
|
|
506
508
|
camera_data_path: str | Path
|
|
507
509
|
"""Stores the output of the DeepLabCut pose estimation pipeline."""
|
|
508
510
|
mesoscope_data_path: str | Path
|
|
@@ -556,6 +558,29 @@ class ProcessedData:
|
|
|
556
558
|
ensure_directory_exists(Path(self.deeplabcut_root_path))
|
|
557
559
|
ensure_directory_exists(Path(self.suite2p_configuration_path))
|
|
558
560
|
|
|
561
|
+
def switch_root(self, new_root: Path) -> None:
|
|
562
|
+
"""Changes the root of the managed processed_data directory to the provided root path.
|
|
563
|
+
|
|
564
|
+
This service method is used by the SessionData class to convert all paths in this class to be relative to the
|
|
565
|
+
new root. This is used to adjust the SessionData instance to work for the VRPC (one root) or the BioHPC server
|
|
566
|
+
(another root). This method is only implemented for subclasses intended to be used both locally and on the
|
|
567
|
+
BioHPC server.
|
|
568
|
+
|
|
569
|
+
Args:
|
|
570
|
+
new_root: The new root directory to use for all paths inside the instance. This has to be the path to the
|
|
571
|
+
root session directory: pc_root/project/animal/session.
|
|
572
|
+
"""
|
|
573
|
+
# Gets current root from the processed_data_path.
|
|
574
|
+
old_root = Path(self.processed_data_path).parents[2]
|
|
575
|
+
|
|
576
|
+
# Updates all paths by replacing old_root with new_root
|
|
577
|
+
self.processed_data_path = new_root.joinpath(Path(self.processed_data_path).relative_to(old_root))
|
|
578
|
+
self.camera_data_path = new_root.joinpath(Path(self.camera_data_path).relative_to(old_root))
|
|
579
|
+
self.mesoscope_data_path = new_root.joinpath(Path(self.mesoscope_data_path).relative_to(old_root))
|
|
580
|
+
self.behavior_data_path = new_root.joinpath(Path(self.behavior_data_path).relative_to(old_root))
|
|
581
|
+
self.deeplabcut_root_path = new_root.joinpath(Path(self.deeplabcut_root_path).relative_to(old_root))
|
|
582
|
+
self.suite2p_configuration_path = new_root.joinpath(Path(self.suite2p_configuration_path).relative_to(old_root))
|
|
583
|
+
|
|
559
584
|
|
|
560
585
|
@dataclass()
|
|
561
586
|
class PersistentData:
|
|
@@ -735,7 +760,7 @@ class SessionData(YamlConfig):
|
|
|
735
760
|
"""Stores the name (timestamp-based ID) of the managed session."""
|
|
736
761
|
session_type: str
|
|
737
762
|
"""Stores the type of the session. Primarily, this determines how to read the session_descriptor.yaml file. Has
|
|
738
|
-
to be set to one of the
|
|
763
|
+
to be set to one of the four supported types: 'Lick training', 'Run training', 'Window checking' or 'Experiment'.
|
|
739
764
|
"""
|
|
740
765
|
experiment_name: str | None
|
|
741
766
|
"""Stores the name of the experiment configuration file. If the session_type field is set to 'Experiment', this
|
|
@@ -747,8 +772,9 @@ class SessionData(YamlConfig):
|
|
|
747
772
|
class initialization location (VRPC or BioHPC server), the class automatically resolves the root directory path to
|
|
748
773
|
either the VRPC project directory or the BioHPC cluster storage volume."""
|
|
749
774
|
processed_data: ProcessedData
|
|
750
|
-
"""Stores the paths to various directories used to store processed session data.
|
|
751
|
-
resolved
|
|
775
|
+
"""Stores the paths to various directories used to store processed session data. Note, when this section is
|
|
776
|
+
resolved for VRPC, it uses the same local session directory as the raw_data folder. When this is resolved for the
|
|
777
|
+
BioHPC server, it uses the 'fast' volume path."""
|
|
752
778
|
persistent_data: PersistentData
|
|
753
779
|
"""Stores the paths to various files and directories kept on VRPC and ScanImagePC after the session data is
|
|
754
780
|
transferred to long-term storage destinations."""
|
|
@@ -806,16 +832,11 @@ class SessionData(YamlConfig):
|
|
|
806
832
|
biohpc_root = Path(project_configuration.local_server_directory)
|
|
807
833
|
nas_root = Path(project_configuration.local_nas_directory)
|
|
808
834
|
|
|
809
|
-
# Also extracts the path to fast (working) directory on the BioHPC server. This is used to configure the
|
|
810
|
-
# paths for data processing, which happens on the server.
|
|
811
|
-
biohpc_workdir = Path(project_configuration.remote_working_directory)
|
|
812
|
-
|
|
813
835
|
# Extracts the name of the project stored inside the project configuration file.
|
|
814
836
|
project_name = project_configuration.project_name
|
|
815
837
|
|
|
816
838
|
# Constructs the session directory path and generates the directory
|
|
817
839
|
session_path = vrpc_root.joinpath(project_name, animal_id, session_name)
|
|
818
|
-
remote_session_path = biohpc_workdir.joinpath(project_name, animal_id, session_name)
|
|
819
840
|
|
|
820
841
|
# Handles potential session name conflicts
|
|
821
842
|
counter = 0
|
|
@@ -823,7 +844,6 @@ class SessionData(YamlConfig):
|
|
|
823
844
|
counter += 1
|
|
824
845
|
new_session_name = f"{session_name}_{counter}"
|
|
825
846
|
session_path = vrpc_root.joinpath(project_name, animal_id, new_session_name)
|
|
826
|
-
remote_session_path = biohpc_workdir.joinpath(project_name, animal_id, new_session_name)
|
|
827
847
|
|
|
828
848
|
# If a conflict is detected and resolved, warns the user about the resolved conflict.
|
|
829
849
|
if counter > 0:
|
|
@@ -854,14 +874,12 @@ class SessionData(YamlConfig):
|
|
|
854
874
|
raw_data.make_dirs() # Generates the local directory tree
|
|
855
875
|
|
|
856
876
|
processed_data = ProcessedData(
|
|
857
|
-
processed_data_path=
|
|
858
|
-
camera_data_path=
|
|
859
|
-
mesoscope_data_path=
|
|
860
|
-
behavior_data_path=
|
|
861
|
-
deeplabcut_root_path=
|
|
862
|
-
suite2p_configuration_path=
|
|
863
|
-
project_name, "configuration", "suite2p_configuration.yaml"
|
|
864
|
-
),
|
|
877
|
+
processed_data_path=session_path.joinpath("processed_data"),
|
|
878
|
+
camera_data_path=session_path.joinpath("processed_data", "camera_data"),
|
|
879
|
+
mesoscope_data_path=session_path.joinpath("processed_data", "mesoscope_data"),
|
|
880
|
+
behavior_data_path=session_path.joinpath("processed_data", "behavior_data"),
|
|
881
|
+
deeplabcut_root_path=vrpc_root.joinpath(project_name, "deeplabcut"),
|
|
882
|
+
suite2p_configuration_path=vrpc_root.joinpath(project_name, "configuration", "suite2p_configuration.yaml"),
|
|
865
883
|
)
|
|
866
884
|
|
|
867
885
|
vrpc_persistent_path = vrpc_root.joinpath(project_name, animal_id, "persistent_data")
|
|
@@ -968,17 +986,32 @@ class SessionData(YamlConfig):
|
|
|
968
986
|
# Loads class data from .yaml
|
|
969
987
|
instance: SessionData = cls.from_yaml(file_path=session_path) # type: ignore
|
|
970
988
|
|
|
971
|
-
#
|
|
972
|
-
#
|
|
973
|
-
#
|
|
974
|
-
#
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
989
|
+
# The method assumes that the 'donor' .yaml file is always stored inside the raw_data directory of the session
|
|
990
|
+
# to be processed. Since the directory itself might have moved (between or even within the same PC) relative to
|
|
991
|
+
# where it was when the SessionData snapshot was generated, reconfigures the paths to all raw_data files using
|
|
992
|
+
# the root from above.
|
|
993
|
+
instance.raw_data.switch_root(new_root=session_path)
|
|
994
|
+
|
|
995
|
+
# Resolves the paths to the processed_data directories. The resolution strategy depends on whether the method is
|
|
996
|
+
# called on the VRPC (locally) or the BioHPC server (remotely).
|
|
997
|
+
if not on_server:
|
|
998
|
+
# Local runtimes use the same root session directory for both raw_data and processed_data. This stems from
|
|
999
|
+
# the assumption that most local machines in the lab only use NVME (fast) volumes and, therefore, do not
|
|
1000
|
+
# need to separate 'storage' and 'working' data.
|
|
1001
|
+
instance.processed_data.switch_root(new_root=session_path)
|
|
1002
|
+
|
|
1003
|
+
else:
|
|
1004
|
+
# The BioHPC server stores raw_data on slow volume and processed_data on fast (NVME) volume. Therefore, to
|
|
1005
|
+
# configure processed_data paths, the method first needs to load the fast volume root path from the
|
|
1006
|
+
# project_configuration.yaml file stored in the raw_data folder.
|
|
1007
|
+
project_configuration: ProjectConfiguration = ProjectConfiguration.load(
|
|
1008
|
+
project_name=instance.project_name,
|
|
1009
|
+
configuration_path=Path(instance.raw_data.project_configuration_path),
|
|
1010
|
+
)
|
|
1011
|
+
instance.processed_data.switch_root(new_root=Path(project_configuration.remote_working_directory))
|
|
978
1012
|
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
instance.processed_data.make_dirs()
|
|
1013
|
+
# Generates processed_data directories
|
|
1014
|
+
instance.processed_data.make_dirs()
|
|
982
1015
|
|
|
983
1016
|
# Returns the initialized SessionData instance to caller
|
|
984
1017
|
return instance
|
|
@@ -1331,6 +1364,10 @@ class ProcedureData:
|
|
|
1331
1364
|
"""Stores surgeon's notes taken during the surgery."""
|
|
1332
1365
|
post_op_notes: str
|
|
1333
1366
|
"""Stores surgeon's notes taken during the post-surgery recovery period."""
|
|
1367
|
+
surgery_quality: int = 0
|
|
1368
|
+
"""Stores the quality of the surgical intervention as a numeric level. 0 indicates unusable (bad) result, 1
|
|
1369
|
+
indicates usable result that is not good enough to be included in a publication, 2 indicates publication-grade
|
|
1370
|
+
result."""
|
|
1334
1371
|
|
|
1335
1372
|
|
|
1336
1373
|
@dataclass
|
|
@@ -163,8 +163,8 @@ class RawData:
|
|
|
163
163
|
|
|
164
164
|
This service method is used by the SessionData class to convert all paths in this class to be relative to the
|
|
165
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).
|
|
167
|
-
|
|
166
|
+
(another root). This method is only implemented for subclasses intended to be used both locally and on the
|
|
167
|
+
BioHPC server.
|
|
168
168
|
|
|
169
169
|
Args:
|
|
170
170
|
new_root: The new root directory to use for all paths inside the instance. This has to be the path to the
|
|
@@ -176,9 +176,15 @@ class ProcessedData:
|
|
|
176
176
|
"""Stores the paths to the directories and files that make up the 'processed_data' session directory.
|
|
177
177
|
|
|
178
178
|
The processed_data directory stores the processed session data, which is generated by running various processing
|
|
179
|
-
pipelines
|
|
180
|
-
|
|
181
|
-
|
|
179
|
+
pipelines. These pipelines use raw data to generate processed data, which represents an intermediate step between
|
|
180
|
+
raw data and the dataset used in the data analysis.
|
|
181
|
+
|
|
182
|
+
Notes:
|
|
183
|
+
The paths from this section are typically used only on the BioHPC server. This is because most data processing
|
|
184
|
+
in the lab is performed using the processing server's resources. On the server, processed data is stored on
|
|
185
|
+
the fast volume, in contrast to raw data, which is stored on the slow volume. However, to support local testing,
|
|
186
|
+
the class resolves the paths in this section both locally and globally (on the server).
|
|
187
|
+
|
|
182
188
|
"""
|
|
183
189
|
|
|
184
190
|
processed_data_path: str | Path
|
|
@@ -203,6 +209,18 @@ class ProcessedData:
|
|
|
203
209
|
This method is used by the BioHPC server to generate the processed_data directory as part of the sl-forgery
|
|
204
210
|
library runtime.
|
|
205
211
|
"""
|
|
212
|
+
def switch_root(self, new_root: Path) -> None:
|
|
213
|
+
"""Changes the root of the managed processed_data directory to the provided root path.
|
|
214
|
+
|
|
215
|
+
This service method is used by the SessionData class to convert all paths in this class to be relative to the
|
|
216
|
+
new root. This is used to adjust the SessionData instance to work for the VRPC (one root) or the BioHPC server
|
|
217
|
+
(another root). This method is only implemented for subclasses intended to be used both locally and on the
|
|
218
|
+
BioHPC server.
|
|
219
|
+
|
|
220
|
+
Args:
|
|
221
|
+
new_root: The new root directory to use for all paths inside the instance. This has to be the path to the
|
|
222
|
+
root session directory: pc_root/project/animal/session.
|
|
223
|
+
"""
|
|
206
224
|
|
|
207
225
|
@dataclass()
|
|
208
226
|
class PersistentData:
|
|
@@ -586,6 +604,7 @@ class ProcedureData:
|
|
|
586
604
|
protocol: str
|
|
587
605
|
surgery_notes: str
|
|
588
606
|
post_op_notes: str
|
|
607
|
+
surgery_quality: int = ...
|
|
589
608
|
|
|
590
609
|
@dataclass
|
|
591
610
|
class ImplantData:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sl-shared-assets
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.0rc7
|
|
4
4
|
Summary: Stores assets shared between multiple Sun (NeuroAI) lab data pipelines.
|
|
5
5
|
Project-URL: Homepage, https://github.com/Sun-Lab-NBB/sl-shared-assets
|
|
6
6
|
Project-URL: Documentation, https://sl-shared-assets-api-docs.netlify.app/
|
|
@@ -2,8 +2,8 @@ sl_shared_assets/__init__.py,sha256=V7EvTTSB_GhetCbyYPg2RoiG1etDVeML5EBWgGvUo7E,
|
|
|
2
2
|
sl_shared_assets/__init__.pyi,sha256=U5Sma4zenITe0-eI_heTUYh_9P0puhgM3hAdcf-qozk,2532
|
|
3
3
|
sl_shared_assets/cli.py,sha256=CjfuXXj7CeDA2pbCwe5Rad6RDjIqGDud14IUDMdzx_w,2639
|
|
4
4
|
sl_shared_assets/cli.pyi,sha256=X5UdXpkzUw71_ftaIXMsnttIeR15SPVLiECuPge_zw8,1032
|
|
5
|
-
sl_shared_assets/data_classes.py,sha256=
|
|
6
|
-
sl_shared_assets/data_classes.pyi,sha256=
|
|
5
|
+
sl_shared_assets/data_classes.py,sha256=sHCnoJQLobW0YYFTqzNPSalG4NJzay-P_NCcsfE5W3Q,86887
|
|
6
|
+
sl_shared_assets/data_classes.pyi,sha256=5l2snWnlqTXGiJldGLvI4sc2G2_08aw9bFIOi_RmgjE,32240
|
|
7
7
|
sl_shared_assets/packaging_tools.py,sha256=3kAXFK37Lv4JA1YhjcoBz1x2Ell8ObCqe9pwxAts4m4,6709
|
|
8
8
|
sl_shared_assets/packaging_tools.pyi,sha256=hlAP9AxF7NHtFIPKjj5ehm8Vr9qIn6xDk4VvL0JuAmk,3055
|
|
9
9
|
sl_shared_assets/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -13,8 +13,8 @@ sl_shared_assets/suite2p.py,sha256=sQ5Zj0TJFD-gUHqtWnRvapBpr8QgmaiVil123cWxGxc,2
|
|
|
13
13
|
sl_shared_assets/suite2p.pyi,sha256=Uyv8ov--etwJIc6e2UVgs0jYXwnK2CD-kICfXo5KpcI,6331
|
|
14
14
|
sl_shared_assets/transfer_tools.py,sha256=J26kwOp_NpPSY0-xu5FTw9udte-rm_mW1FJyaTNoqQI,6606
|
|
15
15
|
sl_shared_assets/transfer_tools.pyi,sha256=FoH7eYZe7guGHfPr0MK5ggO62uXKwD2aJ7h1Bu7PaEE,3294
|
|
16
|
-
sl_shared_assets-1.0.
|
|
17
|
-
sl_shared_assets-1.0.
|
|
18
|
-
sl_shared_assets-1.0.
|
|
19
|
-
sl_shared_assets-1.0.
|
|
20
|
-
sl_shared_assets-1.0.
|
|
16
|
+
sl_shared_assets-1.0.0rc7.dist-info/METADATA,sha256=m3P5OiLBjasw8vyCUCe6Fr_04xHhXzdQF9Q7HkY31xc,47806
|
|
17
|
+
sl_shared_assets-1.0.0rc7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
18
|
+
sl_shared_assets-1.0.0rc7.dist-info/entry_points.txt,sha256=3VPr5RkWBkusNN9OhWXtC-DN0utu7uMrUulazIK2VNA,166
|
|
19
|
+
sl_shared_assets-1.0.0rc7.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
20
|
+
sl_shared_assets-1.0.0rc7.dist-info/RECORD,,
|
|
File without changes
|
{sl_shared_assets-1.0.0rc5.dist-info → sl_shared_assets-1.0.0rc7.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{sl_shared_assets-1.0.0rc5.dist-info → sl_shared_assets-1.0.0rc7.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|