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 FacemapInterface #752

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c558dee
add FacemapInterface, which currently only supports eye tracking.
bendichter Feb 18, 2024
275bf42
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 18, 2024
16523f9
Update CHANGELOG.md
bendichter Feb 18, 2024
234ab4c
Merge branch 'main' into facemap
alessandratrapani Apr 5, 2024
78e8794
add motion svd
alessandratrapani Apr 5, 2024
07e21f9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 5, 2024
2f25678
separate multivideo masks and ROI masks
alessandratrapani Apr 8, 2024
213ff8e
Merge branch 'main' into facemap
alessandratrapani Apr 8, 2024
056d787
separate multivideo and rois motion masks
alessandratrapani Apr 15, 2024
8ac9c47
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 15, 2024
ff03d31
Merge branch 'main' into facemap to update videodatainterface
alessandratrapani Apr 17, 2024
e413efa
set facempa test (not working)
alessandratrapani May 17, 2024
578eeb9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 17, 2024
1682793
add get_metadata() function
alessandratrapani May 21, 2024
6f80805
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 21, 2024
52d5383
add tests for PupilTracking
alessandratrapani May 21, 2024
9c0aec3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 21, 2024
d92ec25
motion svd metadata
alessandratrapani May 21, 2024
ecb5dde
test yey_tracking spatial series
alessandratrapani May 21, 2024
96651d9
Merge branch 'facemap' of https://github.com/catalystneuro/neuroconv …
alessandratrapani May 21, 2024
651eeb8
test pupil tracking time series
alessandratrapani May 21, 2024
b58ef5f
Merge branch 'main' into facemap
CodyCBakerPhD May 21, 2024
06302d3
add testing for MotionSVDMasks and MotionSVDSeries
alessandratrapani May 21, 2024
51b3a97
Merge branch 'facemap' of https://github.com/catalystneuro/neuroconv …
alessandratrapani May 21, 2024
79430bf
Merge branch 'main' into facemap
alessandratrapani Jun 10, 2024
f067458
set check_ragged to False to speed up add_row
alessandratrapani Jun 13, 2024
7b39363
Merge branch 'refs/heads/main' into facemap
alessandratrapani Jul 9, 2024
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
Prev Previous commit
Next Next commit
add tests for PupilTracking
  • Loading branch information
alessandratrapani committed May 21, 2024
commit 52d53834fc006b1448d03ae215c541011a3a06f6
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@

def add_eye_tracking(self, nwbfile: NWBFile, metadata: DeepDict):

timestamps = self.get_timestamps()
if self.timestamps is None:
self.timestamps = self.get_timestamps()

with h5py.File(self.source_data["mat_file_path"], "r") as file:

Expand All @@ -100,7 +101,7 @@
data=file["proc"]["pupil"]["com"][:].T,
reference_frame=eye_tracking_metadata["reference_frame"],
unit=eye_tracking_metadata["unit"],
timestamps=timestamps,
timestamps=self.timestamps,
)

eye_tracking = EyeTracking(name="EyeTracking", spatial_series=eye_com)
Expand Down Expand Up @@ -237,7 +238,7 @@
series_ref = series_ref[0]
mask_ref = mask_ref[0]

# skipping the first ROI because it referes to "running" mask, from Facemap doc

Check failure on line 241 in src/neuroconv/datainterfaces/behavior/facemap/facemapdatainterface.py

View workflow job for this annotation

GitHub Actions / Check for spelling errors

referes ==> refers, referees
mask_coordinates = file[file["proc"]["locROI"][n][0]]
y1 = int(np.round(mask_coordinates[0][0]) - 1) # correct matlab indexing
x1 = int(np.round(mask_coordinates[1][0]) - 1) # correct matlab indexing
Expand Down
28 changes: 23 additions & 5 deletions tests/test_on_data/test_behavior_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from numpy.testing import assert_array_equal
from parameterized import param, parameterized
from pynwb import NWBHDF5IO
from pynwb.behavior import EyeTracking, Position, SpatialSeries
from pynwb.behavior import EyeTracking, Position, SpatialSeries, PupilTracking

from neuroconv import NWBConverter
from neuroconv.datainterfaces import (
Expand Down Expand Up @@ -752,31 +752,49 @@ class TestFacemapInterface(DataInterfaceTestMixin, TemporalAlignmentMixin, unitt

@classmethod
def setUpClass(cls):
cls.eye_com_name = "eye_center_of_mass"

cls.eye_tracking_module = "EyeTracking"
cls.eye_com_expected_metadata = dict(
name=cls.eye_com_name,
name="eye_center_of_mass",
description="The position of the eye measured in degrees.",
reference_frame="unknown",
unit="degrees",
)

cls.pupil_tracking_module = "PupilTracking"
cls.pupil_area_expected_metadata = dict(
name="pupil_area",
description="Area of pupil.",
unit="unknown",
)
cls.pupil_area_raw__expected_metadata = dict(
name="pupil_area_raw",
description="Raw unprocessed area of pupil.",
unit="unknown",
)

with h5py.File(cls.interface_kwargs["mat_file_path"], "r") as file:
cls.eye_com_test_data = file["proc"]["pupil"]["com"][:].T

cls.eye_tracking_module = "EyeTracking"

def check_extracted_metadata(self, metadata: dict):

self.assertIn(self.eye_tracking_module, metadata["Behavior"])
self.assertEqual(self.eye_com_expected_metadata, metadata["Behavior"]["EyeTracking"])

self.assertIn(self.pupil_tracking_module, metadata["Behavior"])
self.assertEqual(self.pupil_area_expected_metadata, metadata["Behavior"]["PupilTracking"]["area"])
self.assertEqual(self.pupil_area_raw__expected_metadata, metadata["Behavior"]["PupilTracking"]["area_raw"])

def check_read_nwb(self, nwbfile_path: str):
with NWBHDF5IO(path=nwbfile_path, mode="r", load_namespaces=True) as io:
nwbfile = io.read()
self.assertIn("behavior", nwbfile.processing)
self.assertIn(self.eye_tracking_module, nwbfile.processing["behavior"].data_interfaces)
eye_tracking_container = nwbfile.processing["behavior"].data_interfaces[self.eye_tracking_module]
self.assertIsInstance(eye_tracking_container, EyeTracking)
self.assertIn(self.pupil_tracking_module, nwbfile.processing["behavior"].data_interfaces)
pupil_tracking_container = nwbfile.processing["behavior"].data_interfaces[self.pupil_tracking_module]
self.assertIsInstance(pupil_tracking_container, PupilTracking)


if __name__ == "__main__":
Expand Down
Loading