Skip to content

Commit 50eb5b9

Browse files
committed
Address comments, improve doc
1 parent def36e9 commit 50eb5b9

File tree

6 files changed

+46
-16
lines changed

6 files changed

+46
-16
lines changed

requirements-doc.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ sphinx
22
matplotlib
33
sphinx_rtd_theme
44
sphinx-gallery
5-
allensdk # ntoe that as of allensdk 2.10.0, python 3.8 is not supported
5+
allensdk # note that as of allensdk 2.10.0, python 3.8 is not supported

src/pynwb/file.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,29 @@ class Subject(NWBContainer):
4848
'strain'
4949
)
5050

51-
@docval({'name': 'age', 'type': str, 'doc': 'the age of the subject', 'default': None},
52-
{'name': 'description', 'type': str, 'doc': 'a description of the subject', 'default': None},
53-
{'name': 'genotype', 'type': str, 'doc': 'the genotype of the subject', 'default': None},
54-
{'name': 'sex', 'type': str, 'doc': 'the sex of the subject', 'default': None},
55-
{'name': 'species', 'type': str, 'doc': 'the species of the subject', 'default': None},
56-
{'name': 'subject_id', 'type': str, 'doc': 'a unique identifier for the subject', 'default': None},
57-
{'name': 'weight', 'type': str, 'doc': 'the weight of the subject', 'default': None},
51+
@docval({'name': 'age', 'type': str,
52+
'doc': ('The age of the subject. The ISO 8601 Duration format is recommended, e.g., "P90D" for '
53+
'90 days old.'), 'default': None},
54+
{'name': 'description', 'type': str,
55+
'doc': 'A description of the subject, e.g., "mouse A10".', 'default': None},
56+
{'name': 'genotype', 'type': str,
57+
'doc': 'The genotype of the subject, e.g., "Sst-IRES-Cre/wt;Ai32(RCL-ChR2(H134R)_EYFP)/wt".',
58+
'default': None},
59+
{'name': 'sex', 'type': str,
60+
'doc': ('The sex of the subject. Using "F" (female), "M" (male), "U" (unknown), or "O" (other) '
61+
'is recommended.'), 'default': None},
62+
{'name': 'species', 'type': str,
63+
'doc': ('The species of the subject. The formal latin binomal name is recommended, e.g., "Mus musculus"'),
64+
'default': None},
65+
{'name': 'subject_id', 'type': str, 'doc': 'A unique identifier for the subject, e.g., "A10"',
66+
'default': None},
67+
{'name': 'weight', 'type': (float, str),
68+
'doc': ('The weight of the subject, including units. Using kilograms is recommended. e.g., "0.02 kg". '
69+
'If a float is provided, then the weight will be stored as "[value] kg".'),
70+
'default': None},
5871
{'name': 'date_of_birth', 'type': datetime, 'default': None,
59-
'doc': 'datetime of date of birth. May be supplied instead of age.'},
60-
{'name': 'strain', 'type': str, 'doc': 'the strain of the subject', 'default': None})
72+
'doc': 'The datetime of the date of birth. May be supplied instead of age.'},
73+
{'name': 'strain', 'type': str, 'doc': 'The strain of the subject, e.g., "C57BL/6J"', 'default': None})
6174
def __init__(self, **kwargs):
6275
kwargs['name'] = 'subject'
6376
call_docval_func(super(Subject, self).__init__, kwargs)
@@ -67,7 +80,10 @@ def __init__(self, **kwargs):
6780
self.sex = getargs('sex', kwargs)
6881
self.species = getargs('species', kwargs)
6982
self.subject_id = getargs('subject_id', kwargs)
70-
self.weight = getargs('weight', kwargs)
83+
weight = getargs('weight', kwargs)
84+
if isinstance(weight, float):
85+
weight = str(weight) + ' kg'
86+
self.weight = weight
7187
self.strain = getargs('strain', kwargs)
7288
date_of_birth = getargs('date_of_birth', kwargs)
7389
if date_of_birth and date_of_birth.tzinfo is None:

src/pynwb/icephys.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ class IZeroClampSeries(CurrentClampSeries):
138138

139139
@docval(*get_docval(CurrentClampSeries.__init__, 'name', 'data', 'electrode'), # required
140140
{'name': 'gain', 'type': 'float', 'doc': 'Units: Volt/Volt'}, # required
141-
*get_docval(CurrentClampSeries.__init__, 'stimulus_description', 'resolution', 'conversion', 'timestamps',
141+
{'name': 'stimulus_description', 'type': str,
142+
'doc': ('The stimulus name/protocol. Setting this to a value other than "N/A" is deprecated as of '
143+
'NWB 2.3.0.'),
144+
'default': 'N/A'},
145+
*get_docval(CurrentClampSeries.__init__, 'resolution', 'conversion', 'timestamps',
142146
'starting_time', 'rate', 'comments', 'description', 'control', 'control_description',
143147
'sweep_number'),
144148
{'name': 'unit', 'type': str, 'doc': "The base unit of measurement (must be 'volts')",

src/pynwb/misc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,10 @@ class DecompositionSeries(TimeSeries):
268268
'doc': 'a table for describing the frequency bands that the signal was decomposed into', 'default': None},
269269
{'name': 'source_timeseries', 'type': TimeSeries,
270270
'doc': 'the input TimeSeries from this analysis', 'default': None},
271-
{'name': 'source_channels', 'type': DynamicTableRegion, 'doc': 'the channels that provided the source data',
271+
{'name': 'source_channels', 'type': DynamicTableRegion,
272+
'doc': ('The channels that provided the source data. In the case of electrical recordings this is '
273+
'typically a DynamicTableRegion pointing to the electrodes table at NWBFile.electrodes, '
274+
'similar to ElectricalSeries.electrodes.'),
272275
'default': None},
273276
*get_docval(TimeSeries.__init__, 'resolution', 'conversion', 'timestamps', 'starting_time', 'rate',
274277
'comments', 'control', 'control_description'))

tests/integration/hdf5/test_nwbfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def setUpContainer(self):
209209
sex='M',
210210
species='Rattus norvegicus',
211211
subject_id='RAT123',
212-
weight='2 lbs',
212+
weight='2 kg',
213213
date_of_birth=datetime(1970, 1, 1, 12, tzinfo=tzutc()),
214214
strain='my_strain')
215215

tests/unit/test_file.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def setUp(self):
423423
sex='M',
424424
species='Rattus norvegicus',
425425
subject_id='RAT123',
426-
weight='2 lbs',
426+
weight='2 kg',
427427
date_of_birth=datetime(2017, 5, 1, 12, tzinfo=tzlocal()),
428428
strain='my_strain')
429429
self.start = datetime(2017, 5, 1, 12, tzinfo=tzlocal())
@@ -445,13 +445,20 @@ def test_constructor(self):
445445
self.assertEqual(self.subject.sex, 'M')
446446
self.assertEqual(self.subject.species, 'Rattus norvegicus')
447447
self.assertEqual(self.subject.subject_id, 'RAT123')
448-
self.assertEqual(self.subject.weight, '2 lbs')
448+
self.assertEqual(self.subject.weight, '2 kg')
449449
self.assertEqual(self.subject.date_of_birth, datetime(2017, 5, 1, 12, tzinfo=tzlocal()))
450450
self.assertEqual(self.subject.strain, 'my_strain')
451451

452452
def test_nwbfile_constructor(self):
453453
self.assertIs(self.nwbfile.subject, self.subject)
454454

455+
def test_weight_float(self):
456+
subject = Subject(
457+
subject_id='RAT123',
458+
weight=2.3,
459+
)
460+
self.assertEqual(subject.weight, '2.3 kg')
461+
455462

456463
class TestCacheSpec(TestCase):
457464

0 commit comments

Comments
 (0)