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 radius as conversion (scaling) instead of adding the scaled data in FicTrac #619

Merged
merged 6 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all 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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down Expand Up @@ -220,7 +221,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"
Expand All @@ -237,8 +238,8 @@ 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
processing_module = get_module(nwbfile=nwbfile, name="Behavior")
# Add the container to the processing module
processing_module = get_module(nwbfile=nwbfile, name="behavior")
processing_module.add_data_interface(position_container)

def get_original_timestamps(self):
Expand Down
6 changes: 4 additions & 2 deletions tests/test_on_data/test_behavior_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand All @@ -81,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
Expand All @@ -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):
Expand Down