diff --git a/src/pynwb/file.py b/src/pynwb/file.py index 5511439e3..3fdca7b1a 100644 --- a/src/pynwb/file.py +++ b/src/pynwb/file.py @@ -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), @@ -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) diff --git a/src/pynwb/io/file.py b/src/pynwb/io/file.py index 4b43b0027..a58705af7 100644 --- a/src/pynwb/io/file.py +++ b/src/pynwb/io/file.py @@ -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) diff --git a/tests/integration/ui_write/test_nwbfile.py b/tests/integration/ui_write/test_nwbfile.py index c669df66c..5e4463596 100644 --- a/tests/integration/ui_write/test_nwbfile.py +++ b/tests/integration/ui_write/test_nwbfile.py @@ -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.], @@ -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() diff --git a/tests/unit/pynwb_tests/test_file.py b/tests/unit/pynwb_tests/test_file.py index 16ce63146..9537cbf89 100644 --- a/tests/unit/pynwb_tests/test_file.py +++ b/tests/unit/pynwb_tests/test_file.py @@ -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]))