From eb035e0338fb67fc04386f67e2272e782304e190 Mon Sep 17 00:00:00 2001 From: CodyCBakerPhD Date: Wed, 7 Jun 2023 20:25:17 +0000 Subject: [PATCH] fix icephys --- .../icephys/abf/abfdatainterface.py | 2 +- tests/test_on_data/test_gin_behavior.py | 16 ++++++------- tests/test_on_data/test_gin_icephys.py | 24 +++++++++++-------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/neuroconv/datainterfaces/icephys/abf/abfdatainterface.py b/src/neuroconv/datainterfaces/icephys/abf/abfdatainterface.py index 9e774c834..e2867210e 100644 --- a/src/neuroconv/datainterfaces/icephys/abf/abfdatainterface.py +++ b/src/neuroconv/datainterfaces/icephys/abf/abfdatainterface.py @@ -144,7 +144,7 @@ def get_metadata(self) -> dict: return metadata - def align_starting_time(self, aligned_starting_time: float): + def set_aligned_starting_time(self, aligned_starting_time: float): for reader in self.readers_list: number_of_segments = reader.header["nb_segment"][0] for segment_index in range(number_of_segments): diff --git a/tests/test_on_data/test_gin_behavior.py b/tests/test_on_data/test_gin_behavior.py index c9f227ada..a09ed3f39 100644 --- a/tests/test_on_data/test_gin_behavior.py +++ b/tests/test_on_data/test_gin_behavior.py @@ -142,7 +142,7 @@ def setUpClass(cls): cls.video_files = list((BEHAVIOR_DATA_PATH / "videos" / "CFR").iterdir()) cls.video_files.sort() cls.number_of_video_files = len(cls.video_files) - cls.segment_starting_times = [0.0, 50.0, 100.0, 150.0, 175.0] + cls.aligned_segment_starting_times = [0.0, 50.0, 100.0, 150.0, 175.0] def _get_metadata(self): """TODO: temporary helper function to fetch new metadata each time; need to debug in follow-up.""" @@ -153,7 +153,7 @@ def _get_metadata(self): def test_real_videos(self): # TODO - merge this with the data mixin in follow-up for file_index, (file_path, segment_starting_time) in enumerate( - zip(self.video_files, self.segment_starting_times) + zip(self.video_files, self.aligned_segment_starting_times) ): self.file_index = file_index @@ -163,15 +163,15 @@ class VideoTestNWBConverter(NWBConverter): source_data = dict(Video=dict(file_paths=[file_path])) self.converter = VideoTestNWBConverter(source_data) self.interface = self.converter.data_interface_objects["Video"] - self.interface.align_segment_starting_times( - segment_starting_times=[self.segment_starting_times[self.file_index]] + self.interface.set_aligned_segment_starting_times( + aligned_segment_starting_times=[self.aligned_segment_starting_times[self.file_index]] ) - self.check_video_starting_times() + self.check_video_set_aligned_starting_times() self.check_video_custom_module() self.check_video_chunking() - def check_video_starting_times(self): + def check_video_set_aligned_starting_times(self): self._get_metadata() conversion_options = dict(Video=dict(external_mode=False)) nwbfile_path = OUTPUT_PATH / "check_video_starting_times.nwb" @@ -187,9 +187,9 @@ def check_video_starting_times(self): self.image_series = nwbfile.acquisition[self.image_series_name] if self.image_series.starting_time is not None: - assert self.segment_starting_times[self.file_index] == self.image_series.starting_time + assert self.aligned_segment_starting_times[self.file_index] == self.image_series.starting_time else: - assert self.segment_starting_times[self.file_index] == self.image_series.timestamps[0] + assert self.aligned_segment_starting_times[self.file_index] == self.image_series.timestamps[0] def check_video_custom_module(self): self._get_metadata() diff --git a/tests/test_on_data/test_gin_icephys.py b/tests/test_on_data/test_gin_icephys.py index fb460e1b6..48fb55354 100644 --- a/tests/test_on_data/test_gin_icephys.py +++ b/tests/test_on_data/test_gin_icephys.py @@ -62,26 +62,30 @@ class TestIcephysNwbConversions(unittest.TestCase): ) ] - def check_align_starting_time(self): # TODO - use the mixin class in the future + def check_set_aligned_starting_time(self): # TODO - use the mixin class in the future fresh_interface = self.data_interface_cls(file_paths=self.file_paths) - starting_time = 1.23 + aligned_starting_time = 1.23 relative_segment_starting_times = [[0.1]] - fresh_interface.align_segment_starting_times(segment_starting_times=relative_segment_starting_times) - fresh_interface.align_starting_time(starting_time=starting_time) + fresh_interface.set_aligned_segment_starting_times( + aligned_segment_starting_times=relative_segment_starting_times + ) + fresh_interface.set_aligned_starting_time(aligned_starting_time=aligned_starting_time) neo_reader_starting_times = [reader._t_starts for reader in fresh_interface.readers_list] expecting_starting_times = [[1.33]] self.assertListEqual(list1=neo_reader_starting_times, list2=expecting_starting_times) - def check_align_segment_starting_times(self): + def check_set_aligned_segment_starting_times(self): fresh_interface = self.data_interface_cls(file_paths=self.file_paths) - segment_starting_times = [[1.2]] - fresh_interface.align_segment_starting_times(segment_starting_times=segment_starting_times) + aligned_segment_starting_times = [[1.2]] + fresh_interface.set_aligned_segment_starting_times( + aligned_segment_starting_times=aligned_segment_starting_times + ) neo_reader_starting_times = [reader._t_starts for reader in fresh_interface.readers_list] - self.assertListEqual(list1=neo_reader_starting_times, list2=segment_starting_times) + self.assertListEqual(list1=neo_reader_starting_times, list2=aligned_segment_starting_times) @parameterized.expand(input=parameterized_recording_list, name_func=custom_name_func) def test_convert_abf_to_nwb(self, data_interface, interface_kwargs): @@ -116,8 +120,8 @@ class TestConverter(NWBConverter): # Test number of traces = n_electrodes * n_segments npt.assert_equal(len(nwbfile.acquisition), n_electrodes * n_segments) - self.check_align_starting_time() - self.check_align_segment_starting_times() + self.check_set_aligned_starting_time() + self.check_set_aligned_segment_starting_times() if __name__ == "__main__":