sl-shared-assets 1.0.0rc13__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.
- sl_shared_assets/__init__.py +27 -9
- sl_shared_assets/__init__.pyi +71 -0
- sl_shared_assets/cli.py +13 -14
- sl_shared_assets/cli.pyi +28 -0
- sl_shared_assets/data_classes/__init__.py +63 -0
- sl_shared_assets/data_classes/__init__.pyi +61 -0
- sl_shared_assets/data_classes/configuration_data.py +64 -0
- sl_shared_assets/data_classes/configuration_data.pyi +37 -0
- sl_shared_assets/data_classes/runtime_data.py +233 -0
- sl_shared_assets/data_classes/runtime_data.pyi +145 -0
- sl_shared_assets/data_classes/session_data.py +1275 -0
- sl_shared_assets/data_classes/session_data.pyi +527 -0
- sl_shared_assets/data_classes/surgery_data.py +152 -0
- sl_shared_assets/data_classes/surgery_data.pyi +89 -0
- sl_shared_assets/server/__init__.py +8 -0
- sl_shared_assets/server/__init__.pyi +8 -0
- sl_shared_assets/server/job.py +140 -0
- sl_shared_assets/server/job.pyi +94 -0
- sl_shared_assets/server/server.py +213 -0
- sl_shared_assets/server/server.pyi +95 -0
- sl_shared_assets/suite2p/__init__.py +8 -0
- sl_shared_assets/suite2p/__init__.pyi +4 -0
- sl_shared_assets/suite2p/multi_day.py +193 -0
- sl_shared_assets/suite2p/multi_day.pyi +99 -0
- sl_shared_assets/{suite2p.py → suite2p/single_day.py} +55 -32
- sl_shared_assets/suite2p/single_day.pyi +192 -0
- sl_shared_assets/tools/__init__.py +8 -0
- sl_shared_assets/tools/__init__.pyi +5 -0
- sl_shared_assets/{ascension_tools.py → tools/ascension_tools.py} +3 -6
- sl_shared_assets/tools/ascension_tools.pyi +68 -0
- sl_shared_assets/tools/packaging_tools.pyi +52 -0
- sl_shared_assets/tools/transfer_tools.pyi +53 -0
- {sl_shared_assets-1.0.0rc13.dist-info → sl_shared_assets-1.0.0rc15.dist-info}/METADATA +1 -1
- sl_shared_assets-1.0.0rc15.dist-info/RECORD +40 -0
- sl_shared_assets/data_classes.py +0 -1656
- sl_shared_assets/server.py +0 -293
- sl_shared_assets-1.0.0rc13.dist-info/RECORD +0 -14
- /sl_shared_assets/{packaging_tools.py → tools/packaging_tools.py} +0 -0
- /sl_shared_assets/{transfer_tools.py → tools/transfer_tools.py} +0 -0
- {sl_shared_assets-1.0.0rc13.dist-info → sl_shared_assets-1.0.0rc15.dist-info}/WHEEL +0 -0
- {sl_shared_assets-1.0.0rc13.dist-info → sl_shared_assets-1.0.0rc15.dist-info}/entry_points.txt +0 -0
- {sl_shared_assets-1.0.0rc13.dist-info → sl_shared_assets-1.0.0rc15.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
"""This module
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"""This module stores the classes used to configure the single-day (within-session) sl-suite2p pipeline. This is the
|
|
2
|
+
'original' suite2p pipeline used to process brain activity data collected as part of a single continuous recording. It
|
|
3
|
+
is used as the first step of the multi-day brain activity processing pipeline used in the lab. Both single-day
|
|
4
|
+
(original) and multi-day (extended) pipelines are available as part of the Sun lab maintained sl-suite2p package."""
|
|
4
5
|
|
|
5
6
|
from typing import Any
|
|
6
7
|
from dataclasses import field, asdict, dataclass
|
|
@@ -10,7 +11,7 @@ from ataraxis_data_structures import YamlConfig
|
|
|
10
11
|
|
|
11
12
|
@dataclass
|
|
12
13
|
class Main:
|
|
13
|
-
"""Stores global
|
|
14
|
+
"""Stores global parameters that broadly define the suite2p single-day processing configuration."""
|
|
14
15
|
|
|
15
16
|
nplanes: int = 3
|
|
16
17
|
"""The number of imaging planes in each TIFF file sequence. For Mesoscope frames, this is the number of individual
|
|
@@ -24,16 +25,17 @@ class Main:
|
|
|
24
25
|
|
|
25
26
|
tau: float = 0.4
|
|
26
27
|
"""The timescale of the sensor, in seconds, used for computing the deconvolution kernel. The kernel is fixed to
|
|
27
|
-
have this decay and is not fit to the data. Note, the default value
|
|
28
|
-
|
|
28
|
+
have this decay and is not fit to the data. Note, the default value is optimized for GCamp6f animals recorded with
|
|
29
|
+
the Mesoscope."""
|
|
29
30
|
|
|
30
31
|
force_sktiff: bool = True
|
|
31
|
-
"""Determines whether to force the use of scikit-image for reading TIFF files.
|
|
32
|
-
|
|
32
|
+
"""Determines whether to force the use of scikit-image for reading TIFF files. Generally, it is recommended to have
|
|
33
|
+
this enabled as it forces suite2p to use tifffile library, which has better safety and compatibility than
|
|
34
|
+
ScanImage tiff reader for certain types of tiff files."""
|
|
33
35
|
|
|
34
36
|
fs: float = 10.0014
|
|
35
|
-
"""The sampling rate per plane in Hertz.
|
|
36
|
-
|
|
37
|
+
"""The sampling rate per plane in Hertz. For instance, if you have a 10 plane recording acquired at 30Hz, then the
|
|
38
|
+
sampling rate per plane is 3Hz, so set this to 3."""
|
|
37
39
|
|
|
38
40
|
do_bidiphase: bool = False
|
|
39
41
|
"""Determines whether to perform computation of bidirectional phase offset for misaligned line scanning
|
|
@@ -53,8 +55,8 @@ class Main:
|
|
|
53
55
|
to process all available frames."""
|
|
54
56
|
|
|
55
57
|
multiplane_parallel: bool = True
|
|
56
|
-
"""Determines whether to parallelize plane processing for multiplane data.
|
|
57
|
-
|
|
58
|
+
"""Determines whether to parallelize plane processing for multiplane data. Note, while enabling this option improves
|
|
59
|
+
processing speeds, it also increases the memory (RAM) overhead resulting from processing all planes in-parallel.
|
|
58
60
|
"""
|
|
59
61
|
|
|
60
62
|
ignore_flyback: list[int] = field(default_factory=list)
|
|
@@ -63,7 +65,7 @@ class Main:
|
|
|
63
65
|
|
|
64
66
|
@dataclass
|
|
65
67
|
class FileIO:
|
|
66
|
-
"""Stores I/O
|
|
68
|
+
"""Stores general I/O parameters that specify input data location, format, and working and output directories."""
|
|
67
69
|
|
|
68
70
|
fast_disk: list[str] = field(default_factory=list)
|
|
69
71
|
"""Specifies the locations where to store the temporary binary files created during processing. If no directories
|
|
@@ -107,7 +109,9 @@ class FileIO:
|
|
|
107
109
|
|
|
108
110
|
save_folder: list[str] = field(default_factory=list)
|
|
109
111
|
"""Lists folder names under which the results should be stored. If this is not provided, the pipeline defaults to
|
|
110
|
-
using 'suite2p' as the root folder, created under the path specified by save_path0.
|
|
112
|
+
using 'suite2p' as the root folder, created under the path specified by save_path0. Note, if the data produced by
|
|
113
|
+
the 'single-day' pipeline is also processed using sl-suite2p 'multi-day' pipeline, do not modify this field. The
|
|
114
|
+
multi-day pipeline expects the save_folder to be 'suite2p' (default)."""
|
|
111
115
|
|
|
112
116
|
look_one_level_down: bool = False
|
|
113
117
|
"""Determines whether to search for TIFF files in the subfolders when searching for Tiff files. If this is True,
|
|
@@ -123,7 +127,7 @@ class FileIO:
|
|
|
123
127
|
|
|
124
128
|
@dataclass
|
|
125
129
|
class Output:
|
|
126
|
-
"""Stores I/O settings
|
|
130
|
+
"""Stores I/O settings that specify the output format and organization of the data processing results."""
|
|
127
131
|
|
|
128
132
|
preclassify: float = 0.5
|
|
129
133
|
"""The probability threshold for pre-classification of cells to use before signal extraction. If this is set to
|
|
@@ -149,7 +153,7 @@ class Output:
|
|
|
149
153
|
|
|
150
154
|
@dataclass
|
|
151
155
|
class Registration:
|
|
152
|
-
"""Stores rigid registration
|
|
156
|
+
"""Stores parameters for rigid registration, which is used to correct motion artifacts between frames."""
|
|
153
157
|
|
|
154
158
|
do_registration: bool = True
|
|
155
159
|
"""Determines whether to run the motion registration."""
|
|
@@ -214,7 +218,8 @@ class Registration:
|
|
|
214
218
|
|
|
215
219
|
@dataclass
|
|
216
220
|
class OnePRegistration:
|
|
217
|
-
"""Stores additional pre-registration processing
|
|
221
|
+
"""Stores parameters for additional pre-registration processing used to improve the registration of 1-photon
|
|
222
|
+
datasets."""
|
|
218
223
|
|
|
219
224
|
one_p_reg: bool = False
|
|
220
225
|
"""Determines whether to perform high-pass spatial filtering and tapering to improve one-photon image
|
|
@@ -233,7 +238,8 @@ class OnePRegistration:
|
|
|
233
238
|
|
|
234
239
|
@dataclass
|
|
235
240
|
class NonRigid:
|
|
236
|
-
"""Stores non-rigid registration
|
|
241
|
+
"""Stores parameters for non-rigid registration, which is used to improve motion registration in complex
|
|
242
|
+
datasets."""
|
|
237
243
|
|
|
238
244
|
nonrigid: bool = True
|
|
239
245
|
"""Determines whether to perform non-rigid registration to correct for local motion and deformation. This is used
|
|
@@ -253,7 +259,7 @@ class NonRigid:
|
|
|
253
259
|
|
|
254
260
|
@dataclass
|
|
255
261
|
class ROIDetection:
|
|
256
|
-
"""Stores ROI detection and extraction
|
|
262
|
+
"""Stores parameters for cell ROI detection and extraction."""
|
|
257
263
|
|
|
258
264
|
roidetect: bool = True
|
|
259
265
|
"""Determines whether to perform ROI detection and subsequent signal extraction."""
|
|
@@ -292,7 +298,8 @@ class ROIDetection:
|
|
|
292
298
|
"""The maximum number of iterations allowed for cell extraction."""
|
|
293
299
|
|
|
294
300
|
nbinned: int = 5000
|
|
295
|
-
"""The maximum number of binned frames to use for ROI detection to
|
|
301
|
+
"""The maximum number of binned frames to use for ROI detection. Settings this value to a higher number leads to
|
|
302
|
+
more ROIs being detected, but reduces processing speed and increases RAM overhead."""
|
|
296
303
|
|
|
297
304
|
denoise: bool = False
|
|
298
305
|
"""Determines whether to denoise the binned movie before cell detection in sparse mode to enhance performance.
|
|
@@ -301,7 +308,7 @@ class ROIDetection:
|
|
|
301
308
|
|
|
302
309
|
@dataclass
|
|
303
310
|
class CellposeDetection:
|
|
304
|
-
"""Stores Cellpose algorithm
|
|
311
|
+
"""Stores parameters for the Cellpose algorithm, which can optionally be used to improve cell ROI extraction."""
|
|
305
312
|
|
|
306
313
|
anatomical_only: int = 0
|
|
307
314
|
"""Specifies the Cellpose mode for cell detection:
|
|
@@ -332,7 +339,7 @@ class CellposeDetection:
|
|
|
332
339
|
|
|
333
340
|
@dataclass
|
|
334
341
|
class SignalExtraction:
|
|
335
|
-
"""Stores
|
|
342
|
+
"""Stores parameters for extracting fluorescence signals from ROIs and surrounding neuropil regions."""
|
|
336
343
|
|
|
337
344
|
neuropil_extract: bool = True
|
|
338
345
|
"""Determines whether to extract neuropil signals."""
|
|
@@ -353,10 +360,10 @@ class SignalExtraction:
|
|
|
353
360
|
|
|
354
361
|
@dataclass
|
|
355
362
|
class SpikeDeconvolution:
|
|
356
|
-
"""Stores
|
|
363
|
+
"""Stores parameters for deconvolve fluorescence signals to infer spike trains."""
|
|
357
364
|
|
|
358
365
|
spikedetect: bool = True
|
|
359
|
-
"""Determines whether to perform spike deconvolution
|
|
366
|
+
"""Determines whether to perform spike deconvolution."""
|
|
360
367
|
|
|
361
368
|
neucoeff: float = 0.7
|
|
362
369
|
"""The neuropil coefficient applied for signal correction before deconvolution."""
|
|
@@ -382,7 +389,7 @@ class SpikeDeconvolution:
|
|
|
382
389
|
|
|
383
390
|
@dataclass
|
|
384
391
|
class Classification:
|
|
385
|
-
"""Stores
|
|
392
|
+
"""Stores parameters for classifying detected ROIs as real cells or artifacts."""
|
|
386
393
|
|
|
387
394
|
soma_crop: bool = True
|
|
388
395
|
"""Determines whether to crop dendritic regions from detected ROIs to focus on the cell body for classification
|
|
@@ -397,20 +404,22 @@ class Classification:
|
|
|
397
404
|
|
|
398
405
|
@dataclass
|
|
399
406
|
class Channel2:
|
|
400
|
-
"""Stores
|
|
407
|
+
"""Stores parameters for processing the second channel in multichannel datasets."""
|
|
401
408
|
|
|
402
409
|
chan2_thres: float = 0.65
|
|
403
410
|
"""The threshold for considering an ROI registered in one channel as detected in the second channel."""
|
|
404
411
|
|
|
405
412
|
|
|
406
413
|
@dataclass
|
|
407
|
-
class
|
|
408
|
-
"""Stores the user-addressable suite2p configuration parameters, organized
|
|
414
|
+
class SingleDayS2PConfiguration(YamlConfig):
|
|
415
|
+
"""Stores the user-addressable suite2p configuration parameters for the single-day (original) pipeline, organized
|
|
416
|
+
into subsections.
|
|
409
417
|
|
|
410
|
-
This class is used during processing to instruct suite2p on how to process the data.
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
418
|
+
This class is used during single-day processing to instruct suite2p on how to process the data. This class is based
|
|
419
|
+
on the 'default_ops' from the original suite2p package. As part of the suite2p refactoring performed in sl-suite2p
|
|
420
|
+
package, the 'default_ops' has been replaced with this class instance. Compared to 'original' ops, it allows saving
|
|
421
|
+
configuration parameters as a .YAML file, which offers a better way of viewing and editing the parameters and
|
|
422
|
+
running suite2p pipeline on remote compute servers.
|
|
414
423
|
|
|
415
424
|
Notes:
|
|
416
425
|
The .YAML file uses section names that match the suite2p documentation sections. This way, users can always
|
|
@@ -419,17 +428,31 @@ class Suite2PConfiguration(YamlConfig):
|
|
|
419
428
|
|
|
420
429
|
# Define the instances of each nested settings class as fields
|
|
421
430
|
main: Main = field(default_factory=Main)
|
|
431
|
+
"""Stores global parameters that broadly define the suite2p single-day processing configuration."""
|
|
422
432
|
file_io: FileIO = field(default_factory=FileIO)
|
|
433
|
+
"""Stores general I/O parameters that specify input data location, format, and working and output directories."""
|
|
423
434
|
output: Output = field(default_factory=Output)
|
|
435
|
+
"""Stores I/O settings that specify the output format and organization of the data processing results."""
|
|
424
436
|
registration: Registration = field(default_factory=Registration)
|
|
437
|
+
"""Stores parameters for rigid registration, which is used to correct motion artifacts between frames."""
|
|
425
438
|
one_p_registration: OnePRegistration = field(default_factory=OnePRegistration)
|
|
439
|
+
"""Stores parameters for additional pre-registration processing used to improve the registration of 1-photon
|
|
440
|
+
datasets."""
|
|
426
441
|
non_rigid: NonRigid = field(default_factory=NonRigid)
|
|
442
|
+
"""Stores parameters for non-rigid registration, which is used to improve motion registration in complex
|
|
443
|
+
datasets."""
|
|
427
444
|
roi_detection: ROIDetection = field(default_factory=ROIDetection)
|
|
445
|
+
"""Stores parameters for cell ROI detection and extraction."""
|
|
428
446
|
cellpose_detection: CellposeDetection = field(default_factory=CellposeDetection)
|
|
447
|
+
"""Stores parameters for the Cellpose algorithm, which can optionally be used to improve cell ROI extraction."""
|
|
429
448
|
signal_extraction: SignalExtraction = field(default_factory=SignalExtraction)
|
|
449
|
+
"""Stores parameters for extracting fluorescence signals from ROIs and surrounding neuropil regions."""
|
|
430
450
|
spike_deconvolution: SpikeDeconvolution = field(default_factory=SpikeDeconvolution)
|
|
451
|
+
"""Stores parameters for deconvolve fluorescence signals to infer spike trains."""
|
|
431
452
|
classification: Classification = field(default_factory=Classification)
|
|
453
|
+
"""Stores parameters for classifying detected ROIs as real cells or artifacts."""
|
|
432
454
|
channel2: Channel2 = field(default_factory=Channel2)
|
|
455
|
+
"""Stores parameters for processing the second channel in multichannel datasets."""
|
|
433
456
|
|
|
434
457
|
def to_ops(self) -> dict[str, Any]:
|
|
435
458
|
"""Converts the class instance to a dictionary and returns it to caller.
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
from dataclasses import field, dataclass
|
|
3
|
+
|
|
4
|
+
from _typeshed import Incomplete
|
|
5
|
+
from ataraxis_data_structures import YamlConfig
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class Main:
|
|
9
|
+
"""Stores global parameters that broadly define the suite2p single-day processing configuration."""
|
|
10
|
+
|
|
11
|
+
nplanes: int = ...
|
|
12
|
+
nchannels: int = ...
|
|
13
|
+
functional_chan: int = ...
|
|
14
|
+
tau: float = ...
|
|
15
|
+
force_sktiff: bool = ...
|
|
16
|
+
fs: float = ...
|
|
17
|
+
do_bidiphase: bool = ...
|
|
18
|
+
bidiphase: int = ...
|
|
19
|
+
bidi_corrected: bool = ...
|
|
20
|
+
frames_include: int = ...
|
|
21
|
+
multiplane_parallel: bool = ...
|
|
22
|
+
ignore_flyback: list[int] = field(default_factory=list)
|
|
23
|
+
|
|
24
|
+
@dataclass
|
|
25
|
+
class FileIO:
|
|
26
|
+
"""Stores general I/O parameters that specify input data location, format, and working and output directories."""
|
|
27
|
+
|
|
28
|
+
fast_disk: list[str] = field(default_factory=list)
|
|
29
|
+
delete_bin: bool = ...
|
|
30
|
+
mesoscan: bool = ...
|
|
31
|
+
bruker: bool = ...
|
|
32
|
+
bruker_bidirectional: bool = ...
|
|
33
|
+
h5py: list[str] = field(default_factory=list)
|
|
34
|
+
h5py_key: str = ...
|
|
35
|
+
nwb_file: str = ...
|
|
36
|
+
nwb_driver: str = ...
|
|
37
|
+
nwb_series: str = ...
|
|
38
|
+
save_path0: list[str] = field(default_factory=list)
|
|
39
|
+
save_folder: list[str] = field(default_factory=list)
|
|
40
|
+
look_one_level_down: bool = ...
|
|
41
|
+
subfolders: list[str] = field(default_factory=list)
|
|
42
|
+
move_bin: bool = ...
|
|
43
|
+
|
|
44
|
+
@dataclass
|
|
45
|
+
class Output:
|
|
46
|
+
"""Stores I/O settings that specify the output format and organization of the data processing results."""
|
|
47
|
+
|
|
48
|
+
preclassify: float = ...
|
|
49
|
+
save_nwb: bool = ...
|
|
50
|
+
save_mat: bool = ...
|
|
51
|
+
combined: bool = ...
|
|
52
|
+
aspect: float = ...
|
|
53
|
+
report_time: bool = ...
|
|
54
|
+
|
|
55
|
+
@dataclass
|
|
56
|
+
class Registration:
|
|
57
|
+
"""Stores parameters for rigid registration, which is used to correct motion artifacts between frames."""
|
|
58
|
+
|
|
59
|
+
do_registration: bool = ...
|
|
60
|
+
align_by_chan: int = ...
|
|
61
|
+
nimg_init: int = ...
|
|
62
|
+
batch_size: int = ...
|
|
63
|
+
maxregshift: float = ...
|
|
64
|
+
smooth_sigma: float = ...
|
|
65
|
+
smooth_sigma_time: float = ...
|
|
66
|
+
keep_movie_raw: bool = ...
|
|
67
|
+
two_step_registration: bool = ...
|
|
68
|
+
reg_tif: bool = ...
|
|
69
|
+
reg_tif_chan2: bool = ...
|
|
70
|
+
subpixel: int = ...
|
|
71
|
+
th_badframes: float = ...
|
|
72
|
+
norm_frames: bool = ...
|
|
73
|
+
force_refImg: bool = ...
|
|
74
|
+
pad_fft: bool = ...
|
|
75
|
+
|
|
76
|
+
@dataclass
|
|
77
|
+
class OnePRegistration:
|
|
78
|
+
"""Stores parameters for additional pre-registration processing used to improve the registration of 1-photon
|
|
79
|
+
datasets."""
|
|
80
|
+
|
|
81
|
+
one_p_reg: bool = ...
|
|
82
|
+
spatial_hp_reg: int = ...
|
|
83
|
+
pre_smooth: float = ...
|
|
84
|
+
spatial_taper: float = ...
|
|
85
|
+
|
|
86
|
+
@dataclass
|
|
87
|
+
class NonRigid:
|
|
88
|
+
"""Stores parameters for non-rigid registration, which is used to improve motion registration in complex
|
|
89
|
+
datasets."""
|
|
90
|
+
|
|
91
|
+
nonrigid: bool = ...
|
|
92
|
+
block_size: list[int] = field(default_factory=Incomplete)
|
|
93
|
+
snr_thresh: float = ...
|
|
94
|
+
maxregshiftNR: float = ...
|
|
95
|
+
|
|
96
|
+
@dataclass
|
|
97
|
+
class ROIDetection:
|
|
98
|
+
"""Stores parameters for cell ROI detection and extraction."""
|
|
99
|
+
|
|
100
|
+
roidetect: bool = ...
|
|
101
|
+
sparse_mode: bool = ...
|
|
102
|
+
spatial_scale: int = ...
|
|
103
|
+
connected: bool = ...
|
|
104
|
+
threshold_scaling: float = ...
|
|
105
|
+
spatial_hp_detect: int = ...
|
|
106
|
+
max_overlap: float = ...
|
|
107
|
+
high_pass: int = ...
|
|
108
|
+
smooth_masks: bool = ...
|
|
109
|
+
max_iterations: int = ...
|
|
110
|
+
nbinned: int = ...
|
|
111
|
+
denoise: bool = ...
|
|
112
|
+
|
|
113
|
+
@dataclass
|
|
114
|
+
class CellposeDetection:
|
|
115
|
+
"""Stores parameters for the Cellpose algorithm, which can optionally be used to improve cell ROI extraction."""
|
|
116
|
+
|
|
117
|
+
anatomical_only: int = ...
|
|
118
|
+
diameter: int = ...
|
|
119
|
+
cellprob_threshold: float = ...
|
|
120
|
+
flow_threshold: float = ...
|
|
121
|
+
spatial_hp_cp: int = ...
|
|
122
|
+
pretrained_model: str = ...
|
|
123
|
+
|
|
124
|
+
@dataclass
|
|
125
|
+
class SignalExtraction:
|
|
126
|
+
"""Stores parameters for extracting fluorescence signals from ROIs and surrounding neuropil regions."""
|
|
127
|
+
|
|
128
|
+
neuropil_extract: bool = ...
|
|
129
|
+
allow_overlap: bool = ...
|
|
130
|
+
min_neuropil_pixels: int = ...
|
|
131
|
+
inner_neuropil_radius: int = ...
|
|
132
|
+
lam_percentile: int = ...
|
|
133
|
+
|
|
134
|
+
@dataclass
|
|
135
|
+
class SpikeDeconvolution:
|
|
136
|
+
"""Stores parameters for deconvolve fluorescence signals to infer spike trains."""
|
|
137
|
+
|
|
138
|
+
spikedetect: bool = ...
|
|
139
|
+
neucoeff: float = ...
|
|
140
|
+
baseline: str = ...
|
|
141
|
+
win_baseline: float = ...
|
|
142
|
+
sig_baseline: float = ...
|
|
143
|
+
prctile_baseline: float = ...
|
|
144
|
+
|
|
145
|
+
@dataclass
|
|
146
|
+
class Classification:
|
|
147
|
+
"""Stores parameters for classifying detected ROIs as real cells or artifacts."""
|
|
148
|
+
|
|
149
|
+
soma_crop: bool = ...
|
|
150
|
+
use_builtin_classifier: bool = ...
|
|
151
|
+
classifier_path: str = ...
|
|
152
|
+
|
|
153
|
+
@dataclass
|
|
154
|
+
class Channel2:
|
|
155
|
+
"""Stores parameters for processing the second channel in multichannel datasets."""
|
|
156
|
+
|
|
157
|
+
chan2_thres: float = ...
|
|
158
|
+
|
|
159
|
+
@dataclass
|
|
160
|
+
class SingleDayS2PConfiguration(YamlConfig):
|
|
161
|
+
"""Stores the user-addressable suite2p configuration parameters for the single-day (original) pipeline, organized
|
|
162
|
+
into subsections.
|
|
163
|
+
|
|
164
|
+
This class is used during single-day processing to instruct suite2p on how to process the data. This class is based
|
|
165
|
+
on the 'default_ops' from the original suite2p package. As part of the suite2p refactoring performed in sl-suite2p
|
|
166
|
+
package, the 'default_ops' has been replaced with this class instance. Compared to 'original' ops, it allows saving
|
|
167
|
+
configuration parameters as a .YAML file, which offers a better way of viewing and editing the parameters and
|
|
168
|
+
running suite2p pipeline on remote compute servers.
|
|
169
|
+
|
|
170
|
+
Notes:
|
|
171
|
+
The .YAML file uses section names that match the suite2p documentation sections. This way, users can always
|
|
172
|
+
consult the suite2p documentation for information on the purpose of each field inside every subsection.
|
|
173
|
+
"""
|
|
174
|
+
|
|
175
|
+
main: Main = field(default_factory=Main)
|
|
176
|
+
file_io: FileIO = field(default_factory=FileIO)
|
|
177
|
+
output: Output = field(default_factory=Output)
|
|
178
|
+
registration: Registration = field(default_factory=Registration)
|
|
179
|
+
one_p_registration: OnePRegistration = field(default_factory=OnePRegistration)
|
|
180
|
+
non_rigid: NonRigid = field(default_factory=NonRigid)
|
|
181
|
+
roi_detection: ROIDetection = field(default_factory=ROIDetection)
|
|
182
|
+
cellpose_detection: CellposeDetection = field(default_factory=CellposeDetection)
|
|
183
|
+
signal_extraction: SignalExtraction = field(default_factory=SignalExtraction)
|
|
184
|
+
spike_deconvolution: SpikeDeconvolution = field(default_factory=SpikeDeconvolution)
|
|
185
|
+
classification: Classification = field(default_factory=Classification)
|
|
186
|
+
channel2: Channel2 = field(default_factory=Channel2)
|
|
187
|
+
def to_ops(self) -> dict[str, Any]:
|
|
188
|
+
"""Converts the class instance to a dictionary and returns it to caller.
|
|
189
|
+
|
|
190
|
+
This dictionary can be passed to suite2p functions either as an 'ops' or 'db' argument to control the
|
|
191
|
+
processing runtime.
|
|
192
|
+
"""
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""This package provides helper tools used to automate routine operations, such as transferring or verifying the
|
|
2
|
+
integrity of the data. The tools from this package are used by most other data processing libraries in the lab."""
|
|
3
|
+
|
|
4
|
+
from .transfer_tools import transfer_directory
|
|
5
|
+
from .ascension_tools import ascend_tyche_data
|
|
6
|
+
from .packaging_tools import calculate_directory_checksum
|
|
7
|
+
|
|
8
|
+
__all__ = ["transfer_directory", "calculate_directory_checksum", "ascend_tyche_data"]
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
from .transfer_tools import transfer_directory as transfer_directory
|
|
2
|
+
from .ascension_tools import ascend_tyche_data as ascend_tyche_data
|
|
3
|
+
from .packaging_tools import calculate_directory_checksum as calculate_directory_checksum
|
|
4
|
+
|
|
5
|
+
__all__ = ["transfer_directory", "calculate_directory_checksum", "ascend_tyche_data"]
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""This module provides tools for translating ('ascending') old Tyche data to use the modern data structure used in the
|
|
2
2
|
Sun lab. The tools from this module will not work for any other data and also assume that the Tyche data has been
|
|
3
|
-
preprocessed with an early version of the Sun lab mesoscope processing pipeline.
|
|
3
|
+
preprocessed with an early version of the Sun lab mesoscope processing pipeline. However, this module can be used as
|
|
4
|
+
an example for how to convert other data formats to match use the Sun lab data structure."""
|
|
4
5
|
|
|
5
6
|
from pathlib import Path
|
|
6
7
|
import datetime
|
|
@@ -10,14 +11,10 @@ import numpy as np
|
|
|
10
11
|
from ataraxis_base_utilities import LogLevel, console
|
|
11
12
|
from ataraxis_time.time_helpers import extract_timestamp_from_bytes
|
|
12
13
|
|
|
13
|
-
from
|
|
14
|
+
from ..data_classes import SessionData, ProjectConfiguration
|
|
14
15
|
from .transfer_tools import transfer_directory
|
|
15
16
|
from .packaging_tools import calculate_directory_checksum
|
|
16
17
|
|
|
17
|
-
# Ensures the console is enabled when this file is imported
|
|
18
|
-
if not console.enabled:
|
|
19
|
-
console.enable()
|
|
20
|
-
|
|
21
18
|
|
|
22
19
|
def _generate_session_name(acquisition_path: Path) -> str:
|
|
23
20
|
"""Generates a session name using the last modification time of a zstack.mat or MotionEstimator.me file.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from ..data_classes import (
|
|
4
|
+
SessionData as SessionData,
|
|
5
|
+
ProjectConfiguration as ProjectConfiguration,
|
|
6
|
+
)
|
|
7
|
+
from .transfer_tools import transfer_directory as transfer_directory
|
|
8
|
+
from .packaging_tools import calculate_directory_checksum as calculate_directory_checksum
|
|
9
|
+
|
|
10
|
+
def _generate_session_name(acquisition_path: Path) -> str:
|
|
11
|
+
"""Generates a session name using the last modification time of a zstack.mat or MotionEstimator.me file.
|
|
12
|
+
|
|
13
|
+
This worker function uses one of the motion estimation files stored in each Tyche 'acquisition' subfolder to
|
|
14
|
+
generate a modern Sun lab timestamp-based session name. This is used to translate the original Tyche session naming
|
|
15
|
+
pattern into the pattern used by all modern Sun lab projects and pipelines.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
acquisition_path: The absolute path to the target acquisition folder. These folders are found under the 'day'
|
|
19
|
+
folders for each animal, e.g.: Tyche-A7/2022_01_03/1.
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
The modernized session name.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
def _reorganize_data(session_data: SessionData, source_root: Path) -> bool:
|
|
26
|
+
"""Reorganizes and moves the session's data from the source folder in the old Tyche data hierarchy to the raw_data
|
|
27
|
+
folder in the newly created modern hierarchy.
|
|
28
|
+
|
|
29
|
+
This worker function is used to physically rearrange the data from the original Tyche data structure to the
|
|
30
|
+
new data structure. It both moves the existing files to their new destinations and renames certain files to match
|
|
31
|
+
the modern naming convention used in the Sun lab.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
session_data: The initialized SessionData instance managing the 'ascended' (modernized) session data hierarchy.
|
|
35
|
+
source_root: The absolute path to the old Tyche data hierarchy folder that stores session's data.
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
True if the ascension process was successfully completed. False if the process encountered missing data or
|
|
39
|
+
otherwise did not go as expected. When the method returns False, the runtime function requests user intervention
|
|
40
|
+
to finalize the process manually.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
def ascend_tyche_data(root_directory: Path, output_root_directory: Path, server_root_directory: Path) -> None:
|
|
44
|
+
"""Reformats the old Tyche data to use the modern Sun lab layout and metadata files.
|
|
45
|
+
|
|
46
|
+
This function is used to convert old Tyche data to the modern data management standard. This is used to make the
|
|
47
|
+
data compatible with the modern Sun lab data workflows.
|
|
48
|
+
|
|
49
|
+
Notes:
|
|
50
|
+
This function is statically written to work with the raw Tyche dataset featured in the OSM manuscript:
|
|
51
|
+
https://www.nature.com/articles/s41586-024-08548-w. Additionally, it assumes that the dataset has been
|
|
52
|
+
preprocessed with the early Sun lab mesoscope compression pipeline. The function will not work for any other
|
|
53
|
+
project or data hierarchy.
|
|
54
|
+
|
|
55
|
+
As part of its runtime, the function automatically transfers the ascended session data to the BioHPC server.
|
|
56
|
+
Since transferring the data over the network is the bottleneck of this pipeline, it runs in a single-threaded
|
|
57
|
+
mode and is constrained by the communication channel between the local machine and the BioHPC server. Calling
|
|
58
|
+
this function for a large number of sessions will result in a long processing time due to the network data
|
|
59
|
+
transfer.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
root_directory: The directory that stores one or more Tyche animal folders. This can be conceptualized as the
|
|
63
|
+
root directory for the Tyche project.
|
|
64
|
+
output_root_directory: The path to the local directory where to generate the converted Tyche project hierarchy.
|
|
65
|
+
Typically, this is the 'root' directory where all other Sun lab projects are stored.
|
|
66
|
+
server_root_directory: The path to the local filesystem-mounted BioHPC server storage directory. Note, this
|
|
67
|
+
directory hs to be mapped to the local filesystem via the SMB or equivalent protocol.
|
|
68
|
+
"""
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
def _calculate_file_checksum(base_directory: Path, file_path: Path) -> tuple[str, bytes]:
|
|
4
|
+
"""Calculates xxHash3-128 checksum for a single file and its path relative to the base directory.
|
|
5
|
+
|
|
6
|
+
This function is passed to parallel workers used by the calculate_directory_hash() method that iteratively
|
|
7
|
+
calculates the checksum for all files inside a directory. Each call to this function returns the checksum for the
|
|
8
|
+
target file, which includes both the contents of the file and its path relative to the base directory.
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
base_directory: The path to the base (root) directory which is being checksummed by the main
|
|
12
|
+
'calculate_directory_checksum' function.
|
|
13
|
+
file_path: The absolute path to the target file.
|
|
14
|
+
|
|
15
|
+
Returns:
|
|
16
|
+
A tuple with two elements. The first element is the path to the file relative to the base directory. The second
|
|
17
|
+
element is the xxHash3-128 checksum that covers the relative path and the contents of the file.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
def calculate_directory_checksum(
|
|
21
|
+
directory: Path, num_processes: int | None = None, batch: bool = False, save_checksum: bool = True
|
|
22
|
+
) -> str:
|
|
23
|
+
"""Calculates xxHash3-128 checksum for the input directory, which includes the data of all contained files and
|
|
24
|
+
the directory structure information.
|
|
25
|
+
|
|
26
|
+
This function is used to generate a checksum for the raw_data directory of each experiment or training session.
|
|
27
|
+
Checksums are used to verify the session data integrity during transmission between the PC that acquired the data
|
|
28
|
+
and long-term storage locations, such as the Synology NAS or the BioHPC server. The function can be configured to
|
|
29
|
+
write the generated checksum as a hexadecimal string to the ax_checksum.txt file stored at the highest level of the
|
|
30
|
+
input directory.
|
|
31
|
+
|
|
32
|
+
Note:
|
|
33
|
+
This method uses multiprocessing to efficiently parallelize checksum calculation for multiple files. In
|
|
34
|
+
combination with xxHash3, this achieves a significant speedup over more common checksums, such as MD5 and
|
|
35
|
+
SHA256. Note that xxHash3 is not suitable for security purposes and is only used to ensure data integrity.
|
|
36
|
+
|
|
37
|
+
The method notifies the user about the checksum calculation process via the terminal.
|
|
38
|
+
|
|
39
|
+
The returned checksum accounts for both the contents of each file and the layout of the input directory
|
|
40
|
+
structure.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
directory: The Path to the directory to be checksummed.
|
|
44
|
+
num_processes: The number of CPU processes to use for parallelizing checksum calculation. If set to None, the
|
|
45
|
+
function defaults to using (logical CPU count - 4).
|
|
46
|
+
batch: Determines whether the function is called as part of batch-processing multiple directories. This is used
|
|
47
|
+
to optimize progress reporting to avoid cluttering the terminal.
|
|
48
|
+
save_checksum: Determines whether the checksum should be saved (written to) a .txt file.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
The xxHash3-128 checksum for the input directory as a hexadecimal string.
|
|
52
|
+
"""
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from .packaging_tools import calculate_directory_checksum as calculate_directory_checksum
|
|
4
|
+
|
|
5
|
+
def _transfer_file(source_file: Path, source_directory: Path, destination_directory: Path) -> None:
|
|
6
|
+
"""Copies the input file from the source directory to the destination directory while preserving the file metadata.
|
|
7
|
+
|
|
8
|
+
This is a worker method used by the transfer_directory() method to move multiple files in parallel.
|
|
9
|
+
|
|
10
|
+
Notes:
|
|
11
|
+
If the file is found under a hierarchy of subdirectories inside the input source_directory, that hierarchy will
|
|
12
|
+
be preserved in the destination directory.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
source_file: The file to be copied.
|
|
16
|
+
source_directory: The root directory where the file is located.
|
|
17
|
+
destination_directory: The destination directory where to move the file.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
def transfer_directory(source: Path, destination: Path, num_threads: int = 1, verify_integrity: bool = True) -> None:
|
|
21
|
+
"""Copies the contents of the input directory tree from source to destination while preserving the folder
|
|
22
|
+
structure.
|
|
23
|
+
|
|
24
|
+
This function is used to assemble the experimental data from all remote machines used in the acquisition process on
|
|
25
|
+
the VRPC before the data is preprocessed. It is also used to transfer the preprocessed data from the VRPC to the
|
|
26
|
+
SynologyNAS and the Sun lab BioHPC server.
|
|
27
|
+
|
|
28
|
+
Notes:
|
|
29
|
+
This method recreates the moved directory hierarchy on the destination if the hierarchy does not exist. This is
|
|
30
|
+
done before copying the files.
|
|
31
|
+
|
|
32
|
+
The method executes a multithreading copy operation. It does not clean up the source files. That job is handed
|
|
33
|
+
to the specific preprocessing function from the sl_experiment or sl-forgery libraries that calls this function.
|
|
34
|
+
|
|
35
|
+
If the method is configured to verify transferred file integrity, it reruns the xxHash3-128 checksum calculation
|
|
36
|
+
and compares the returned checksum to the one stored in the source directory. The method assumes that all input
|
|
37
|
+
directories contain the 'ax_checksum.txt' file that stores the 'source' directory checksum at the highest level
|
|
38
|
+
of the input directory tree.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
source: The path to the directory that needs to be moved.
|
|
42
|
+
destination: The path to the destination directory where to move the contents of the source directory.
|
|
43
|
+
num_threads: The number of threads to use for parallel file transfer. This number should be set depending on the
|
|
44
|
+
type of transfer (local or remote) and is not guaranteed to provide improved transfer performance. For local
|
|
45
|
+
transfers, setting this number above 1 will likely provide a performance boost. For remote transfers using
|
|
46
|
+
a single TCP / IP socket (such as non-multichannel SMB protocol), the number should be set to 1.
|
|
47
|
+
verify_integrity: Determines whether to perform integrity verification for the transferred files. Note,
|
|
48
|
+
integrity verification is a time-consuming process and generally would not be a concern for most runtimes.
|
|
49
|
+
Therefore, it is often fine to disable this option to optimize method runtime speed.
|
|
50
|
+
|
|
51
|
+
Raises:
|
|
52
|
+
RuntimeError: If the transferred files do not pass the xxHas3-128 checksum integrity verification.
|
|
53
|
+
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sl-shared-assets
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.0rc15
|
|
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/
|