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
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
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 15, 2024
commit 8ac9c471a2ee8b05267fa326c49f751015fee9b3
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import h5py
import numpy as np
from ndx_facemap_motionsvd import MotionSVDMasks, MotionSVDSeries
from pynwb.base import TimeSeries
from pynwb.behavior import EyeTracking, PupilTracking, SpatialSeries
from pynwb.file import NWBFile
from ndx_facemap_motionsvd import MotionSVDMasks, MotionSVDSeries
from pynwb.core import DynamicTableRegion
from pynwb.file import NWBFile

from ..video.video_utils import get_video_timestamps
from ....basetemporalalignmentinterface import BaseTemporalAlignmentInterface
from ....tools import get_module
Expand Down Expand Up @@ -113,8 +114,8 @@

# Extract mask_coordinates
mask_coordinates = file[file[file["proc"]["ROI"][0][0]][0][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
y1 = int(np.round(mask_coordinates[0][0]) - 1) # correct matlab indexing
x1 = int(np.round(mask_coordinates[1][0]) - 1) # correct matlab indexing
y2 = y1 + int(np.round(mask_coordinates[2][0]))
x2 = x1 + int(np.round(mask_coordinates[3][0]))
mask_coordinates = [x1, y1, x2, y2]
Expand All @@ -133,7 +134,7 @@
for c, component in enumerate(file[mask_ref]):
if c == self.first_n_components:
break
componendt_2d = component.reshape((y2-y1, x2-x1))
componendt_2d = component.reshape((y2 - y1, x2 - x1))
motion_masks_table.add_row(image_mask=componendt_2d.T)

motion_masks = DynamicTableRegion(
Expand Down Expand Up @@ -180,18 +181,18 @@
behavior_module = get_module(nwbfile=nwbfile, name="behavior", description="behavioral data")

timestamps = self.get_timestamps()
downsampling_factor=self._get_downsamplig_factor()
processed_frame_dimension=self._get_processed_frame_dimension()
downsampling_factor = self._get_downsamplig_factor()
processed_frame_dimension = self._get_processed_frame_dimension()
# store ROIs motion mask and motion series
n = 1
for series_ref, mask_ref in zip(file["proc"]["motSVD"][1:], file["proc"]["uMotMask"][1:]):
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 192 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
y1 = int(np.round(mask_coordinates[0][0]) - 1) # correct matlab indexing
x1 = int(np.round(mask_coordinates[1][0]) - 1) # correct matlab indexing
y2 = y1 + int(np.round(mask_coordinates[2][0]))
x2 = x1 + int(np.round(mask_coordinates[3][0]))
mask_coordinates = [x1, y1, x2, y2]
Expand Down Expand Up @@ -247,19 +248,18 @@

def set_aligned_timestamps(self, aligned_timestamps: np.ndarray) -> None:
self.timestamps = aligned_timestamps

def _get_downsamplig_factor(self) -> float:
with h5py.File(self.source_data["mat_file_path"], "r") as file:
downsamplig_factor = file["proc"]["sc"][0][0]
return downsamplig_factor

def _get_processed_frame_dimension(self) -> np.ndarray:
with h5py.File(self.source_data["mat_file_path"], "r") as file:
processed_frame_ref = file["proc"]["wpix"][0][0]
frame = file[processed_frame_ref]
return [frame.shape[1],frame.shape[0]]


return [frame.shape[1], frame.shape[0]]

def add_to_nwbfile(
self,
nwbfile: NWBFile,
Expand Down
Loading