Skip to content

Commit

Permalink
Merge pull request #619 from catalystneuro/add_radius_as_scaling
Browse files Browse the repository at this point in the history
Add radius as conversion (scaling) instead of adding the scaled data in `FicTrac`
  • Loading branch information
CodyCBakerPhD authored Oct 30, 2023
2 parents 88eabb1 + 7495597 commit 9838b67
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
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

0 comments on commit 9838b67

Please sign in to comment.