diff --git a/pyproject.toml b/pyproject.toml index 8e69cf7..eb48e01 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,7 @@ classifiers = [ dependencies = [ "neuroconv==0.6.6", "ndx-events==0.2.0", + "pymatreader==1.0.0" "spikeinterface==0.101.2" ] diff --git a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_nwbconverter.py b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_nwbconverter.py index cc67c8f..7d0a0ea 100644 --- a/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_nwbconverter.py +++ b/src/schneider_lab_to_nwb/zempolich_2024/zempolich_2024_nwbconverter.py @@ -1,4 +1,6 @@ """Primary NWBConverter class for this dataset.""" +from pathlib import Path +from pymatreader import read_mat from neuroconv import NWBConverter from neuroconv.datainterfaces import ( PhySortingInterface, @@ -25,3 +27,17 @@ class Zempolich2024NWBConverter(NWBConverter): Optogenetic=Zempolich2024OptogeneticInterface, ISOI=Zempolich2024IntrinsicSignalOpticalImagingInterface, ) + + def temporally_align_data_interfaces(self): + """Align timestamps between data interfaces. + + It is called by run_conversion() after the data interfaces have been initialized but before the data is added + to the NWB file. + In its current implementation, this method aligns timestamps between the behavior and video data interfaces. + """ + behavior_interface = self.data_interface_objects["Behavior"] + behavior_file_path = Path(behavior_interface.source_data["file_path"]) + file = read_mat(behavior_file_path) + cam1_timestamps, cam2_timestamps = file["continuous"]["cam"]["time"] + self.data_interface_objects["VideoCamera1"].set_aligned_timestamps([cam1_timestamps]) + self.data_interface_objects["VideoCamera2"].set_aligned_timestamps([cam2_timestamps])