Skip to content

Commit 52a7e6d

Browse files
authored
Add model_number, model_name, and serial_number to Device (#1997)
1 parent 1b46014 commit 52a7e6d

File tree

6 files changed

+69
-21
lines changed

6 files changed

+69
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Added support for NWB schema 2.8.0:
77
- Removed `SpatialSeries.bounds` field that was not functional. This will be fixed in a future release. @rly [#1907](https://github.com/NeurodataWithoutBorders/pynwb/pull/1907), [#1996](https://github.com/NeurodataWithoutBorders/pynwb/pull/1996)
88
- Added support for `NWBFile.was_generated_by` field. @stephprince [#1924](https://github.com/NeurodataWithoutBorders/pynwb/pull/1924)
9+
- Added support for `model_number`, `model_name`, and `serial_number` fields to `Device`. @stephprince [#1997](https://github.com/NeurodataWithoutBorders/pynwb/pull/1997)
910

1011
## PyNWB 2.8.3 (Upcoming)
1112

docs/gallery/domain/ecephys.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,16 @@
7777
#
7878
# The electrodes table references a required :py:class:`~pynwb.ecephys.ElectrodeGroup`, which is used to represent a
7979
# group of electrodes. Before creating an :py:class:`~pynwb.ecephys.ElectrodeGroup`, you must define a
80-
# :py:class:`~pynwb.device.Device` object using the method :py:meth:`.NWBFile.create_device`.
81-
80+
# :py:class:`~pynwb.device.Device` object using the method :py:meth:`.NWBFile.create_device`. The fields
81+
# ``description``, ``manufacturer``, ``model_number``, ``model_name``, and ``serial_number`` are optional, but
82+
# recommended.
8283
device = nwbfile.create_device(
83-
name="array", description="the best array", manufacturer="Probe Company 9000"
84+
name="array",
85+
description="A 12-channel array with 4 shanks and 3 channels per shank",
86+
manufacturer="Array Technologies",
87+
model_number="PRB_1_4_0480_123",
88+
model_name="Neurovoxels 0.99",
89+
serial_number="1234567890",
8490
)
8591

8692
#######################

docs/gallery/domain/ophys.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,17 @@
8686
# :align: center
8787
#
8888
# Create a :py:class:`~pynwb.device.Device` named ``"Microscope"`` in the :py:class:`~pynwb.file.NWBFile` object. Then
89-
# create an :py:class:`~pynwb.ophys.OpticalChannel` named ``"OpticalChannel"``.
89+
# create an :py:class:`~pynwb.ophys.OpticalChannel` named ``"OpticalChannel"``. The fields
90+
# ``description``, ``manufacturer``, ``model_number``, ``model_name``, and ``serial_number`` are optional, but
91+
# recommended.
9092

9193
device = nwbfile.create_device(
9294
name="Microscope",
9395
description="My two-photon microscope",
94-
manufacturer="The best microscope manufacturer",
96+
manufacturer="Loki Labs",
97+
model_number="ABC-123",
98+
model_name="Loki 1.0",
99+
serial_number="1234567890",
95100
)
96101
optical_channel = OpticalChannel(
97102
name="OpticalChannel",

src/pynwb/device.py

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,41 @@ class Device(NWBContainer):
1010
Metadata about a data acquisition device, e.g., recording system, electrode, microscope.
1111
"""
1212

13-
__nwbfields__ = ('name',
14-
'description',
15-
'manufacturer')
13+
__nwbfields__ = (
14+
'name',
15+
'description',
16+
'manufacturer',
17+
'model_number',
18+
'model_name',
19+
'serial_number',
20+
)
1621

17-
@docval({'name': 'name', 'type': str, 'doc': 'the name of this device'},
18-
{'name': 'description', 'type': str,
19-
'doc': 'Description of the device (e.g., model, firmware version, processing software version, etc.)',
20-
'default': None},
21-
{'name': 'manufacturer', 'type': str, 'doc': 'the name of the manufacturer of this device',
22-
'default': None})
22+
@docval(
23+
{'name': 'name', 'type': str, 'doc': 'the name of this device'},
24+
{'name': 'description', 'type': str,
25+
'doc': ("Description of the device as free-form text. If there is any software/firmware associated "
26+
"with the device, the names and versions of those can be added to `NWBFile.was_generated_by`."),
27+
'default': None},
28+
{'name': 'manufacturer', 'type': str,
29+
'doc': ("The name of the manufacturer of the device, e.g., Imec, Plexon, Thorlabs."),
30+
'default': None},
31+
{'name': 'model_number', 'type': str,
32+
'doc': ('The model number (or part/product number) of the device, e.g., PRB_1_4_0480_1, '
33+
'PLX-VP-32-15SE(75)-(260-80)(460-10)-300-(1)CON/32m-V, BERGAMO.'),
34+
'default': None},
35+
{'name': 'model_name', 'type': str,
36+
'doc': ('The model name of the device, e.g., Neuropixels 1.0, V-Probe, Bergamo III.'),
37+
'default': None},
38+
{'name': 'serial_number', 'type': str,
39+
'doc': 'The serial number of the device.',
40+
'default': None},
41+
)
2342
def __init__(self, **kwargs):
24-
description, manufacturer = popargs('description', 'manufacturer', kwargs)
43+
description, manufacturer, model_number, model_name, serial_number = popargs(
44+
'description', 'manufacturer', 'model_number', 'model_name', 'serial_number', kwargs)
2545
super().__init__(**kwargs)
2646
self.description = description
2747
self.manufacturer = manufacturer
48+
self.model_number = model_number
49+
self.model_name = model_name
50+
self.serial_number = serial_number

tests/integration/hdf5/test_device.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ class TestDeviceIO(NWBH5IOMixin, TestCase):
66

77
def setUpContainer(self):
88
""" Return the test Device to read/write """
9-
return Device(name='device_name',
10-
description='description',
11-
manufacturer='manufacturer')
9+
return Device(
10+
name='device_name',
11+
description='description',
12+
manufacturer='manufacturer',
13+
model_number='model_number',
14+
model_name='model_name',
15+
serial_number='serial_number',
16+
)
1217

1318
def addContainer(self, nwbfile):
1419
""" Add the test Device to the given NWBFile """

tests/unit/test_device.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@
55
class TestDevice(TestCase):
66

77
def test_init(self):
8-
device = Device(name='device_name',
9-
description='description',
10-
manufacturer='manufacturer')
8+
device = Device(
9+
name='device_name',
10+
description='description',
11+
manufacturer='manufacturer',
12+
model_number='model_number',
13+
model_name='model_name',
14+
serial_number='serial_number',
15+
)
1116

1217
self.assertEqual(device.name, 'device_name')
1318
self.assertEqual(device.description, 'description')
1419
self.assertEqual(device.manufacturer, 'manufacturer')
20+
self.assertEqual(device.model_number, 'model_number')
21+
self.assertEqual(device.model_name, 'model_name')
22+
self.assertEqual(device.serial_number, 'serial_number')

0 commit comments

Comments
 (0)