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

Add support for ElectricalSeries.filtering dataset #1270

Merged
merged 4 commits into from
Jul 30, 2020
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
13 changes: 11 additions & 2 deletions src/pynwb/ecephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class ElectricalSeries(TimeSeries):

__nwbfields__ = ({'name': 'electrodes', 'required_name': 'electrodes',
'doc': 'the electrodes that generated this electrical series', 'child': True},
'channel_conversion')
'channel_conversion',
'filtering')

@docval(*get_docval(TimeSeries.__init__, 'name'), # required
{'name': 'data', 'type': ('array_data', 'data', TimeSeries), # required
Expand All @@ -65,13 +66,21 @@ class ElectricalSeries(TimeSeries):
"to support the storage of electrical recordings as native values generated by data acquisition systems. "
"If this dataset is not present, then there is no channel-specific conversion factor, i.e. it is 1 for all"
" channels.", 'default': None},
{'name': 'filtering', 'type': str, 'doc':
"Filtering applied to all channels of the data. For example, if this ElectricalSeries represents "
"high-pass-filtered data (also known as AP Band), then this value could be 'High-pass 4-pole Bessel "
"filter at 500 Hz'. If this ElectricalSeries represents low-pass-filtered LFP data and the type of "
"filter is unknown, then this value could be 'Low-pass filter at 300 Hz'. If a non-standard filter "
"type is used, provide as much detail about the filter properties as possible.", 'default': None},
*get_docval(TimeSeries.__init__, 'resolution', 'conversion', 'timestamps', 'starting_time', 'rate',
'comments', 'description', 'control', 'control_description'))
def __init__(self, **kwargs):
name, electrodes, data, channel_conversion = popargs('name', 'electrodes', 'data', 'channel_conversion', kwargs)
name, electrodes, data, channel_conversion, filtering = popargs('name', 'electrodes', 'data',
'channel_conversion', 'filtering', kwargs)
super(ElectricalSeries, self).__init__(name, data, 'volts', **kwargs)
self.electrodes = electrodes
self.channel_conversion = channel_conversion
self.filtering = filtering


@register_class('SpikeEventSeries', CORE_NAMESPACE)
Expand Down
2 changes: 1 addition & 1 deletion src/pynwb/nwb-schema
15 changes: 10 additions & 5 deletions tests/integration/hdf5/test_ecephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ def setUpContainer(self):
table=self.table)
data = list(zip(range(10), range(10, 20)))
timestamps = list(map(lambda x: x/10., range(10)))
es = ElectricalSeries(name='test_eS',
data=data,
electrodes=region,
channel_conversion=[4., .4],
timestamps=timestamps)
channel_conversion = [1., 2., 3., 4.]
filtering = 'Low-pass filter at 300 Hz'
es = ElectricalSeries(
name='test_eS',
data=data,
electrodes=region,
channel_conversion=channel_conversion,
filtering=filtering,
timestamps=timestamps
)
return es

def addContainer(self, nwbfile):
Expand Down
14 changes: 13 additions & 1 deletion tests/unit/test_ecephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,24 @@ class ElectricalSeriesConstructor(TestCase):
def test_init(self):
data = list(range(10))
ts = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
channel_conversion = [2., 6.3]
filtering = 'Low-pass filter at 300 Hz'
table = make_electrode_table()
region = DynamicTableRegion('electrodes', [0, 2], 'the first and third electrodes', table)
eS = ElectricalSeries('test_eS', data, region, channel_conversion=[2., 6.3], timestamps=ts)
eS = ElectricalSeries(
name='test_eS',
data=data,
electrodes=region,
channel_conversion=channel_conversion,
filtering=filtering,
timestamps=ts
)
self.assertEqual(eS.name, 'test_eS')
self.assertEqual(eS.data, data)
self.assertEqual(eS.electrodes, region)
self.assertEqual(eS.timestamps, ts)
self.assertEqual(eS.channel_conversion, [2., 6.3])
self.assertEqual(eS.filtering, filtering)

def test_link(self):
table = make_electrode_table()
Expand Down