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 name parameter to the DeepLabCutInterface #917

Merged
merged 13 commits into from
Jul 11, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def add_to_nwbfile(
self,
nwbfile: NWBFile,
metadata: Optional[dict] = None,
container_name: str = "PoseEstimation",
):
"""
Conversion from DLC output files to nwb. Derived from dlc2nwb library.
Expand All @@ -110,4 +111,5 @@ def add_to_nwbfile(
individual_name=self.subject_name,
config_file=str(self.source_data["config_file_path"]),
timestamps=self._timestamps,
pose_estimation_container_kwargs=dict(name=container_name),
)
17 changes: 17 additions & 0 deletions tests/test_on_data/test_behavior_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ class TestDeepLabCutInterface(DeepLabCutInterfaceMixin, unittest.TestCase):

def run_custom_checks(self):
self.check_custom_timestamps(nwbfile_path=self.nwbfile_path)
self.check_renaming_instance(nwbfile_path=self.nwbfile_path)

def check_custom_timestamps(self, nwbfile_path: str):
# TODO: Peel out into separate test class and replace this part with check_read_nwb
Expand All @@ -361,6 +362,22 @@ def check_custom_timestamps(self, nwbfile_path: str):
pose_timestamps = pose_estimation.timestamps
np.testing.assert_array_equal(pose_timestamps, self._custom_timestamps_case_1)

def check_renaming_instance(self, nwbfile_path: str):
custom_container_name = "TestPoseEstimation"

metadata = self.interface.get_metadata()
metadata["NWBFile"].update(session_start_time=datetime.now().astimezone())

self.interface.run_conversion(
nwbfile_path=nwbfile_path, overwrite=True, metadata=metadata, container_name=custom_container_name
)

with NWBHDF5IO(path=nwbfile_path, mode="r", load_namespaces=True) as io:
nwbfile = io.read()
assert "behavior" in nwbfile.processing
assert "PoseEstimation" not in nwbfile.processing["behavior"].data_interfaces
assert custom_container_name in nwbfile.processing["behavior"].data_interfaces

def check_read_nwb(self, nwbfile_path: str):
# TODO: move this to the upstream mixin
with NWBHDF5IO(path=nwbfile_path, mode="r", load_namespaces=True) as io:
Expand Down
Loading