From f194ec20a7e48dc525718c7699728e03435ecbc1 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Fri, 27 Oct 2023 16:48:09 +0200 Subject: [PATCH 1/5] add radius as scaling instead of adding scaled data --- .../datainterfaces/behavior/fictrac/fictracdatainterface.py | 2 +- tests/test_on_data/test_behavior_interfaces.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/neuroconv/datainterfaces/behavior/fictrac/fictracdatainterface.py b/src/neuroconv/datainterfaces/behavior/fictrac/fictracdatainterface.py index 100d7c7d4..339dae249 100644 --- a/src/neuroconv/datainterfaces/behavior/fictrac/fictracdatainterface.py +++ b/src/neuroconv/datainterfaces/behavior/fictrac/fictracdatainterface.py @@ -220,7 +220,7 @@ def add_to_nwbfile( column_in_dat_file = data_dict["column_in_dat_file"] data = fictrac_data_df[column_in_dat_file].to_numpy() if self.radius is not None: - data = data * self.radius + spatial_series_kwargs["conversion"] = self.radius units = "meters" else: units = "radians" diff --git a/tests/test_on_data/test_behavior_interfaces.py b/tests/test_on_data/test_behavior_interfaces.py index eb2aa5b46..69c1d748b 100644 --- a/tests/test_on_data/test_behavior_interfaces.py +++ b/tests/test_on_data/test_behavior_interfaces.py @@ -63,6 +63,7 @@ def check_read_nwb(self, nwbfile_path: str): # This is currently structured to expected_units = "radians" assert spatial_series.unit == expected_units + assert spatial_series.conversion == 1.0 class TestFicTracDataInterfaceWithRadius(DataInterfaceTestMixin, unittest.TestCase): @@ -96,6 +97,7 @@ def check_read_nwb(self, nwbfile_path: str): # This is currently structured to assert reference_frame == spatial_series.reference_frame expected_units = "meters" assert spatial_series.unit == expected_units + assert spatial_series.conversion == self.interface.radius class TestFicTracDataInterfaceTiming(TemporalAlignmentMixin, unittest.TestCase): From 1a0725752b54df310bf679e60aec4b5ce34a3cb3 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Fri, 27 Oct 2023 16:51:02 +0200 Subject: [PATCH 2/5] Change log --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f53f5a32..a544a7a9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ * Added alignment methods to `FicTracDataInterface`. [PR #607](https://github.com/catalystneuro/neuroconv/pull/607) * Added alignment methods support to `MockRecordingInterface` [PR #611](https://github.com/catalystneuro/neuroconv/pull/611) * Added `NeuralynxNvtInterface`, which can read position tracking NVT files. [PR #580](https://github.com/catalystneuro/neuroconv/pull/580) +* Adding radius as a conversion factor in `FicTracDataInterface`. [PR #619](https://github.com/catalystneuro/neuroconv/pull/619) ### Fixes * Remove `starting_time` reset to default value (0.0) when adding the rate and updating the `photon_series_kwargs` or `roi_response_series_kwargs`, in `add_photon_series` or `add_fluorescence_traces`. [PR #595](https://github.com/catalystneuro/neuroconv/pull/595) From 60469e0518b362af143ea3b7a29b37d2128010e7 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Fri, 27 Oct 2023 16:58:49 +0200 Subject: [PATCH 3/5] best practice name for behavior module --- .../datainterfaces/behavior/fictrac/fictracdatainterface.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/neuroconv/datainterfaces/behavior/fictrac/fictracdatainterface.py b/src/neuroconv/datainterfaces/behavior/fictrac/fictracdatainterface.py index 339dae249..1fd16ab91 100644 --- a/src/neuroconv/datainterfaces/behavior/fictrac/fictracdatainterface.py +++ b/src/neuroconv/datainterfaces/behavior/fictrac/fictracdatainterface.py @@ -154,7 +154,8 @@ def __init__( file_path : a string or a path Path to the .dat file (the output of fictrac) radius : float, optional - The radius of the ball in meters. If provided the data will be converted to meters and stored as such. + The radius of the ball in meters. If provided the radius is stored as a conversion factor + and the units are set to meters. If not provided the units are set to radians. verbose : bool, default: True controls verbosity. ``True`` by default. """ @@ -238,7 +239,7 @@ def add_to_nwbfile( position_container.add_spatial_series(spatial_series) # Add the compass direction container to the processing module - processing_module = get_module(nwbfile=nwbfile, name="Behavior") + processing_module = get_module(nwbfile=nwbfile, name="behavior") processing_module.add_data_interface(position_container) def get_original_timestamps(self): From 3646bac4dab86ce30445d11ffc26ecab5743ce5d Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Fri, 27 Oct 2023 17:10:05 +0200 Subject: [PATCH 4/5] correct docstring --- .../datainterfaces/behavior/fictrac/fictracdatainterface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/neuroconv/datainterfaces/behavior/fictrac/fictracdatainterface.py b/src/neuroconv/datainterfaces/behavior/fictrac/fictracdatainterface.py index 1fd16ab91..9ec9bd978 100644 --- a/src/neuroconv/datainterfaces/behavior/fictrac/fictracdatainterface.py +++ b/src/neuroconv/datainterfaces/behavior/fictrac/fictracdatainterface.py @@ -238,7 +238,7 @@ def add_to_nwbfile( spatial_series = SpatialSeries(**spatial_series_kwargs) position_container.add_spatial_series(spatial_series) - # Add the compass direction container to the processing module + # Add the container to the processing module processing_module = get_module(nwbfile=nwbfile, name="behavior") processing_module.add_data_interface(position_container) From ceac3e90ad046b8506f85db3e8a0a9eb98466c8b Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Sat, 28 Oct 2023 15:33:02 +0200 Subject: [PATCH 5/5] fix tests --- tests/test_on_data/test_behavior_interfaces.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_on_data/test_behavior_interfaces.py b/tests/test_on_data/test_behavior_interfaces.py index 69c1d748b..1f1ebfb6a 100644 --- a/tests/test_on_data/test_behavior_interfaces.py +++ b/tests/test_on_data/test_behavior_interfaces.py @@ -47,7 +47,7 @@ def check_read_nwb(self, nwbfile_path: str): # This is currently structured to with NWBHDF5IO(path=nwbfile_path, mode="r", load_namespaces=True) as io: nwbfile = io.read() - fictrac_position_container = nwbfile.processing["Behavior"].data_interfaces["FicTrac"] + fictrac_position_container = nwbfile.processing["behavior"].data_interfaces["FicTrac"] assert isinstance(fictrac_position_container, Position) assert len(fictrac_position_container.spatial_series) == 10 @@ -82,7 +82,7 @@ def check_read_nwb(self, nwbfile_path: str): # This is currently structured to with NWBHDF5IO(path=nwbfile_path, mode="r", load_namespaces=True) as io: nwbfile = io.read() - fictrac_position_container = nwbfile.processing["Behavior"].data_interfaces["FicTrac"] + fictrac_position_container = nwbfile.processing["behavior"].data_interfaces["FicTrac"] assert isinstance(fictrac_position_container, Position) assert len(fictrac_position_container.spatial_series) == 10