Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shock stimuli interface and metadata #17

Merged
merged 8 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/cai_lab_to_nwb/zaki_2024/interfaces/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
from .minian_interface import MinianSegmentationInterface, MinianMotionCorrectionInterface
from .zaki_2024_sleep_classification_interface import Zaki2024SleepClassificationInterface
from .miniscope_imaging_interface import MiniscopeImagingInterface
from .zaki_2024_shock_stimuli_interface import Zaki2024ShockStimuliInterface
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""Primary class for converting experiment-specific behavior."""

from pynwb.file import NWBFile

from neuroconv.basedatainterface import BaseDataInterface
from neuroconv.utils import DeepDict
from typing import Optional, List
from pynwb.epoch import TimeIntervals


class Zaki2024ShockStimuliInterface(BaseDataInterface):
"""Adds annotated events of shock times."""

keywords = ["behavior", "sleep stages"]

def __init__(self, verbose: bool = False):

self.verbose = verbose
super().__init__()

def get_metadata(self) -> DeepDict:
# Automatically retrieve as much metadata as possible from the source files available
metadata = super().get_metadata()

return metadata

def add_to_nwbfile(
self,
nwbfile: NWBFile,
shock_amplitude: float,
shock_times: List = [120.0, 180.0, 240.0],
alessandratrapani marked this conversation as resolved.
Show resolved Hide resolved
shock_duration: float = 2.0,
metadata: Optional[dict] = None,
):

description = (
"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. "
"All testing was done in Med Associates chambers. "
)

shock_stimuli = TimeIntervals(name="ShockStimuli", description=description)
column_description = "Shock amplitude in mA"
shock_stimuli.add_column(name="shock_amplitude", description=column_description)
for start_time in shock_times:
shock_stimuli.add_interval(
start_time=start_time, stop_time=start_time + shock_duration, shock_amplitude=shock_amplitude
)

nwbfile.add_time_intervals(shock_stimuli)
alessandratrapani marked this conversation as resolved.
Show resolved Hide resolved
21 changes: 19 additions & 2 deletions src/cai_lab_to_nwb/zaki_2024/zaki_2024_convert_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def session_to_nwb(
include_sleep_classification: bool = True,
include_behavioral_video: bool = True,
include_eeg_emg_signals: bool = True,
include_shock_times: bool = False,
):
print(f"Converting session {session_id}")
alessandratrapani marked this conversation as resolved.
Show resolved Hide resolved
if verbose:
Expand All @@ -63,6 +64,8 @@ def session_to_nwb(
experiment_dir_path = data_dir_path / "Ca_EEG_Experiment" / subject_id / (subject_id + "_Sessions") / session_id
include_eeg_emg_signals = False
include_sleep_classification = False
if "FC" in session_id:
include_shock_times = True

# Add Imaging
folder_path = experiment_dir_path / date_str / time_str
Expand Down Expand Up @@ -144,6 +147,20 @@ def session_to_nwb(
elif verbose and not sleep_classification_file_path.is_file():
print(f"No sleep classification output csv file found at {sleep_classification_file_path}")

# Add Shock Stimuli times for FC sessions
if include_shock_times:
import re

subjects_df = pd.read_excel(data_dir_path / "Ca_EEG_Design.xlsx")
alessandratrapani marked this conversation as resolved.
Show resolved Hide resolved
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_times = [120.0, 180.0, 240.0]
shock_duration = 2.0
source_data.update(ShockStimuli=dict())
conversion_options.update(
ShockStimuli=dict(shock_times=shock_times, shock_amplitude=shock_amplitude, shock_duration=shock_duration)
)

converter = Zaki2024NWBConverter(source_data=source_data)

# Add datetime to conversion
Expand Down Expand Up @@ -182,10 +199,10 @@ def session_to_nwb(
# Parameters for conversion
data_dir_path = Path("D:/")
subject_id = "Ca_EEG3-4"
task = "NeutralExposure"
task = "FC"
session_id = subject_id + "_" + task
output_dir_path = Path("D:/cai_lab_conversion_nwb/")
stub_test = True
stub_test = False
session_times_file_path = data_dir_path / "Ca_EEG_Experiment" / subject_id / (subject_id + "_SessionTimes.csv")
df = pd.read_csv(session_times_file_path)
session_row = df[df["Session"] == task].iloc[0]
Expand Down
54 changes: 29 additions & 25 deletions src/cai_lab_to_nwb/zaki_2024/zaki_2024_metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,48 @@
NWBFile:
keywords:
- hippocampus
- memory integration
- learning
h-mayorquin marked this conversation as resolved.
Show resolved Hide resolved
- memory-linking
- ensemble
- reactivation
- co-firing
- co-activity
- offline periods
- sleep
- stress
- PTSD
- aversive
related_publications:
- https://www.biorxiv.org/content/10.1101/2023.03.13.532469v2
- https://doi.org/10.1038/s41586-024-08168-4
session_description:
A rich text description of the experiment. Can also just be the abstract of the publication.
In memory-linking behavioural experiments, mice were exposed to the neutral context for 10 min to explore.
alessandratrapani marked this conversation as resolved.
Show resolved Hide resolved
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
institution: Icahn School of Medicine at Mount Sinai
lab: Cai
experimenter:
- Cai, Denise
h-mayorquin marked this conversation as resolved.
Show resolved Hide resolved
- Morales-Rodriguez, Denisse
- Bacon, Madeline E.
- Ko, BumJin
- Francisco, Taylor R.
- LaBanca, Alexa R.
- Sompolpong, Patlapa
- Dong, Zhe
- Lamsifer, Sophia
- Chen, Hung-Tu
- Carrillo Segura, Simón
- Christenson Wick, Zoé
- Silva, Alcino J.
- Rajan, Kanaka
- van der Meer, Matthijs
- Fenton, André
- Shuman, Tristan
- Zaki, Yosif
surgery:
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.
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"
sex: U # One of M, F, U, or O
sex: M
Ophys:
OnePhotonSeries:
- name: OnePhotonSeries
Expand Down
2 changes: 2 additions & 0 deletions src/cai_lab_to_nwb/zaki_2024/zaki_2024_nwbconverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Zaki2024SleepClassificationInterface,
MiniscopeImagingInterface,
MinianMotionCorrectionInterface,
Zaki2024ShockStimuliInterface,
)


Expand All @@ -28,6 +29,7 @@ class Zaki2024NWBConverter(NWBConverter):
EDFSignals=Zaki2024EDFInterface,
FreezingBehavior=EzTrackFreezingBehaviorInterface,
Video=VideoInterface,
ShockStimuli=Zaki2024ShockStimuliInterface,
)


Expand Down
Loading