diff --git a/src/neuroconv/datainterfaces/behavior/deeplabcut/deeplabcutdatainterface.py b/src/neuroconv/datainterfaces/behavior/deeplabcut/deeplabcutdatainterface.py index f5aea74aa..e053e88fa 100644 --- a/src/neuroconv/datainterfaces/behavior/deeplabcut/deeplabcutdatainterface.py +++ b/src/neuroconv/datainterfaces/behavior/deeplabcut/deeplabcutdatainterface.py @@ -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. @@ -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), ) diff --git a/tests/test_on_data/test_behavior_interfaces.py b/tests/test_on_data/test_behavior_interfaces.py index 155b32d72..36011da92 100644 --- a/tests/test_on_data/test_behavior_interfaces.py +++ b/tests/test_on_data/test_behavior_interfaces.py @@ -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 @@ -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: