Skip to content

Commit 160f083

Browse files
Merge pull request #293 from AllenNeuralDynamics/more_fib_plus_pav_updates
More fib plus pav updates
2 parents b8f4807 + 4523bfb commit 160f083

File tree

18 files changed

+1862
-669
lines changed

18 files changed

+1862
-669
lines changed

scripts/example_create_fiber_and_pav_sessions.py

Lines changed: 231 additions & 279 deletions
Large diffs are not rendered by default.

src/aind_metadata_mapper/fip/example_create_session.py

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
# Optional parameters with defaults:
3232
experimenter_full_name=["test_experimenter_1", "test_experimenter_2"],
3333
rig_id="428_9_B_20240617",
34-
task_version="1.0.0",
3534
iacuc_protocol="2115",
3635
mouse_platform_name="mouse_tube_foraging",
3736
active_mouse_platform=False,
@@ -62,13 +61,14 @@ def create_metadata(
6261
"test_experimenter_2",
6362
],
6463
rig_id: str = "428_9_0_20240617",
65-
task_version: str = "1.0.0",
6664
iacuc_protocol: str = "2115",
6765
mouse_platform_name: str = "mouse_tube_foraging",
6866
active_mouse_platform: bool = False,
69-
session_type: str = "Foraging_Photometry",
70-
task_name: str = "Fiber Photometry",
71-
notes: str = "Example configuration for fiber photometry rig",
67+
session_type: str = "FIB",
68+
notes: str = "",
69+
anaesthesia: Optional[str] = None,
70+
animal_weight_post: Optional[float] = None,
71+
animal_weight_prior: Optional[float] = None,
7272
) -> bool:
7373
"""Create fiber photometry metadata with default settings.
7474
@@ -79,13 +79,14 @@ def create_metadata(
7979
output_filename: Name of the output JSON file
8080
experimenter_full_name: List of experimenter names
8181
rig_id: Identifier for the experimental rig
82-
task_version: Version of the experimental task
8382
iacuc_protocol: Protocol identifier
8483
mouse_platform_name: Name of the mouse platform
8584
active_mouse_platform: Whether platform is active
8685
session_type: Type of experimental session
87-
task_name: Name of the experimental task
8886
notes: Additional notes about the session
87+
anaesthesia: Anaesthesia used
88+
animal_weight_post: Animal weight after session
89+
animal_weight_prior: Animal weight before session
8990
9091
Returns:
9192
bool: True if metadata was successfully
@@ -99,13 +100,14 @@ def create_metadata(
99100
"output_directory": str(output_directory),
100101
"output_filename": output_filename,
101102
"rig_id": rig_id,
102-
"task_version": task_version,
103103
"iacuc_protocol": iacuc_protocol,
104104
"mouse_platform_name": mouse_platform_name,
105105
"active_mouse_platform": active_mouse_platform,
106106
"session_type": session_type,
107-
"task_name": task_name,
108107
"notes": notes,
108+
"anaesthesia": anaesthesia,
109+
"animal_weight_post": animal_weight_post,
110+
"animal_weight_prior": animal_weight_prior,
109111
"data_streams": [
110112
{
111113
"stream_start_time": None,
@@ -184,7 +186,7 @@ def create_metadata(
184186
{
185187
"name": "Bonsai",
186188
"parameters": {},
187-
"url": "",
189+
"url": "https://github.com/AllenNeuralDynamics/PavlovianCond_Bonsai/tree/dafd7dfe0f347f781e91466b3d16b83cf32f8b6d", # noqa E501
188190
"version": "",
189191
}
190192
],
@@ -232,6 +234,32 @@ def create_metadata(
232234
default="session_fip.json",
233235
help="Name of the output JSON file (default: session_fip.json)",
234236
)
237+
parser.add_argument(
238+
"--active-mouse-platform",
239+
action="store_true",
240+
help="Whether the mouse platform was active",
241+
)
242+
parser.add_argument(
243+
"--anaesthesia", type=str, default=None, help="Anaesthesia used"
244+
)
245+
parser.add_argument(
246+
"--animal-weight-post",
247+
type=float,
248+
default=None,
249+
help="Animal weight after session",
250+
)
251+
parser.add_argument(
252+
"--animal-weight-prior",
253+
type=float,
254+
default=None,
255+
help="Animal weight before session",
256+
)
257+
parser.add_argument(
258+
"--mouse-platform-name",
259+
type=str,
260+
default="mouse_tube_foraging",
261+
help="Name of the mouse platform",
262+
)
235263

236264
args = parser.parse_args()
237265

@@ -240,6 +268,11 @@ def create_metadata(
240268
data_directory=args.data_directory,
241269
output_directory=args.output_directory,
242270
output_filename=args.output_filename,
271+
active_mouse_platform=args.active_mouse_platform,
272+
anaesthesia=args.anaesthesia,
273+
animal_weight_post=args.animal_weight_post,
274+
animal_weight_prior=args.animal_weight_prior,
275+
mouse_platform_name=args.mouse_platform_name,
243276
)
244277

245278
output_path = args.output_directory / args.output_filename

src/aind_metadata_mapper/fip/models.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ class JobSettings(BaseJobSettings):
3636
IACUC protocol identifier
3737
notes : str
3838
Session notes
39+
anaesthesia : Optional[str]
40+
Anaesthesia used
41+
animal_weight_post : Optional[float]
42+
Animal weight after session
43+
animal_weight_prior : Optional[float]
44+
Animal weight before session
3945
protocol_id : List[str], optional
4046
List of protocol identifiers, defaults to empty list
4147
data_directory : Optional[Union[str, Path]], optional
@@ -60,6 +66,9 @@ class JobSettings(BaseJobSettings):
6066
session_type: str = "FIB"
6167
iacuc_protocol: str
6268
notes: str
69+
anaesthesia: Optional[str] = None
70+
animal_weight_post: Optional[float] = None
71+
animal_weight_prior: Optional[float] = None
6372

6473
# Optional Session fields with defaults
6574
protocol_id: List[str] = []

src/aind_metadata_mapper/fip/session.py

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,51 @@
4040

4141
@dataclass
4242
class FiberData:
43-
"""Intermediate data model for fiber photometry data."""
43+
"""Intermediate data model for fiber photometry data.
44+
45+
This model holds the extracted and processed data before final
46+
transformation into a Session object. It serves as a structured
47+
intermediate representation of the fiber photometry session data.
48+
49+
Parameters
50+
----------
51+
start_time : datetime
52+
Session start time from fiber photometry files
53+
end_time : Optional[datetime]
54+
Session end time from fiber photometry files
55+
data_files : List[Path]
56+
List of paths to fiber photometry data files
57+
timestamps : List[float]
58+
List of timestamps from fiber photometry recordings
59+
light_source_configs : List[dict]
60+
List of light source configuration dictionaries
61+
detector_configs : List[dict]
62+
List of detector configuration dictionaries
63+
fiber_configs : List[dict]
64+
List of fiber configuration dictionaries
65+
subject_id : str
66+
Subject identifier
67+
experimenter_full_name : List[str]
68+
List of experimenter names
69+
rig_id : str
70+
Identifier for the experimental rig
71+
iacuc_protocol : str
72+
IACUC protocol number
73+
notes : str
74+
Additional notes about the session
75+
mouse_platform_name : str
76+
Name of the mouse platform used
77+
active_mouse_platform : bool
78+
Whether the mouse platform was active
79+
session_type : str
80+
Type of session (e.g. "FIB")
81+
anaesthesia : Optional[str]
82+
Anaesthesia used, if any
83+
animal_weight_post : Optional[float]
84+
Animal weight after session
85+
animal_weight_prior : Optional[float]
86+
Animal weight before session
87+
"""
4488

4589
start_time: datetime
4690
end_time: Optional[datetime]
@@ -56,6 +100,10 @@ class FiberData:
56100
notes: str
57101
mouse_platform_name: str
58102
active_mouse_platform: bool
103+
session_type: str
104+
anaesthesia: Optional[str]
105+
animal_weight_post: Optional[float]
106+
animal_weight_prior: Optional[float]
59107

60108

61109
class FIBEtl(GenericEtl[JobSettings]):
@@ -141,6 +189,10 @@ def _extract(self) -> FiberData:
141189
notes=settings.notes,
142190
mouse_platform_name=settings.mouse_platform_name,
143191
active_mouse_platform=settings.active_mouse_platform,
192+
session_type=settings.session_type,
193+
anaesthesia=settings.anaesthesia,
194+
animal_weight_post=settings.animal_weight_post,
195+
animal_weight_prior=settings.animal_weight_prior,
144196
)
145197

146198
def _transform(self, fiber_data: FiberData) -> Session:
@@ -177,14 +229,17 @@ def _transform(self, fiber_data: FiberData) -> Session:
177229
experimenter_full_name=fiber_data.experimenter_full_name,
178230
session_start_time=fiber_data.start_time,
179231
session_end_time=fiber_data.end_time,
180-
session_type="FIB",
232+
session_type=fiber_data.session_type,
181233
rig_id=fiber_data.rig_id,
182234
subject_id=fiber_data.subject_id,
183235
iacuc_protocol=fiber_data.iacuc_protocol,
184236
notes=fiber_data.notes,
185237
data_streams=[stream],
186238
mouse_platform_name=fiber_data.mouse_platform_name,
187239
active_mouse_platform=fiber_data.active_mouse_platform,
240+
anaesthesia=fiber_data.anaesthesia,
241+
animal_weight_post=fiber_data.animal_weight_post,
242+
animal_weight_prior=fiber_data.animal_weight_prior,
188243
)
189244

190245
return session

0 commit comments

Comments
 (0)