Skip to content

Commit

Permalink
add name parameter to the DeepLabCutInterface (#917)
Browse files Browse the repository at this point in the history
Co-authored-by: Cody Baker <[email protected]>
  • Loading branch information
vigji and CodyCBakerPhD authored Jul 11, 2024
1 parent fa36957 commit d3ea2a1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
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

0 comments on commit d3ea2a1

Please sign in to comment.