Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing invalid time intervals #1069

Merged
merged 5 commits into from
Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/pynwb/io/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ def __init__(self, spec):
self.map_spec('unit', data_spec.get_attribute('unit'))
self.map_spec('resolution', data_spec.get_attribute('resolution'))
self.map_spec('conversion', data_spec.get_attribute('conversion'))

timestamps_spec = self.spec.get_dataset('timestamps')
self.map_spec('timestamps_unit', timestamps_spec.get_attribute('unit'))
self.map_spec('interval', timestamps_spec.get_attribute('interval'))

startingtime_spec = self.spec.get_dataset('starting_time')
self.map_spec('starting_time_unit', startingtime_spec.get_attribute('unit'))
self.map_spec('rate', startingtime_spec.get_attribute('rate'))
Expand Down
37 changes: 23 additions & 14 deletions src/pynwb/io/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,43 @@ def __init__(self, spec):

acq_spec = self.spec.get_group('acquisition')
self.unmap(acq_spec)
raw_ts_spec = acq_spec.get_neurodata_type('NWBDataInterface')
self.map_spec('acquisition', raw_ts_spec)
self.map_spec('acquisition', acq_spec.get_neurodata_type('NWBDataInterface'))

self.map_spec('analysis', self.spec.get_group('analysis').get_neurodata_type('NWBContainer'))

# map constructor arg and property 'stimulus' -> stimulus__presentation
stimulus_spec = self.spec.get_group('stimulus')
self.unmap(stimulus_spec)
self.map_spec('stimulus', stimulus_spec.get_group('presentation').get_neurodata_type('TimeSeries'))
self.map_spec('stimulus_template', stimulus_spec.get_group('templates').get_neurodata_type('TimeSeries'))

intervals_spec = self.spec.get_group('intervals')
self.map_spec('intervals', intervals_spec.get_neurodata_type('TimeIntervals'))

epochs_spec = intervals_spec.get_group('epochs')
self.map_spec('epochs', epochs_spec)

trials_spec = intervals_spec.get_group('trials')
self.map_spec('trials', trials_spec)
self.map_spec('intervals', intervals_spec.get_neurodata_type('TimeIntervals'))

invalid_times_spec = intervals_spec.get_group('invalid_times')
self.map_spec('invalid_times', invalid_times_spec)

general_spec = self.spec.get_group('general')

icephys_spec = general_spec.get_group('intracellular_ephys')
self.map_spec('ic_electrodes', icephys_spec.get_neurodata_type('IntracellularElectrode'))
ecephys_spec = general_spec.get_group('extracellular_ephys')
self.map_spec('sweep_table', icephys_spec.get_neurodata_type('SweepTable'))

ecephys_spec = general_spec.get_group('extracellular_ephys')
self.map_spec('electrodes', ecephys_spec.get_group('electrodes'))
self.map_spec('electrode_groups', ecephys_spec.get_neurodata_type('ElectrodeGroup'))
self.map_spec(
'ogen_sites',
general_spec.get_group('optogenetics').get_neurodata_type('OptogeneticStimulusSite'))
self.map_spec(
'imaging_planes',
general_spec.get_group('optophysiology').get_neurodata_type('ImagingPlane'))

self.map_spec('ogen_sites',
general_spec.get_group('optogenetics').get_neurodata_type('OptogeneticStimulusSite'))

self.map_spec('imaging_planes',
general_spec.get_group('optophysiology').get_neurodata_type('ImagingPlane'))

general_datasets = ['data_collection',
'experiment_description',
Expand All @@ -62,17 +70,18 @@ def __init__(self, spec):
for dataset_name in general_datasets:
self.map_spec(dataset_name, general_spec.get_dataset(dataset_name))

proc_spec = self.spec.get_group('processing')
self.unmap(proc_spec)
self.map_spec('processing', proc_spec.get_neurodata_type('ProcessingModule'))
# self.unmap(general_spec.get_dataset('stimulus'))
# note: constructor arg and property 'stimulus' is already mapped above, so use a different name here
self.map_spec('stimulus_notes', general_spec.get_dataset('stimulus'))
self.map_spec('source_script_file_name', general_spec.get_dataset('source_script').get_attribute('file_name'))

self.map_spec('subject', general_spec.get_group('subject'))
self.map_spec('devices', general_spec.get_group('devices').get_neurodata_type('Device'))
self.map_spec('lab_meta_data', general_spec.get_neurodata_type('LabMetaData'))

proc_spec = self.spec.get_group('processing')
self.unmap(proc_spec)
self.map_spec('processing', proc_spec.get_neurodata_type('ProcessingModule'))

scratch_spec = self.spec.get_group('scratch')
self.unmap(scratch_spec)
self.map_spec('scratch_datas', scratch_spec.get_neurodata_type('ScratchData'))
Expand Down
20 changes: 20 additions & 0 deletions tests/integration/ui_write/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@ def getContainer(self, nwbfile):
return nwbfile.trials


class TestInvalidTimes(base.TestMapRoundTrip):

def setUpContainer(self):
# this will get ignored
return DynamicTable('trials', 'a placeholder table')

def addContainer(self, nwbfile):
nwbfile.add_invalid_times_column('foo', 'an int column')
nwbfile.add_invalid_times_column('bar', 'a float column')
nwbfile.add_invalid_times_column('baz', 'a string column')
nwbfile.add_invalid_times_column('qux', 'a boolean column')
nwbfile.add_invalid_time_interval(start_time=0., stop_time=1., foo=27, bar=28.0, baz="29", qux=True)
nwbfile.add_invalid_time_interval(start_time=2., stop_time=3., foo=37, bar=38.0, baz="39", qux=False)
# reset the thing
self.container = nwbfile.invalid_times

def getContainer(self, nwbfile):
return nwbfile.invalid_times


class TestUnits(base.TestMapRoundTrip):

def setUpContainer(self):
Expand Down