Skip to content

Commit

Permalink
Merge pull request #22 from catalystneuro/add_subject_metadata
Browse files Browse the repository at this point in the history
Add subject metadata and generate session description for each session
  • Loading branch information
alessandratrapani authored Dec 10, 2024
2 parents 57f96cd + 9d9cee0 commit e84014c
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 22 deletions.
1 change: 1 addition & 0 deletions src/cai_lab_to_nwb/zaki_2024/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
get_freezing_output_file_path,
)
from .define_conversion_parameters import update_conversion_parameters_yaml
from .generate_session_description import generate_session_description
5 changes: 5 additions & 0 deletions src/cai_lab_to_nwb/zaki_2024/utils/conversion_parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Ca_EEG2-1:
imaging_folder_path: D:\Ca_EEG_Experiment\Ca_EEG2-1\Ca_EEG2-1_Sessions\Ca_EEG2-1_FC\10_11_24
minian_folder_path: D:\Ca_EEG_Calcium\Ca_EEG2-1\Ca_EEG2-1_FC\minian
output_dir_path: D:\cai_lab_conversion_nwb
session_description: 'Fear Conditioning session: after a baseline period of 2
min, mouse received three 2s foot shocks of 1.5, with an intershock interval
of 1 min. Then, 30 s after the final shock, the mice were removed and returned
to the vivarium. Context: overhead external light, external fan at medium level,
box fan on, even grid floor, acetic acid 1pct scent'
session_id: Ca_EEG2-1_FC
shock_stimulus:
shock_amplitude: 1.5
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import re
import yaml

from source_data_path_resolver import *
from .source_data_path_resolver import *
from .generate_session_description import generate_session_description


def update_conversion_parameters_yaml(
Expand Down Expand Up @@ -55,7 +56,7 @@ def update_conversion_parameters_yaml(
sleep_classification_file_path = None
video_file_path = get_video_file_path(subject_id, session_id, data_dir_path)
freezing_output_file_path = get_freezing_output_file_path(subject_id, session_id, data_dir_path)
if session_type == "FC":
if session_type == "FC" or session_type == "Recall1":
shock_amplitude = subjects_df["Amplitude"][subjects_df["Mouse"] == subject_id].to_numpy()[0]
shock_amplitude = float(re.findall(r"[-+]?\d*\.\d+|\d+", shock_amplitude)[0])
shock_stimulus = dict(
Expand All @@ -65,13 +66,18 @@ def update_conversion_parameters_yaml(
shock_stimulus = None
imaging_folder_path = get_imaging_folder_path(subject_id, session_id, data_dir_path, time_str, date_str)
minian_folder_path = get_miniscope_folder_path(subject_id, session_id, data_dir_path)

session_description = generate_session_description(
experiment_design_file_path=experiment_design_file_path, subject_id=subject_id, session_type=session_type
)
session_to_nwb_kwargs_per_session = {
session_id: {
"output_dir_path": str(output_dir_path),
"subject_id": subject_id,
"session_id": session_id,
"date_str": date_str,
"time_str": time_str,
"session_description": session_description,
"experiment_dir_path": str(experiment_dir_path),
"imaging_folder_path": str(imaging_folder_path) if imaging_folder_path else None,
"minian_folder_path": str(minian_folder_path) if minian_folder_path else None,
Expand Down Expand Up @@ -103,7 +109,7 @@ def update_conversion_parameters_yaml(

if __name__ == "__main__":
update_conversion_parameters_yaml(
subject_id="Ca_EEG2-1",
subject_id="Ca_EEG3-4",
data_dir_path=Path("D:/"),
output_dir_path=Path("D:/cai_lab_conversion_nwb/"),
experiment_design_file_path=Path("D:/Ca_EEG_Design.xlsx"),
Expand Down
40 changes: 40 additions & 0 deletions src/cai_lab_to_nwb/zaki_2024/utils/generate_session_description.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from pathlib import Path
from typing import Union
import pandas as pd
import re


def generate_session_description(experiment_design_file_path: Union[Path, str], subject_id: str, session_type: str):
subjects_df = pd.read_excel(experiment_design_file_path)
subject_df = subjects_df[subjects_df["Mouse"] == subject_id]
shock_amplitude = subject_df["Amplitude"].to_numpy()[0]
shock_amplitude = float(re.findall(r"[-+]?\d*\.\d+|\d+", shock_amplitude)[0])

Contexts = {
"A": "overhead external light, external fan off, box fan on, smooth floor, white curve insert, simple green 5pct scent",
"B": "overhead external light, external fan off, box fan on, bath mat floor, A frame insert, ethanol 70pct scent",
"S": "overhead external light, external fan at medium level, box fan on, even grid floor, acetic acid 1pct scent",
}

session_descriptions = {
"NeutralExposure": f"Neutral Exposure session: mouse was exposed to a neutral context for 10 min to explore. Context: {Contexts["A"]}",
"FC": f"Fear Conditioning session: after a baseline period of 2 min, mouse received three 2s foot shocks of {shock_amplitude}, with an intershock interval of 1 min. Then, 30 s after the final shock, the mice were removed and returned to the vivarium. Context: {Contexts["S"]}",
"Recall1": f"First Recall session: mouse was placed in shock context for 5 min. Context: {Contexts['S']}",
"Recall2": f"Second Recall session: mouse was placed in {subject_df["Test_2"].to_numpy()[0]} context for 5 min. Context: {Contexts[subject_df["Test_2_ctx"].to_numpy()[0]]}",
"Recall3": f"Third Recall session: mouse was placed in {subject_df["Test_3"].to_numpy()[0]} context for 5 min. Context: {Contexts[subject_df["Test_3_ctx"].to_numpy()[0]]}",
"Offline": f"After Neutral Exposure and Fear Conditioning sessions, mice were taken out of the testing chambers and immediately placed in their homecage (scope was not removed).The homecage was placed in a dark grey storage bin with a webcam on top of the bin, taped to a wooden plank, looking down into the homecage. Mouse behavior and calcium were recorded for an hour.",
}
if "Offline" in session_type:
session_type = "Offline"

return session_descriptions[session_type]


if __name__ == "__main__":
experiment_design_file_path = Path("D:/Ca_EEG_Design.xlsx")
subject_id = "Ca_EEG3-4"
session_type = "NeutralExposure"
session_description = generate_session_description(
experiment_design_file_path=experiment_design_file_path, subject_id=subject_id, session_type=session_type
)
print(session_description)
4 changes: 3 additions & 1 deletion src/cai_lab_to_nwb/zaki_2024/zaki_2024_convert_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ def session_to_nwb(
session_id: str,
date_str: str,
time_str: str,
session_description: str,
stub_test: bool = False,
verbose: bool = True,
verbose: bool = False,
experiment_dir_path: Union[str, Path] = None,
imaging_folder_path: Union[str, Path] = None,
minian_folder_path: Union[str, Path] = None,
Expand Down Expand Up @@ -237,6 +238,7 @@ def session_to_nwb(
metadata = dict_deep_update(metadata, editable_metadata)

metadata["Subject"]["subject_id"] = subject_id
metadata["NWBFile"]["session_description"] = session_description

# Run conversion
converter.run_conversion(
Expand Down
59 changes: 41 additions & 18 deletions src/cai_lab_to_nwb/zaki_2024/zaki_2024_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,22 @@ NWBFile:
- aversive
related_publications:
- https://doi.org/10.1038/s41586-024-08168-4
session_description:
In memory-linking behavioural experiments, mice were exposed to the neutral context for 10 min to explore.
During aversive encoding, after a baseline period of 2 min, mice received three 2 s foot shocks of either amplitude
0.25 mA (low-shock) or 1.5 mA (high-shock), with an intershock interval of 1 min.
Then, 30 s after the final shock, the mice were removed and returned to the vivarium.
On the next 3 days, the mice were tested in the previously experienced aversive and neutral contexts,
as well as a completely novel context that they had not been exposed to previously, for 5 min each.
The features of the neutral and novel contexts were counter-balanced and were made up of different olfactory,
auditory, lighting and tactile cues.
The aversive context was always the same with distinct cues from the neutral and novel contexts.
In the low- versus high-shock experiments mice were tested in the aversive context first,
followed by testing in the neutral and novel context counter-balanced;
half of the mice received neutral recall and then novel-context exposure the next day,
and the other half received novel-context exposure and then neutral recall.
experiment_description:
Simultaneous calcium imaging with Miniscopes and EEG/EMG experiment during retrospective memory-linking behavioral paradigm,
to test whether ensemble co-reactivation is sleep-state specific
to test whether ensemble co-reactivation is sleep-state specific.
Mice were exposed to the neutral context for 10 min to explore.
During aversive encoding, after a baseline period of 2 min, mice received three 2 s foot shocks of either amplitude
0.25 mA (low-shock) or 1.5 mA (high-shock), with an intershock interval of 1 min.
Then, 30 s after the final shock, the mice were removed and returned to the vivarium.
On the next 3 days, the mice were tested in the previously experienced aversive and neutral contexts,
as well as a completely novel context that they had not been exposed to previously, for 5 min each.
The features of the neutral and novel contexts were counter-balanced and were made up of different olfactory,
auditory, lighting and tactile cues.
The aversive context was always the same with distinct cues from the neutral and novel contexts.
In the low- versus high-shock experiments mice were tested in the aversive context first,
followed by testing in the neutral and novel context counter-balanced;
half of the mice received neutral recall and then novel-context exposure the next day,
and the other half received novel-context exposure and then neutral recall.
institution: Icahn School of Medicine at Mount Sinai
lab: Cai
experimenter:
Expand All @@ -35,14 +34,38 @@ NWBFile:
Mice were anaesthetized with 1 to 2% isoflurane for surgical procedures and placed into a stereotaxic frame (David Kopf Instruments).
Eye ointment was applied to prevent desiccation, and the mice were kept on a heated pad to prevent hypothermia.
Surgery was performed using aseptic technique. After surgery, carprofen (5mg per kg) was administered every day for the following 3 days,
and ampicillin (20mg per kg) was administered every day for the next 7days.
For calcium imaging experiments, dexamethasone (0.2mg per kg) was also administered for the following 7days.
and ampicillin (20mg per kg) was administered every day for the next 7days.
For calcium imaging experiments with EEG/EMG implants, mice underwent three serial procedures spaced around 2 weeks apart.
During the first surgery, mice had 300 nl of AAV1-Syn-GCaMP6f injected into dorsal CA1 (AP, −2 mm; ML, +1.5 mm; DV, −1.2 mm),
the incision was sutured after the surgery.
Then, 2 weeks later during a second surgery, mice had their overlying cortex aspirated and a GRIN lens was implanted above the injection site.
This involved aspirating the cortex with a 27-gauge blunt syringe needle attached to a vacuum pump, constantly irrigating with cortex buffer.
When the striations of the corpus callosum were visible, a 30-gauge needle replaced the 27-gauge needle for finer-tuned aspiration.
Once most of corpus callosum was removed, bleeding was controlled using surgical foam (Surgifoam),
and a 1 mm diameter x 4 mm length GRIN lens (GRINTECH) was slowly lowered into the craniotomy.
The lens was fixed with cyanoacrylate, and dental acrylic was applied to cement the implant in place and cover the exposed skull.
The top of the exposed lens was covered with Kwik-Sil (World Precision Instruments) and then dental cement.
During this same surgery, a wireless telemetry probe (HD-X02, Data Science International) was implanted with EEG and EMG wires.
Two EMG wires were placed into the left trapezius muscle.
One EEG wire was implanted between the skull and dura mater above the dorsal hippocampus on the contralateral hemisphere to the GRIN lens
(left hemisphere; AP, −2 mm; ML, −1.5 mm), and a reference EEG wire was implanted between the skull and the dura on the right hemisphere overlying the prefrontal cortex (AP, +1.75 mm; ML, −0.5 mm).
Cyanoacrylate and dental cement fixed the GRIN lens, anchor screw, and EEG wires in place.
The telemetry probes were implanted during this second surgery to minimize the time mice needed to live with the implant.
During the third procedure, the mice were returned to implant the baseplate.
The Miniscope with an attached baseplate was lowered near the implanted lens, with the field of view monitored in real-time on a computer.
The Miniscope was rotated until a well-exposed field of view was observed, at which point the baseplate was fixed to the implant with cyanoacrylate and dental cement.
virus:
AAV1-Syn-GCaMP6f was injected into dorsal CA1 of the hippocampus on the right hemisphere (AP, −2 mm; ML, +1.5 mm; DV, −1.2 mm)
Subject:
species: Mus musculus
age: P12W/P15W # in ISO 8601, such as "P1W2D"
description: Adult C57BL/6J wild-type mice from Jackson Laboratories were used.
Mice ordered from Jackson arrived group-housed in cages of 4 mice/cage and were singly housed for the experiment.
Mice were ordered to arrive at 8-9 weeks of age and underwent behavioral testing about 4-6 weeks after the arrival date.
All experimental procedures were approved by the Icahn School of Medicine at Mount Sinai’s IACUC.
age: P12W/P18W
sex: M
strain: C57BL/6J
genotype: wild-type
Ophys:
OnePhotonSeries:
- name: OnePhotonSeries
Expand Down

0 comments on commit e84014c

Please sign in to comment.