sl-shared-assets 1.0.0rc19__tar.gz → 1.0.0rc20__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of sl-shared-assets might be problematic. Click here for more details.
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/PKG-INFO +1 -1
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/pyproject.toml +1 -1
- sl_shared_assets-1.0.0rc20/src/sl_shared_assets/__init__.pyi +71 -0
- sl_shared_assets-1.0.0rc20/src/sl_shared_assets/cli.pyi +28 -0
- sl_shared_assets-1.0.0rc20/src/sl_shared_assets/data_classes/__init__.pyi +61 -0
- sl_shared_assets-1.0.0rc20/src/sl_shared_assets/data_classes/configuration_data.pyi +37 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/src/sl_shared_assets/data_classes/runtime_data.py +12 -0
- sl_shared_assets-1.0.0rc20/src/sl_shared_assets/data_classes/runtime_data.pyi +148 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/src/sl_shared_assets/data_classes/session_data.py +9 -9
- sl_shared_assets-1.0.0rc20/src/sl_shared_assets/data_classes/session_data.pyi +544 -0
- sl_shared_assets-1.0.0rc20/src/sl_shared_assets/data_classes/surgery_data.pyi +89 -0
- sl_shared_assets-1.0.0rc20/src/sl_shared_assets/server/__init__.pyi +8 -0
- sl_shared_assets-1.0.0rc20/src/sl_shared_assets/server/job.pyi +94 -0
- sl_shared_assets-1.0.0rc20/src/sl_shared_assets/server/server.pyi +95 -0
- sl_shared_assets-1.0.0rc20/src/sl_shared_assets/suite2p/__init__.pyi +4 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/src/sl_shared_assets/suite2p/multi_day.py +7 -8
- sl_shared_assets-1.0.0rc20/src/sl_shared_assets/suite2p/multi_day.pyi +104 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/src/sl_shared_assets/suite2p/single_day.py +5 -4
- sl_shared_assets-1.0.0rc20/src/sl_shared_assets/suite2p/single_day.pyi +220 -0
- sl_shared_assets-1.0.0rc20/src/sl_shared_assets/tools/__init__.pyi +5 -0
- sl_shared_assets-1.0.0rc20/src/sl_shared_assets/tools/ascension_tools.pyi +68 -0
- sl_shared_assets-1.0.0rc20/src/sl_shared_assets/tools/packaging_tools.pyi +52 -0
- sl_shared_assets-1.0.0rc20/src/sl_shared_assets/tools/transfer_tools.pyi +53 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/.gitignore +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/LICENSE +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/README.md +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/docs/Makefile +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/docs/make.bat +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/docs/source/api.rst +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/docs/source/conf.py +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/docs/source/index.rst +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/docs/source/welcome.rst +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/envs/slsa_dev_lin.yml +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/envs/slsa_dev_lin_spec.txt +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/src/sl_shared_assets/__init__.py +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/src/sl_shared_assets/cli.py +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/src/sl_shared_assets/data_classes/__init__.py +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/src/sl_shared_assets/data_classes/configuration_data.py +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/src/sl_shared_assets/data_classes/surgery_data.py +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/src/sl_shared_assets/py.typed +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/src/sl_shared_assets/server/__init__.py +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/src/sl_shared_assets/server/job.py +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/src/sl_shared_assets/server/server.py +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/src/sl_shared_assets/suite2p/__init__.py +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/src/sl_shared_assets/tools/__init__.py +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/src/sl_shared_assets/tools/ascension_tools.py +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/src/sl_shared_assets/tools/packaging_tools.py +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/src/sl_shared_assets/tools/transfer_tools.py +0 -0
- {sl_shared_assets-1.0.0rc19 → sl_shared_assets-1.0.0rc20}/tox.ini +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sl-shared-assets
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.0rc20
|
|
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/
|
|
@@ -8,7 +8,7 @@ build-backend = "hatchling.build"
|
|
|
8
8
|
# Project metdata section. Provides the genral ID information about the project.
|
|
9
9
|
[project]
|
|
10
10
|
name = "sl-shared-assets"
|
|
11
|
-
version = "1.0.
|
|
11
|
+
version = "1.0.0rc20"
|
|
12
12
|
description = "Stores assets shared between multiple Sun (NeuroAI) lab data pipelines."
|
|
13
13
|
readme = "README.md"
|
|
14
14
|
license = { file = "LICENSE" }
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from .tools import (
|
|
2
|
+
transfer_directory as transfer_directory,
|
|
3
|
+
calculate_directory_checksum as calculate_directory_checksum,
|
|
4
|
+
)
|
|
5
|
+
from .server import (
|
|
6
|
+
Server as Server,
|
|
7
|
+
ServerCredentials as ServerCredentials,
|
|
8
|
+
)
|
|
9
|
+
from .suite2p import (
|
|
10
|
+
MultiDayS2PConfiguration as MultiDayS2PConfiguration,
|
|
11
|
+
SingleDayS2PConfiguration as SingleDayS2PConfiguration,
|
|
12
|
+
)
|
|
13
|
+
from .data_classes import (
|
|
14
|
+
RawData as RawData,
|
|
15
|
+
DrugData as DrugData,
|
|
16
|
+
ImplantData as ImplantData,
|
|
17
|
+
SessionData as SessionData,
|
|
18
|
+
SubjectData as SubjectData,
|
|
19
|
+
SurgeryData as SurgeryData,
|
|
20
|
+
InjectionData as InjectionData,
|
|
21
|
+
MesoscopeData as MesoscopeData,
|
|
22
|
+
ProcedureData as ProcedureData,
|
|
23
|
+
ProcessedData as ProcessedData,
|
|
24
|
+
DeepLabCutData as DeepLabCutData,
|
|
25
|
+
ZaberPositions as ZaberPositions,
|
|
26
|
+
ExperimentState as ExperimentState,
|
|
27
|
+
VRPCDestinations as VRPCDestinations,
|
|
28
|
+
ConfigurationData as ConfigurationData,
|
|
29
|
+
MesoscopePositions as MesoscopePositions,
|
|
30
|
+
VRPCPersistentData as VRPCPersistentData,
|
|
31
|
+
ProjectConfiguration as ProjectConfiguration,
|
|
32
|
+
HardwareConfiguration as HardwareConfiguration,
|
|
33
|
+
RunTrainingDescriptor as RunTrainingDescriptor,
|
|
34
|
+
LickTrainingDescriptor as LickTrainingDescriptor,
|
|
35
|
+
ExperimentConfiguration as ExperimentConfiguration,
|
|
36
|
+
ScanImagePCPersistentData as ScanImagePCPersistentData,
|
|
37
|
+
MesoscopeExperimentDescriptor as MesoscopeExperimentDescriptor,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
__all__ = [
|
|
41
|
+
"Server",
|
|
42
|
+
"ServerCredentials",
|
|
43
|
+
"SingleDayS2PConfiguration",
|
|
44
|
+
"MultiDayS2PConfiguration",
|
|
45
|
+
"DrugData",
|
|
46
|
+
"ImplantData",
|
|
47
|
+
"SessionData",
|
|
48
|
+
"RawData",
|
|
49
|
+
"ProcessedData",
|
|
50
|
+
"ConfigurationData",
|
|
51
|
+
"DeepLabCutData",
|
|
52
|
+
"VRPCPersistentData",
|
|
53
|
+
"ScanImagePCPersistentData",
|
|
54
|
+
"MesoscopeData",
|
|
55
|
+
"VRPCDestinations",
|
|
56
|
+
"SubjectData",
|
|
57
|
+
"SurgeryData",
|
|
58
|
+
"InjectionData",
|
|
59
|
+
"ProcedureData",
|
|
60
|
+
"ZaberPositions",
|
|
61
|
+
"ExperimentState",
|
|
62
|
+
"MesoscopePositions",
|
|
63
|
+
"ProjectConfiguration",
|
|
64
|
+
"HardwareConfiguration",
|
|
65
|
+
"RunTrainingDescriptor",
|
|
66
|
+
"LickTrainingDescriptor",
|
|
67
|
+
"ExperimentConfiguration",
|
|
68
|
+
"MesoscopeExperimentDescriptor",
|
|
69
|
+
"transfer_directory",
|
|
70
|
+
"calculate_directory_checksum",
|
|
71
|
+
]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from .tools import ascend_tyche_data as ascend_tyche_data
|
|
2
|
+
from .server import generate_server_credentials as generate_server_credentials
|
|
3
|
+
from .data_classes import replace_root_path as replace_root_path
|
|
4
|
+
|
|
5
|
+
def replace_local_root_directory(path: str) -> None:
|
|
6
|
+
"""Replaces the root directory used to store all lab projects on the local PC with the specified directory.
|
|
7
|
+
|
|
8
|
+
To ensure all projects are saved in the same location, this library resolves and saves the absolute path to the
|
|
9
|
+
project directory the first time ProjectConfiguration class instance is created on a new PC. All future projects
|
|
10
|
+
automatically reuse the same 'root' directory path. Since this information is stored in a typically hidden user
|
|
11
|
+
directory, this CLI can be used to replace the local directory path, if necessary.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def generate_server_credentials_file(output_directory: str, host: str, username: str, password: str) -> None:
|
|
15
|
+
"""Generates a new server_credentials.yaml file under the specified directory, using input information.
|
|
16
|
+
|
|
17
|
+
This CLI is used to set up new PCs to work with the lab BioHPC server. While this is primarily intended for the
|
|
18
|
+
VRPC, any machined that interacts with BioHPC server can use this CLI to build the access credentials file.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def ascend_tyche_directory(path: str, output_directory: str, server_directory: str) -> None:
|
|
22
|
+
"""Restructures old Tyche project data to use the modern Sun lab data structure.
|
|
23
|
+
|
|
24
|
+
This CLI is used to convert ('ascend') the old Tyche project data to the modern Sun lab structure. After
|
|
25
|
+
ascension, the data can be processed and analyzed using all modern Sun lab (sl-) tools and libraries. Note, this
|
|
26
|
+
process expects the input data to be preprocessed using an old Sun lab mesoscope data preprocessing pipeline. It
|
|
27
|
+
will not work for any other project or data.
|
|
28
|
+
"""
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
from .runtime_data import (
|
|
2
|
+
ZaberPositions as ZaberPositions,
|
|
3
|
+
MesoscopePositions as MesoscopePositions,
|
|
4
|
+
HardwareConfiguration as HardwareConfiguration,
|
|
5
|
+
RunTrainingDescriptor as RunTrainingDescriptor,
|
|
6
|
+
LickTrainingDescriptor as LickTrainingDescriptor,
|
|
7
|
+
MesoscopeExperimentDescriptor as MesoscopeExperimentDescriptor,
|
|
8
|
+
)
|
|
9
|
+
from .session_data import (
|
|
10
|
+
RawData as RawData,
|
|
11
|
+
SessionData as SessionData,
|
|
12
|
+
MesoscopeData as MesoscopeData,
|
|
13
|
+
ProcessedData as ProcessedData,
|
|
14
|
+
DeepLabCutData as DeepLabCutData,
|
|
15
|
+
VRPCDestinations as VRPCDestinations,
|
|
16
|
+
ConfigurationData as ConfigurationData,
|
|
17
|
+
VRPCPersistentData as VRPCPersistentData,
|
|
18
|
+
ProjectConfiguration as ProjectConfiguration,
|
|
19
|
+
ScanImagePCPersistentData as ScanImagePCPersistentData,
|
|
20
|
+
replace_root_path as replace_root_path,
|
|
21
|
+
)
|
|
22
|
+
from .surgery_data import (
|
|
23
|
+
DrugData as DrugData,
|
|
24
|
+
ImplantData as ImplantData,
|
|
25
|
+
SubjectData as SubjectData,
|
|
26
|
+
SurgeryData as SurgeryData,
|
|
27
|
+
InjectionData as InjectionData,
|
|
28
|
+
ProcedureData as ProcedureData,
|
|
29
|
+
)
|
|
30
|
+
from .configuration_data import (
|
|
31
|
+
ExperimentState as ExperimentState,
|
|
32
|
+
ExperimentConfiguration as ExperimentConfiguration,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
__all__ = [
|
|
36
|
+
"DrugData",
|
|
37
|
+
"ImplantData",
|
|
38
|
+
"SessionData",
|
|
39
|
+
"RawData",
|
|
40
|
+
"ProcessedData",
|
|
41
|
+
"ConfigurationData",
|
|
42
|
+
"DeepLabCutData",
|
|
43
|
+
"VRPCPersistentData",
|
|
44
|
+
"ScanImagePCPersistentData",
|
|
45
|
+
"MesoscopeData",
|
|
46
|
+
"VRPCDestinations",
|
|
47
|
+
"SubjectData",
|
|
48
|
+
"SurgeryData",
|
|
49
|
+
"InjectionData",
|
|
50
|
+
"ProcedureData",
|
|
51
|
+
"ZaberPositions",
|
|
52
|
+
"ExperimentState",
|
|
53
|
+
"MesoscopePositions",
|
|
54
|
+
"ProjectConfiguration",
|
|
55
|
+
"HardwareConfiguration",
|
|
56
|
+
"RunTrainingDescriptor",
|
|
57
|
+
"LickTrainingDescriptor",
|
|
58
|
+
"ExperimentConfiguration",
|
|
59
|
+
"MesoscopeExperimentDescriptor",
|
|
60
|
+
"replace_root_path",
|
|
61
|
+
]
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from pathlib import Path as Path
|
|
2
|
+
from dataclasses import field, dataclass
|
|
3
|
+
|
|
4
|
+
from _typeshed import Incomplete
|
|
5
|
+
from ataraxis_data_structures import YamlConfig
|
|
6
|
+
|
|
7
|
+
@dataclass()
|
|
8
|
+
class ExperimentState:
|
|
9
|
+
"""Encapsulates the information used to set and maintain the desired experiment and Mesoscope-VR system state.
|
|
10
|
+
|
|
11
|
+
Primarily, experiment runtime logic (task logic) is resolved by the Unity game engine. However, the Mesoscope-VR
|
|
12
|
+
system configuration may also need to change throughout the experiment to optimize the runtime by disabling or
|
|
13
|
+
reconfiguring specific hardware modules. For example, some experiment stages may require the running wheel to be
|
|
14
|
+
locked to prevent the animal from running, and other may require the VR screens to be turned off.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
experiment_state_code: int
|
|
18
|
+
vr_state_code: int
|
|
19
|
+
state_duration_s: float
|
|
20
|
+
|
|
21
|
+
@dataclass()
|
|
22
|
+
class ExperimentConfiguration(YamlConfig):
|
|
23
|
+
"""Stores the configuration of a single experiment runtime.
|
|
24
|
+
|
|
25
|
+
Primarily, this includes the sequence of experiment and Virtual Reality (Mesoscope-VR) states that defines the flow
|
|
26
|
+
of the experiment runtime. During runtime, the main runtime control function traverses the sequence of states
|
|
27
|
+
stored in this class instance start-to-end in the exact order specified by the user. Together with custom Unity
|
|
28
|
+
projects that define the task logic (how the system responds to animal interactions with the VR system) this class
|
|
29
|
+
allows flexibly implementing a wide range of experiments.
|
|
30
|
+
|
|
31
|
+
Each project should define one or more experiment configurations and save them as .yaml files inside the project
|
|
32
|
+
'configuration' folder. The name for each configuration file is defined by the user and is used to identify and load
|
|
33
|
+
the experiment configuration when 'sl-run-experiment' CLI command exposed by the sl-experiment library is executed.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
cue_map: dict[int, float] = field(default_factory=Incomplete)
|
|
37
|
+
experiment_states: dict[str, ExperimentState] = field(default_factory=Incomplete)
|
|
@@ -90,6 +90,10 @@ class LickTrainingDescriptor(YamlConfig):
|
|
|
90
90
|
"""Stores the maximum volume of water the system is allowed to dispense during training."""
|
|
91
91
|
maximum_training_time_m: int
|
|
92
92
|
"""Stores the maximum time, in minutes, the system is allowed to run the training for."""
|
|
93
|
+
maximum_unconsumed_rewards: int = 3
|
|
94
|
+
"""Stores the maximum number of consecutive rewards that can be delivered without the animal consuming them. If
|
|
95
|
+
the animal receives this many rewards without licking (consuming) them, reward delivery is paused until the animal
|
|
96
|
+
consumes the rewards."""
|
|
93
97
|
experimenter_notes: str = "Replace this with your notes."
|
|
94
98
|
"""This field is not set during runtime. It is expected that each experimenter replaces this field with their
|
|
95
99
|
notes made during runtime."""
|
|
@@ -137,6 +141,14 @@ class RunTrainingDescriptor(YamlConfig):
|
|
|
137
141
|
"""Stores the maximum volume of water the system is allowed to dispense during training."""
|
|
138
142
|
maximum_training_time_m: int
|
|
139
143
|
"""Stores the maximum time, in minutes, the system is allowed to run the training for."""
|
|
144
|
+
maximum_unconsumed_rewards: int = 3
|
|
145
|
+
"""Stores the maximum number of consecutive rewards that can be delivered without the animal consuming them. If
|
|
146
|
+
the animal receives this many rewards without licking (consuming) them, reward delivery is paused until the animal
|
|
147
|
+
consumes the rewards."""
|
|
148
|
+
maximum_idle_time_s: float = 0.0
|
|
149
|
+
"""Stores the maximum time, in seconds, the animal can dip below the running speed threshold to still receive the
|
|
150
|
+
reward. This allows animals that 'run' by taking a series of large steps, briefly dipping below speed threshold at
|
|
151
|
+
the end of each step, to still get water rewards."""
|
|
140
152
|
experimenter_notes: str = "Replace this with your notes."
|
|
141
153
|
"""This field is not set during runtime. It is expected that each experimenter will replace this field with their
|
|
142
154
|
notes made during runtime."""
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
from ataraxis_data_structures import YamlConfig
|
|
4
|
+
|
|
5
|
+
@dataclass()
|
|
6
|
+
class HardwareConfiguration(YamlConfig):
|
|
7
|
+
"""This class is used to save the runtime hardware configuration parameters as a .yaml file.
|
|
8
|
+
|
|
9
|
+
This information is used to read and decode the data saved to the .npz log files during runtime as part of data
|
|
10
|
+
processing.
|
|
11
|
+
|
|
12
|
+
Notes:
|
|
13
|
+
All fields in this dataclass initialize to None. During log processing, any log associated with a hardware
|
|
14
|
+
module that provides the data stored in a field will be processed, unless that field is None. Therefore, setting
|
|
15
|
+
any field in this dataclass to None also functions as a flag for whether to parse the log associated with the
|
|
16
|
+
module that provides this field's information.
|
|
17
|
+
|
|
18
|
+
This class is automatically configured by MesoscopeExperiment and BehaviorTraining classes from sl-experiment
|
|
19
|
+
library to facilitate log parsing.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
cue_map: dict[int, float] | None = ...
|
|
23
|
+
cm_per_pulse: float | None = ...
|
|
24
|
+
maximum_break_strength: float | None = ...
|
|
25
|
+
minimum_break_strength: float | None = ...
|
|
26
|
+
lick_threshold: int | None = ...
|
|
27
|
+
valve_scale_coefficient: float | None = ...
|
|
28
|
+
valve_nonlinearity_exponent: float | None = ...
|
|
29
|
+
torque_per_adc_unit: float | None = ...
|
|
30
|
+
screens_initially_on: bool | None = ...
|
|
31
|
+
recorded_mesoscope_ttl: bool | None = ...
|
|
32
|
+
|
|
33
|
+
@dataclass()
|
|
34
|
+
class LickTrainingDescriptor(YamlConfig):
|
|
35
|
+
"""This class is used to save the description information specific to lick training sessions as a .yaml file.
|
|
36
|
+
|
|
37
|
+
The information stored in this class instance is filled in two steps. The main runtime function fills most fields
|
|
38
|
+
of the class, before it is saved as a .yaml file. After runtime, the experimenter manually fills leftover fields,
|
|
39
|
+
such as 'experimenter_notes,' before the class instance is transferred to the long-term storage destination.
|
|
40
|
+
|
|
41
|
+
The fully filled instance data is also used during preprocessing to write the water restriction log entry for the
|
|
42
|
+
trained animal.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
experimenter: str
|
|
46
|
+
mouse_weight_g: float
|
|
47
|
+
dispensed_water_volume_ml: float
|
|
48
|
+
minimum_reward_delay: int
|
|
49
|
+
maximum_reward_delay_s: int
|
|
50
|
+
maximum_water_volume_ml: float
|
|
51
|
+
maximum_training_time_m: int
|
|
52
|
+
maximum_unconsumed_rewards: int = ...
|
|
53
|
+
experimenter_notes: str = ...
|
|
54
|
+
experimenter_given_water_volume_ml: float = ...
|
|
55
|
+
|
|
56
|
+
@dataclass()
|
|
57
|
+
class RunTrainingDescriptor(YamlConfig):
|
|
58
|
+
"""This class is used to save the description information specific to run training sessions as a .yaml file.
|
|
59
|
+
|
|
60
|
+
The information stored in this class instance is filled in two steps. The main runtime function fills most fields
|
|
61
|
+
of the class, before it is saved as a .yaml file. After runtime, the experimenter manually fills leftover fields,
|
|
62
|
+
such as 'experimenter_notes,' before the class instance is transferred to the long-term storage destination.
|
|
63
|
+
|
|
64
|
+
The fully filled instance data is also used during preprocessing to write the water restriction log entry for the
|
|
65
|
+
trained animal.
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
experimenter: str
|
|
69
|
+
mouse_weight_g: float
|
|
70
|
+
dispensed_water_volume_ml: float
|
|
71
|
+
final_run_speed_threshold_cm_s: float
|
|
72
|
+
final_run_duration_threshold_s: float
|
|
73
|
+
initial_run_speed_threshold_cm_s: float
|
|
74
|
+
initial_run_duration_threshold_s: float
|
|
75
|
+
increase_threshold_ml: float
|
|
76
|
+
run_speed_increase_step_cm_s: float
|
|
77
|
+
run_duration_increase_step_s: float
|
|
78
|
+
maximum_water_volume_ml: float
|
|
79
|
+
maximum_training_time_m: int
|
|
80
|
+
maximum_unconsumed_rewards: int = ...
|
|
81
|
+
maximum_idle_time_s: float = ...
|
|
82
|
+
experimenter_notes: str = ...
|
|
83
|
+
experimenter_given_water_volume_ml: float = ...
|
|
84
|
+
|
|
85
|
+
@dataclass()
|
|
86
|
+
class MesoscopeExperimentDescriptor(YamlConfig):
|
|
87
|
+
"""This class is used to save the description information specific to experiment sessions as a .yaml file.
|
|
88
|
+
|
|
89
|
+
The information stored in this class instance is filled in two steps. The main runtime function fills most fields
|
|
90
|
+
of the class, before it is saved as a .yaml file. After runtime, the experimenter manually fills leftover fields,
|
|
91
|
+
such as 'experimenter_notes,' before the class instance is transferred to the long-term storage destination.
|
|
92
|
+
|
|
93
|
+
The fully filled instance data is also used during preprocessing to write the water restriction log entry for the
|
|
94
|
+
animal participating in the experiment runtime.
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
experimenter: str
|
|
98
|
+
mouse_weight_g: float
|
|
99
|
+
dispensed_water_volume_ml: float
|
|
100
|
+
experimenter_notes: str = ...
|
|
101
|
+
experimenter_given_water_volume_ml: float = ...
|
|
102
|
+
|
|
103
|
+
@dataclass()
|
|
104
|
+
class ZaberPositions(YamlConfig):
|
|
105
|
+
"""This class is used to save Zaber motor positions as a .yaml file to reuse them between sessions.
|
|
106
|
+
|
|
107
|
+
The class is specifically designed to store, save, and load the positions of the LickPort and HeadBar motors
|
|
108
|
+
(axes). It is used to both store Zaber motor positions for each session for future analysis and to restore the same
|
|
109
|
+
Zaber motor positions across consecutive runtimes for the same project and animal combination.
|
|
110
|
+
|
|
111
|
+
Notes:
|
|
112
|
+
All positions are saved using native motor units. All class fields initialize to default placeholders that are
|
|
113
|
+
likely NOT safe to apply to the VR system. Do not apply the positions loaded from the file unless you are
|
|
114
|
+
certain they are safe to use.
|
|
115
|
+
|
|
116
|
+
Exercise caution when working with Zaber motors. The motors are powerful enough to damage the surrounding
|
|
117
|
+
equipment and manipulated objects. Do not modify the data stored inside the .yaml file unless you know what you
|
|
118
|
+
are doing.
|
|
119
|
+
"""
|
|
120
|
+
|
|
121
|
+
headbar_z: int = ...
|
|
122
|
+
headbar_pitch: int = ...
|
|
123
|
+
headbar_roll: int = ...
|
|
124
|
+
lickport_z: int = ...
|
|
125
|
+
lickport_x: int = ...
|
|
126
|
+
lickport_y: int = ...
|
|
127
|
+
|
|
128
|
+
@dataclass()
|
|
129
|
+
class MesoscopePositions(YamlConfig):
|
|
130
|
+
"""This class is used to save the real and virtual Mesoscope objective positions as a .yaml file to reuse it
|
|
131
|
+
between experiment sessions.
|
|
132
|
+
|
|
133
|
+
Primarily, the class is used to help the experimenter to position the Mesoscope at the same position across
|
|
134
|
+
multiple imaging sessions. It stores both the physical (real) position of the objective along the motorized
|
|
135
|
+
X, Y, Z, and Roll axes and the virtual (ScanImage software) tip, tilt, and fastZ focus axes.
|
|
136
|
+
|
|
137
|
+
Notes:
|
|
138
|
+
Since the API to read and write these positions automatically is currently not available, this class relies on
|
|
139
|
+
the experimenter manually entering all positions and setting the mesoscope to these positions when necessary.
|
|
140
|
+
"""
|
|
141
|
+
|
|
142
|
+
mesoscope_x_position: float = ...
|
|
143
|
+
mesoscope_y_position: float = ...
|
|
144
|
+
mesoscope_roll_position: float = ...
|
|
145
|
+
mesoscope_z_position: float = ...
|
|
146
|
+
mesoscope_fast_z_position: float = ...
|
|
147
|
+
mesoscope_tip_position: float = ...
|
|
148
|
+
mesoscope_tilt_position: float = ...
|
|
@@ -11,11 +11,11 @@ import shutil as sh
|
|
|
11
11
|
from pathlib import Path
|
|
12
12
|
from dataclasses import field, dataclass
|
|
13
13
|
|
|
14
|
+
import dacite
|
|
14
15
|
import appdirs
|
|
15
16
|
from ataraxis_base_utilities import LogLevel, console, ensure_directory_exists
|
|
16
17
|
from ataraxis_data_structures import YamlConfig
|
|
17
18
|
from ataraxis_time.time_helpers import get_timestamp
|
|
18
|
-
import dacite
|
|
19
19
|
|
|
20
20
|
from .configuration_data import ExperimentConfiguration
|
|
21
21
|
|
|
@@ -1313,7 +1313,7 @@ class SessionData(YamlConfig):
|
|
|
1313
1313
|
"""
|
|
1314
1314
|
|
|
1315
1315
|
# Reads the file content without using the YAML parsing methods.
|
|
1316
|
-
with open(path,
|
|
1316
|
+
with open(path, "r") as f:
|
|
1317
1317
|
content = f.read()
|
|
1318
1318
|
|
|
1319
1319
|
# Extracts the necessary fields using regex
|
|
@@ -1321,11 +1321,11 @@ class SessionData(YamlConfig):
|
|
|
1321
1321
|
|
|
1322
1322
|
# Defines the field patterns for each field to extract
|
|
1323
1323
|
patterns = {
|
|
1324
|
-
"project_name": r
|
|
1325
|
-
"animal_id": r
|
|
1326
|
-
"session_name": r
|
|
1327
|
-
"session_type": r
|
|
1328
|
-
"experiment_name": r
|
|
1324
|
+
"project_name": r"project_name:\s*(.+?)(?=\n\w|\n$)",
|
|
1325
|
+
"animal_id": r"animal_id:\s*(.+?)(?=\n\w|\n$)",
|
|
1326
|
+
"session_name": r"session_name:\s*(.+?)(?=\n\w|\n$)",
|
|
1327
|
+
"session_type": r"session_type:\s*(.+?)(?=\n\w|\n$)",
|
|
1328
|
+
"experiment_name": r"experiment_name:\s*(.+?)(?=\n\w|\n$)",
|
|
1329
1329
|
}
|
|
1330
1330
|
|
|
1331
1331
|
# Extracts each field
|
|
@@ -1343,5 +1343,5 @@ class SessionData(YamlConfig):
|
|
|
1343
1343
|
fields_to_keep[key] = "" # Default for other fields
|
|
1344
1344
|
|
|
1345
1345
|
# Returns the data to caller
|
|
1346
|
-
|
|
1347
|
-
|
|
1346
|
+
# noinspection PyTypeChecker
|
|
1347
|
+
return dacite.from_dict(data_class=cls, data=fields_to_keep)
|