diff --git a/environment.yml b/environment.yml index 86c90e1..e2e1fda 100644 --- a/environment.yml +++ b/environment.yml @@ -7,7 +7,7 @@ dependencies: - numpy - scipy - pandas -- pynwb<=3.0.0 +- pynwb>=3.1.0 - nwbinspector>=0.5.0 - dask - ipython diff --git a/pyproject.toml b/pyproject.toml index 3b800e7..1377a4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ dependencies = [ "numpy", "scipy", "pandas", - "pynwb<=3.0.0", + "pynwb>=3.1.0", "nwbinspector>=0.5.0", "ndx_franklab_novela", "pyyaml", diff --git a/src/trodes_to_nwb/convert_yaml.py b/src/trodes_to_nwb/convert_yaml.py index 044ee90..5082ae4 100644 --- a/src/trodes_to_nwb/convert_yaml.py +++ b/src/trodes_to_nwb/convert_yaml.py @@ -25,6 +25,12 @@ from pynwb import NWBFile from pynwb.file import ProcessingModule, Subject +try: + from pynwb.device import DeviceModel +except ImportError: + # Temporary error message to ensure existing users have the correct version of pynwb + raise ImportError("Please upgrade pynwb to 3.1.0 or later") + import trodes_to_nwb.metadata_validation from trodes_to_nwb import __version__ @@ -134,13 +140,20 @@ def add_cameras(nwbfile: NWBFile, metadata: dict) -> None: metadata from the yaml generator """ # add each camera device to the nwb + camera_devices = {} for camera_metadata in metadata["cameras"]: + if (model_name := camera_metadata["model"]) not in camera_devices: + camera_devices[model_name] = nwbfile.create_device_model( + name=camera_metadata["model"], + manufacturer=camera_metadata["manufacturer"], + description="", + ) nwbfile.add_device( CameraDevice( name="camera_device " + str(camera_metadata["id"]), meters_per_pixel=camera_metadata["meters_per_pixel"], manufacturer=camera_metadata["manufacturer"], - model=camera_metadata["model"], + model=camera_devices[model_name], lens=camera_metadata["lens"], camera_name=camera_metadata["camera_name"], ) diff --git a/src/trodes_to_nwb/tests/test_convert_yaml.py b/src/trodes_to_nwb/tests/test_convert_yaml.py index 7a8608c..d7feaf9 100644 --- a/src/trodes_to_nwb/tests/test_convert_yaml.py +++ b/src/trodes_to_nwb/tests/test_convert_yaml.py @@ -60,7 +60,8 @@ def test_camera_creation(): assert len(cameras) == 2 name = "camera_device " + str(metadata["cameras"][0]["id"]) assert cameras[name].meters_per_pixel == 0.001 - assert cameras[name].model == "model1" + assert cameras[name].model.name == "model1" + assert cameras[name].manufacturer == "Allied Vision" assert cameras[name].lens == "lens1" assert cameras[name].manufacturer == "Allied Vision"