Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies:
- numpy
- scipy
- pandas
- pynwb<=3.0.0
- pynwb>=3.1.0
- nwbinspector>=0.5.0
- dask
- ipython
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies = [
"numpy",
"scipy",
"pandas",
"pynwb<=3.0.0",
"pynwb>=3.1.0",
"nwbinspector>=0.5.0",
"ndx_franklab_novela",
"pyyaml",
Expand Down
15 changes: 14 additions & 1 deletion src/trodes_to_nwb/convert_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__

Expand Down Expand Up @@ -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"],
)
Expand Down
3 changes: 2 additions & 1 deletion src/trodes_to_nwb/tests/test_convert_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Loading