From 3e24b085aa9f3b2d4933da5ca600f108a58f8a79 Mon Sep 17 00:00:00 2001 From: pauladkisson Date: Mon, 9 Dec 2024 09:16:23 -0800 Subject: [PATCH 1/9] added video --- .../zempolich_2024_convert_session.py | 24 +++++++++---------- .../zempolich_2024_metadata.yaml | 16 ++++++------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_session.py b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_session.py index 30ddd4e..c77bbb9 100644 --- a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_session.py +++ b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_session.py @@ -80,10 +80,10 @@ def session_to_nwb( conversion_options.update(dict(Behavior=dict())) # Add Video(s) - # for i, video_file_path in enumerate(video_file_paths): - # metadata_key_name = f"VideoCamera{i+1}" - # source_data.update({metadata_key_name: dict(file_paths=[video_file_path], metadata_key_name=metadata_key_name)}) - # conversion_options.update({metadata_key_name: dict()}) + for i, video_file_path in enumerate(video_file_paths): + metadata_key_name = f"VideoCamera{i+1}" + source_data.update({metadata_key_name: dict(file_paths=[video_file_path], metadata_key_name=metadata_key_name)}) + conversion_options.update({metadata_key_name: dict()}) # Add Optogenetic if has_opto: @@ -110,10 +110,10 @@ def session_to_nwb( if has_ephys: conversion_options["Sorting"]["units_description"] = metadata["Sorting"]["units_description"] - # # Overwrite video metadata - # for i, video_file_path in enumerate(video_file_paths): - # metadata_key_name = f"VideoCamera{i+1}" - # metadata["Behavior"][metadata_key_name] = editable_metadata["Behavior"][metadata_key_name] + # Overwrite video metadata + for i, video_file_path in enumerate(video_file_paths): + metadata_key_name = f"VideoCamera{i+1}" + metadata["Behavior"][metadata_key_name] = editable_metadata["Behavior"][metadata_key_name] subject_id = behavior_file_path.name.split("_")[1] session_id = behavior_file_path.name.split("_")[2] @@ -168,7 +168,7 @@ def main(): # Example Session A1 Ephys + Behavior ephys_folder_path = data_dir_path / "A1_EphysFiles" / "m53" / "Day1_A1" behavior_file_path = data_dir_path / "A1_EphysBehavioralFiles" / "raw_m53_231029_001.mat" - video_folder_path = Path("") + video_folder_path = data_dir_path / "Videos" / "A1EphysVideos" / "m53" / "231029" intrinsic_signal_optical_imaging_folder_path = Path("") session_to_nwb( ephys_folder_path=ephys_folder_path, @@ -182,7 +182,7 @@ def main(): # Example Session A1 Ogen + Behavior behavior_file_path = data_dir_path / "A1_OptoBehavioralFiles" / "raw_m53_231013_001.mat" - video_folder_path = Path("") + video_folder_path = data_dir_path / "Videos" / "A1OptoVideos" / "m53" / "231013" intrinsic_signal_optical_imaging_folder_path = Path("") session_to_nwb( behavior_file_path=behavior_file_path, @@ -197,7 +197,7 @@ def main(): # Example Session M2 Ephys + Behavior ephys_folder_path = data_dir_path / "M2_EphysFiles" / "m74" / "M2_Day1" behavior_file_path = data_dir_path / "M2_EphysBehavioralFiles" / "raw_m74_240815_001.mat" - video_folder_path = Path("") + video_folder_path = data_dir_path / "Videos" / "M2EphysVideos" / "m74" / "240815" intrinsic_signal_optical_imaging_folder_path = Path("") session_to_nwb( ephys_folder_path=ephys_folder_path, @@ -212,7 +212,7 @@ def main(): # Example Session M2 Opto + Behavior behavior_file_path = data_dir_path / "M2_OptoBehavioralFiles" / "raw_m74_240809_001.mat" - video_folder_path = Path("") + video_folder_path = data_dir_path / "Videos" / "M2OptoVideos" / "m74" / "240809" intrinsic_signal_optical_imaging_folder_path = Path("") session_to_nwb( behavior_file_path=behavior_file_path, diff --git a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_metadata.yaml b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_metadata.yaml index b626bfd..eda03b2 100644 --- a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_metadata.yaml +++ b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_metadata.yaml @@ -101,14 +101,14 @@ Behavior: - name: endZone_ThresholdVector description: Position of ending/exit position of target zone on a given trial (in raw encoder values corresponding to value read out by quadrature encoder). dtype: float64 - # VideoCamera1: - # - name: video_camera_1 - # description: Two IR video cameras (AAK CA20 600TVL 2.8MM) were used to monitor the experiments from different angles of interest, allowing for offline analysis of body movements, pupillometry, and other behavioral data as necessary. Camera 1 is a side angle view of the mouse. - # unit: Frames - # VideoCamera2: - # - name: video_camera_2 - # description: Two IR video cameras (AAK CA20 600TVL 2.8MM) were used to monitor the experiments from different angles of interest, allowing for offline analysis of body movements, pupillometry, and other behavioral data as necessary. Camera 2 is a zoomed-in view of the pupil of the mouse. - # unit: Frames + VideoCamera1: + - name: video_camera_1 + description: Two IR video cameras (AAK CA20 600TVL 2.8MM) were used to monitor the experiments from different angles of interest, allowing for offline analysis of body movements, pupillometry, and other behavioral data as necessary. Camera 1 is a side angle view of the mouse. + unit: Frames + VideoCamera2: + - name: video_camera_2 + description: Two IR video cameras (AAK CA20 600TVL 2.8MM) were used to monitor the experiments from different angles of interest, allowing for offline analysis of body movements, pupillometry, and other behavioral data as necessary. Camera 2 is a zoomed-in view of the pupil of the mouse. + unit: Frames Sorting: units_description: Neural spikes were sorted offline using Kilosort 2.5 and Phy2 software and manually curated to ensure precise spike time acquisition. From f5a2634df102f9473273fffa9bbcbb30daaa6658 Mon Sep 17 00:00:00 2001 From: pauladkisson Date: Mon, 9 Dec 2024 09:30:10 -0800 Subject: [PATCH 2/9] added isoi --- .../zempolich_2024_convert_session.py | 12 +++---- ...2024_intrinsic_signal_imaging_interface.py | 32 +++++++++---------- .../zempolich_2024_metadata.yaml | 10 +++--- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_session.py b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_session.py index c77bbb9..a774dac 100644 --- a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_session.py +++ b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_session.py @@ -92,8 +92,8 @@ def session_to_nwb( conversion_options["Behavior"]["normalize_timestamps"] = True # Add Intrinsic Signal Optical Imaging - # source_data.update(dict(ISOI=dict(folder_path=intrinsic_signal_optical_imaging_folder_path))) - # conversion_options.update(dict(ISOI=dict())) + source_data.update(dict(ISOI=dict(folder_path=intrinsic_signal_optical_imaging_folder_path))) + conversion_options.update(dict(ISOI=dict())) converter = Zempolich2024NWBConverter(source_data=source_data, verbose=verbose) metadata = converter.get_metadata() @@ -169,7 +169,7 @@ def main(): ephys_folder_path = data_dir_path / "A1_EphysFiles" / "m53" / "Day1_A1" behavior_file_path = data_dir_path / "A1_EphysBehavioralFiles" / "raw_m53_231029_001.mat" video_folder_path = data_dir_path / "Videos" / "A1EphysVideos" / "m53" / "231029" - intrinsic_signal_optical_imaging_folder_path = Path("") + intrinsic_signal_optical_imaging_folder_path = data_dir_path / "Intrinsic Imaging Data" / "m53" session_to_nwb( ephys_folder_path=ephys_folder_path, behavior_file_path=behavior_file_path, @@ -183,7 +183,7 @@ def main(): # Example Session A1 Ogen + Behavior behavior_file_path = data_dir_path / "A1_OptoBehavioralFiles" / "raw_m53_231013_001.mat" video_folder_path = data_dir_path / "Videos" / "A1OptoVideos" / "m53" / "231013" - intrinsic_signal_optical_imaging_folder_path = Path("") + intrinsic_signal_optical_imaging_folder_path = data_dir_path / "Intrinsic Imaging Data" / "m53" session_to_nwb( behavior_file_path=behavior_file_path, video_folder_path=video_folder_path, @@ -198,7 +198,7 @@ def main(): ephys_folder_path = data_dir_path / "M2_EphysFiles" / "m74" / "M2_Day1" behavior_file_path = data_dir_path / "M2_EphysBehavioralFiles" / "raw_m74_240815_001.mat" video_folder_path = data_dir_path / "Videos" / "M2EphysVideos" / "m74" / "240815" - intrinsic_signal_optical_imaging_folder_path = Path("") + intrinsic_signal_optical_imaging_folder_path = data_dir_path / "Intrinsic Imaging Data" / "m74" session_to_nwb( ephys_folder_path=ephys_folder_path, behavior_file_path=behavior_file_path, @@ -213,7 +213,7 @@ def main(): # Example Session M2 Opto + Behavior behavior_file_path = data_dir_path / "M2_OptoBehavioralFiles" / "raw_m74_240809_001.mat" video_folder_path = data_dir_path / "Videos" / "M2OptoVideos" / "m74" / "240809" - intrinsic_signal_optical_imaging_folder_path = Path("") + intrinsic_signal_optical_imaging_folder_path = data_dir_path / "Intrinsic Imaging Data" / "m74" session_to_nwb( behavior_file_path=behavior_file_path, video_folder_path=video_folder_path, diff --git a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_intrinsic_signal_imaging_interface.py b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_intrinsic_signal_imaging_interface.py index 8fe671c..40727b3 100644 --- a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_intrinsic_signal_imaging_interface.py +++ b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_intrinsic_signal_imaging_interface.py @@ -1,7 +1,7 @@ """Primary class for converting intrinsic signal optical imaging.""" from pynwb.file import NWBFile from pynwb.base import Images -from pynwb.image import GrayscaleImage, RGBImage +from pynwb.image import RGBImage from pynwb.device import Device from pydantic import DirectoryPath import numpy as np @@ -60,12 +60,12 @@ def get_metadata_schema(self) -> dict: def add_to_nwbfile(self, nwbfile: NWBFile, metadata: dict): # Read Data folder_path = self.source_data["folder_path"] - raw_image_path = folder_path / "BloodvesselPattern.tiff" - processed_image_path = folder_path / "IOS_imageOverlaidFinal.jpg" - with Image.open(raw_image_path) as image: - raw_image_array = np.array(image) - with Image.open(processed_image_path) as image: - processed_image_array = np.array(image) + overlaid_image_path = folder_path / "Overlaid.jpg" + target_image_path = folder_path / "Target.jpg" + with Image.open(overlaid_image_path) as image: + overlaid_image_array = np.array(image) + with Image.open(target_image_path) as image: + target_image_array = np.array(image) # Add Data to NWBFile isoi_metadata = metadata["IntrinsicSignalOpticalImaging"] @@ -74,20 +74,20 @@ def add_to_nwbfile(self, nwbfile: NWBFile, metadata: dict): name=isoi_metadata["Module"]["name"], description=isoi_metadata["Module"]["description"], ) - raw_image = GrayscaleImage( - name=isoi_metadata["RawImage"]["name"], - data=raw_image_array, - description=isoi_metadata["RawImage"]["description"], + overlaid_image = RGBImage( + name=isoi_metadata["OverlaidImage"]["name"], + data=overlaid_image_array, + description=isoi_metadata["OverlaidImage"]["description"], ) - processed_image = RGBImage( - name=isoi_metadata["ProcessedImage"]["name"], - data=processed_image_array, - description=isoi_metadata["ProcessedImage"]["description"], + target_image = RGBImage( + name=isoi_metadata["TargetImage"]["name"], + data=target_image_array, + description=isoi_metadata["TargetImage"]["description"], ) images = Images( name=isoi_metadata["Images"]["name"], description=isoi_metadata["Images"]["description"], - images=[raw_image, processed_image], + images=[overlaid_image, target_image], ) isoi_module.add(images) diff --git a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_metadata.yaml b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_metadata.yaml index eda03b2..064cb62 100644 --- a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_metadata.yaml +++ b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_metadata.yaml @@ -136,12 +136,12 @@ IntrinsicSignalOpticalImaging: Images: name: images description: Intrinsic signal optical images. - RawImage: - name: raw_image - description: Original image capture of ROI (blood vessel pattern) for intrinsic imaging. - ProcessedImage: - name: processed_image + OverlaidImage: + name: overlaid_image description: The primary auditory cortex was identified through tonotopic mapping using a temporally periodic acoustic stimulation consisting of sequences of single pure tones of ascending or descending frequencies (20 tones per sequence, 2 to 40kHz exponentially separated, 75dB SPL, 50ms tone duration, 500ms onset-to-onset interval). Tone sequences were delivered from a free-field speaker 10cm above the mouse and repeated 40-60 times (0.1Hz). To compute tonotopic maps, the time course of each pixel was first highpass filtered using a moving average (10s window). Next, a Fourier transform was computed to extract the phase and the power of the frequency component at the frequency of acoustic stimulation (0.1 Hz). The phase indicates the sound frequency driving the response of a pixel, and the power indicates the strength of its response. To account for the hemodynamic delay and compute maps of absolute tonotopy, the response time to ascending sequence of tones was subtracted from the response time to the descending sequence. From these maps of absolute tonotopy, equally spaced iso-frequency contour lines were extracted, color-coded for sound frequency, and overlaid on top of the image of the blood vessel pattern. + TargetImage: + name: target_image + description: The ephys probe target location is indicated by an ellipse overlaid on top of the blood vessel pattern image. Devices: - name: two_photon_microscope description: (Neurolabware) From 59b43545b5341fa433ae860fd71c7841116889cc Mon Sep 17 00:00:00 2001 From: pauladkisson Date: Mon, 9 Dec 2024 09:32:39 -0800 Subject: [PATCH 3/9] added isoi metadata --- .../zempolich_2024/zempolich_2024_metadata.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_metadata.yaml b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_metadata.yaml index 064cb62..235c6a9 100644 --- a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_metadata.yaml +++ b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_metadata.yaml @@ -144,8 +144,8 @@ IntrinsicSignalOpticalImaging: description: The ephys probe target location is indicated by an ellipse overlaid on top of the blood vessel pattern image. Devices: - name: two_photon_microscope - description: (Neurolabware) + description: Standard Microscope by Neurolabware. manufacturer: Neurolabware - name: intrinsic_signal_optical_imaging_laser - description: (ThorLabs) + description: ThorLabs 700nm fiber coupled LED (M700F3) driven by their basic LED driver (LEDD1B). manufacturer: ThorLabs From 1e719b6a50e47ff943b458c3eb6555384d174179 Mon Sep 17 00:00:00 2001 From: pauladkisson Date: Mon, 9 Dec 2024 11:30:19 -0800 Subject: [PATCH 4/9] added isoi and video to convert_all_sessions --- .../zempolich_2024_convert_all_sessions.py | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_all_sessions.py b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_all_sessions.py index 53e5594..92c5d74 100644 --- a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_all_sessions.py +++ b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_all_sessions.py @@ -106,21 +106,32 @@ def get_session_to_nwb_kwargs_per_session(*, data_dir_path: DirectoryPath): """ a1_ephys_path = data_dir_path / "A1_EphysFiles" a1_ephys_behavior_path = data_dir_path / "A1_EphysBehavioralFiles" + a1_ephys_video_path = data_dir_path / "Videos" / "A1EphysVideos" a1_opto_path = data_dir_path / "A1_OptoBehavioralFiles" + a1_opto_video_path = data_dir_path / "Videos" / "A1OptoVideos" m2_ephys_path = data_dir_path / "M2_EphysFiles" m2_ephys_behavior_path = data_dir_path / "M2_EphysBehavioralFiles" + m2_ephys_video_path = data_dir_path / "Videos" / "M2EphysVideos" m2_opto_path = data_dir_path / "M2_OptoBehavioralFiles" + m2_opto_video_path = data_dir_path / "Videos" / "M2OptoVideos" + intrinsic_signal_optical_imaging_path = data_dir_path / "Intrinsic Imaging Data" a1_kwargs = get_brain_region_kwargs( ephys_path=a1_ephys_path, ephys_behavior_path=a1_ephys_behavior_path, + ephys_video_path=a1_ephys_video_path, opto_path=a1_opto_path, + opto_video_path=a1_opto_video_path, + intrinsic_signal_optical_imaging_path=intrinsic_signal_optical_imaging_path, brain_region="A1", ) m2_kwargs = get_brain_region_kwargs( ephys_path=m2_ephys_path, ephys_behavior_path=m2_ephys_behavior_path, + ephys_video_path=m2_ephys_video_path, opto_path=m2_opto_path, + opto_video_path=m2_opto_video_path, + intrinsic_signal_optical_imaging_path=intrinsic_signal_optical_imaging_path, brain_region="M2", ) session_to_nwb_kwargs_per_session = a1_kwargs + m2_kwargs @@ -129,7 +140,13 @@ def get_session_to_nwb_kwargs_per_session(*, data_dir_path: DirectoryPath): def get_brain_region_kwargs( - ephys_path: DirectoryPath, ephys_behavior_path: DirectoryPath, opto_path: DirectoryPath, brain_region: str + ephys_path: DirectoryPath, + ephys_behavior_path: DirectoryPath, + opto_path: DirectoryPath, + ephys_video_path: DirectoryPath, + opto_video_path: DirectoryPath, + intrinsic_signal_optical_imaging_path: DirectoryPath, + brain_region: str, ): """Get the session_to_nwb kwargs for each session in the dataset for a given brain region. @@ -153,23 +170,33 @@ def get_brain_region_kwargs( for subject_dir in ephys_path.iterdir(): subject_id = subject_dir.name matched_behavior_paths = sorted(ephys_behavior_path.glob(f"raw_{subject_id}_*.mat")) + video_subject_path = ephys_video_path / subject_id + matched_video_paths = sorted(list(video_subject_path.iterdir())) + matched_isoi_path = intrinsic_signal_optical_imaging_path / subject_id sorted_session_dirs = sorted(subject_dir.iterdir()) - for ephys_folder_path, behavior_file_path in zip(sorted_session_dirs, matched_behavior_paths): + for ephys_folder_path, behavior_file_path, video_folder_path in zip( + sorted_session_dirs, matched_behavior_paths, matched_video_paths + ): session_to_nwb_kwargs = dict( ephys_folder_path=ephys_folder_path, behavior_file_path=behavior_file_path, brain_region=brain_region, - intrinsic_signal_optical_imaging_folder_path="", # TODO: Add intrinsic signal optical imaging folder path - video_folder_path="", # TODO: Add video folder path + intrinsic_signal_optical_imaging_folder_path=matched_isoi_path, + video_folder_path=video_folder_path, ) session_to_nwb_kwargs_per_session.append(session_to_nwb_kwargs) for behavior_file_path in opto_path.iterdir(): + split_behavior_file_path = behavior_file_path.name.split("_") + subject_id = split_behavior_file_path[1] + date = split_behavior_file_path[2] + video_folder_path = opto_video_path / subject_id / date + matched_isoi_path = intrinsic_signal_optical_imaging_path / subject_id session_to_nwb_kwargs = dict( behavior_file_path=behavior_file_path, brain_region=brain_region, has_opto=True, - intrinsic_signal_optical_imaging_folder_path="", # TODO: Add intrinsic signal optical imaging folder path - video_folder_path="", # TODO: Add video folder path + intrinsic_signal_optical_imaging_folder_path=matched_isoi_path, + video_folder_path=video_folder_path, ) session_to_nwb_kwargs_per_session.append(session_to_nwb_kwargs) return session_to_nwb_kwargs_per_session From 08a4305086974599010a7639bbc93edbe2e8b184 Mon Sep 17 00:00:00 2001 From: pauladkisson Date: Mon, 9 Dec 2024 11:31:21 -0800 Subject: [PATCH 5/9] updated docstrings --- .../zempolich_2024/zempolich_2024_convert_all_sessions.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_all_sessions.py b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_all_sessions.py index 92c5d74..9306820 100644 --- a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_all_sessions.py +++ b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_all_sessions.py @@ -156,8 +156,14 @@ def get_brain_region_kwargs( Path to the directory containing electrophysiology data for subjects. ephys_behavior_path : DirectoryPath Path to the directory containing electrophysiology behavior data files. + ephys_video_path : DirectoryPath + Path to the directory containing electrophysiology video data files. opto_path : DirectoryPath Path to the directory containing optogenetics behavior data files. + opto_video_path : DirectoryPath + Path to the directory containing optogenetics video data files. + intrinsic_signal_optical_imaging_path : DirectoryPath + Path to the directory containing intrinsic signal optical imaging data files. brain_region : str The brain region associated with the sessions. From 10c1ee533483eb0e204641314373f22ae91b55ba Mon Sep 17 00:00:00 2001 From: pauladkisson Date: Mon, 9 Dec 2024 14:12:26 -0800 Subject: [PATCH 6/9] updated pyproject to pin spikeinterface --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d701271..98641fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,8 @@ classifiers = [ dependencies = [ "neuroconv", "nwbinspector", - "ndx-events==0.2.0" + "ndx-events==0.2.0", + "spikeinterface>=101.1" ] [project.urls] From 252d344676f15831b73c4acb180514458129fa19 Mon Sep 17 00:00:00 2001 From: pauladkisson Date: Mon, 9 Dec 2024 14:15:10 -0800 Subject: [PATCH 7/9] updated notes --- .../zempolich_2024/zempolich_2024_notes.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_notes.md b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_notes.md index 4a304a5..c24b65d 100644 --- a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_notes.md +++ b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_notes.md @@ -3,6 +3,7 @@ ## Behavior ## Video +- M2EphysVideos/m80/240819 is missing video for Cam2 ## Optogenetics - is_opto_trial in the trials table is `np.logical_not(np.isnan(onset_times))` rather than reading from the .mat file @@ -12,9 +13,7 @@ ## Intrinsic Signal Optical Imaging - Just including raw blood vessel image and processed overlay + pixel locations bc including the isoi roi response series would really require an extension for context, but seems like it has limited reuse potential. - Used the Audette paper for description of overlay image. -- Need pixel locs for ephys -- Need device info for 2p microscope and red light laser -- Why is the overlaid image flipped left/right compared to the original? +- m73 is missing the target image ## Temporal Alignment - For session A1/m53/Day1 (raw_m53_231029_001.mat), @@ -32,12 +31,10 @@ ## Active Requests - Mice sexes -- Video for each session and ISOI data for each animal -- pixel locs for ephys -- ISOI device info for 2p microscope and red light laser +- target image for m73 +- Cam2 Video for M2EphysVideos/m80/240819 ## Questions for Midway Meeting - injection vs stimulation location(s) for A1 vs M2??? -- Why is the overlaid image flipped left/right compared to the original? - Want to split data into epochs: Active Behavior, Passive Listening, ??? What is happening post-2164? Before 1187s? - Double Check: Is it ok to normalize opto sessions to first encoder timestamp? From 046d20044e7d39dad69e0d06504a17dd70e19073 Mon Sep 17 00:00:00 2001 From: pauladkisson Date: Tue, 10 Dec 2024 15:18:16 -0800 Subject: [PATCH 8/9] updated dependency pins --- pyproject.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 98641fc..8e69cf7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,10 +15,9 @@ classifiers = [ ] dependencies = [ - "neuroconv", - "nwbinspector", + "neuroconv==0.6.6", "ndx-events==0.2.0", - "spikeinterface>=101.1" + "spikeinterface==0.101.2" ] [project.urls] From 11d1abcc9cb858912b1005356d7eb8646914c112 Mon Sep 17 00:00:00 2001 From: pauladkisson Date: Tue, 10 Dec 2024 15:25:15 -0800 Subject: [PATCH 9/9] updated isoi to use file_paths instead of folder_path --- .../zempolich_2024_convert_session.py | 4 +++- ..._2024_intrinsic_signal_imaging_interface.py | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_session.py b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_session.py index a774dac..0ee3ed6 100644 --- a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_session.py +++ b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_convert_session.py @@ -92,7 +92,9 @@ def session_to_nwb( conversion_options["Behavior"]["normalize_timestamps"] = True # Add Intrinsic Signal Optical Imaging - source_data.update(dict(ISOI=dict(folder_path=intrinsic_signal_optical_imaging_folder_path))) + overlaid_image_path = intrinsic_signal_optical_imaging_folder_path / "Overlaid.jpg" + target_image_path = intrinsic_signal_optical_imaging_folder_path / "Target.jpg" + source_data.update(dict(ISOI=dict(overlaid_image_path=overlaid_image_path, target_image_path=target_image_path))) conversion_options.update(dict(ISOI=dict())) converter = Zempolich2024NWBConverter(source_data=source_data, verbose=verbose) diff --git a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_intrinsic_signal_imaging_interface.py b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_intrinsic_signal_imaging_interface.py index 40727b3..8081a66 100644 --- a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_intrinsic_signal_imaging_interface.py +++ b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_intrinsic_signal_imaging_interface.py @@ -3,9 +3,10 @@ from pynwb.base import Images from pynwb.image import RGBImage from pynwb.device import Device -from pydantic import DirectoryPath +from pydantic import FilePath import numpy as np from PIL import Image +from pathlib import Path from neuroconv.basedatainterface import BaseDataInterface from neuroconv.tools import nwb_helpers @@ -16,15 +17,17 @@ class Zempolich2024IntrinsicSignalOpticalImagingInterface(BaseDataInterface): keywords = ("intrinsic signal optical imaging",) - def __init__(self, folder_path: DirectoryPath): + def __init__(self, overlaid_image_path: FilePath, target_image_path: FilePath): """Initialize the intrinsic signal optical imaging interface. Parameters ---------- - folder_path : DirectoryPath - Path to the folder containing the intrinsic signal optical imaging files. + overlaid_image_path : FilePath + Path to the intrinsic signal optical imaging overlaid image file. + target_image_path : FilePath + Path to the intrinsic signal optical imaging target image file. """ - super().__init__(folder_path=folder_path) + super().__init__(overlaid_image_path=overlaid_image_path, target_image_path=target_image_path) def get_metadata_schema(self) -> dict: metadata_schema = super().get_metadata_schema() @@ -59,9 +62,8 @@ def get_metadata_schema(self) -> dict: def add_to_nwbfile(self, nwbfile: NWBFile, metadata: dict): # Read Data - folder_path = self.source_data["folder_path"] - overlaid_image_path = folder_path / "Overlaid.jpg" - target_image_path = folder_path / "Target.jpg" + overlaid_image_path = Path(self.source_data["overlaid_image_path"]) + target_image_path = Path(self.source_data["target_image_path"]) with Image.open(overlaid_image_path) as image: overlaid_image_array = np.array(image) with Image.open(target_image_path) as image: