Skip to content

Commit

Permalink
Merge pull request #846 from NeurodataWithoutBorders/fix/nwbfile.anal…
Browse files Browse the repository at this point in the history
…ysis

fix nwbfile.analysis access
  • Loading branch information
bendichter authored Mar 13, 2019
2 parents b5939d5 + d0aa132 commit 6bb2a01
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/pynwb/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ class NWBFile(MultiContainerInterface):
{'name': 'lab', 'type': str, 'doc': 'lab where experiment was performed', 'default': None},
{'name': 'acquisition', 'type': (list, tuple),
'doc': 'Raw TimeSeries objects belonging to this NWBFile', 'default': None},
{'name': 'analysis', 'type': (list, tuple),
'doc': 'result of analysis', 'default': None},
{'name': 'stimulus', 'type': (list, tuple),
'doc': 'Stimulus TimeSeries objects belonging to this NWBFile', 'default': None},
{'name': 'stimulus_template', 'type': (list, tuple),
Expand Down Expand Up @@ -298,6 +300,7 @@ def __init__(self, **kwargs):
self.__file_create_date = list(map(_add_missing_timezone, self.__file_create_date))

self.acquisition = getargs('acquisition', kwargs)
self.analysis = getargs('analysis', kwargs)
self.stimulus = getargs('stimulus', kwargs)
self.stimulus_template = getargs('stimulus_template', kwargs)
self.keywords = getargs('keywords', kwargs)
Expand Down
1 change: 1 addition & 0 deletions src/pynwb/io/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def __init__(self, spec):
super(NWBFileMap, self).__init__(spec)
raw_ts_spec = self.spec.get_group('acquisition').get_neurodata_type('NWBDataInterface')
self.map_spec('acquisition', raw_ts_spec)
self.map_spec('analysis', self.spec.get_group('analysis').get_neurodata_type('NWBContainer'))

stimulus_spec = self.spec.get_group('stimulus')
self.unmap(stimulus_spec)
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/ui_write/test_nwbfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ def setUpContainer(self):
self.ts = TimeSeries('test_timeseries', list(range(100, 200, 10)),
'SIunit', timestamps=list(range(10)), resolution=0.1)
container.add_acquisition(self.ts)
self.ts2 = TimeSeries('test_timeseries2', list(range(200, 300, 10)),
'SIunit', timestamps=list(range(10)), resolution=0.1)
container.add_analysis(self.ts2)
self.mod = container.create_processing_module('test_module',
'a test module')
self.clustering = Clustering("A fake Clustering interface", [0, 1, 2, 0, 1, 2], [100., 101., 102.],
Expand Down Expand Up @@ -164,6 +167,7 @@ def test_read(self):
self.assertIsInstance(container, NWBFile)
raw_ts = container.acquisition
self.assertEqual(len(raw_ts), 1)
self.assertEqual(len(container.analysis), 1)
for v in raw_ts.values():
self.assertIsInstance(v, TimeSeries)
hdf5io.close()
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/pynwb_tests/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ def test_add_stimulus_template(self):
'grams', timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5]))
self.assertEqual(len(self.nwbfile.stimulus_template), 1)

def test_add_analysis(self):
self.nwbfile.add_analysis(TimeSeries('test_ts', [0, 1, 2, 3, 4, 5],
'grams', timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5]))
self.assertEqual(len(self.nwbfile.analysis), 1)

def test_add_acquisition_check_dups(self):
self.nwbfile.add_acquisition(TimeSeries('test_ts', [0, 1, 2, 3, 4, 5],
'grams', timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5]))
Expand Down

0 comments on commit 6bb2a01

Please sign in to comment.