Skip to content

Commit 81c1227

Browse files
committed
correctly add camera device object to file
1 parent 8a9439b commit 81c1227

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/trodes_to_nwb/convert_yaml.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,20 @@ def add_cameras(nwbfile: NWBFile, metadata: dict) -> None:
140140
metadata from the yaml generator
141141
"""
142142
# add each camera device to the nwb
143+
camera_devices = {}
143144
for camera_metadata in metadata["cameras"]:
144-
model = DeviceModel(
145-
name=camera_metadata["model"],
146-
manufacturer=camera_metadata["manufacturer"],
147-
description="",
148-
)
145+
if (model_name := camera_metadata["model"]) not in camera_devices:
146+
camera_devices[model_name] = nwbfile.create_device_model(
147+
name=camera_metadata["model"],
148+
manufacturer=camera_metadata["manufacturer"],
149+
description="",
150+
)
149151
nwbfile.add_device(
150152
CameraDevice(
151153
name="camera_device " + str(camera_metadata["id"]),
152154
meters_per_pixel=camera_metadata["meters_per_pixel"],
153155
manufacturer=camera_metadata["manufacturer"],
154-
model=model,
156+
model=camera_devices[model_name],
155157
lens=camera_metadata["lens"],
156158
camera_name=camera_metadata["camera_name"],
157159
)

0 commit comments

Comments
 (0)