Skip to content

Commit

Permalink
Patch clamp series data shape (#1596)
Browse files Browse the repository at this point in the history
* add missing shape constraint for PatchClampSeries.data
* Update CHANGELOG.md
  • Loading branch information
bendichter authored Dec 3, 2022
1 parent a1af42d commit 31b887d
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 20 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
[#1586](https://github.com/NeurodataWithoutBorders/pynwb/pull/1586)
- More informative error message for common installation error. @bendichter, @rly
[#1591](https://github.com/NeurodataWithoutBorders/pynwb/pull/1591)

### Bug fixes
- Add shape constraint to `PatchClampSeries.data`. @bendichter
[#1596](https://github.com/NeurodataWithoutBorders/pynwb/pull/1596)
- Update the [images tutorial](https://pynwb.readthedocs.io/en/stable/tutorials/domain/images.html) to provide example usage of an ``IndexSeries``
with a reference to ``Images``. @bendichter [#1602](https://github.com/NeurodataWithoutBorders/pynwb/pull/1602)

## PyNWB 2.2.0 (October 19, 2022)

### Enhancements and minor changes
Expand Down
76 changes: 57 additions & 19 deletions src/pynwb/icephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,63 @@ class PatchClampSeries(TimeSeries):
(this class should not be instantiated directly).
'''

__nwbfields__ = ('electrode',
'gain',
'stimulus_description',
'sweep_number')

@docval(*get_docval(TimeSeries.__init__, 'name'), # required
{'name': 'data', 'type': ('array_data', 'data', TimeSeries), # required
'doc': 'The data values. The first dimension must be time.'},
{'name': 'unit', 'type': str, 'doc': 'The base unit of measurement (should be SI unit)'}, # required
{'name': 'electrode', 'type': IntracellularElectrode, # required
'doc': 'IntracellularElectrode group that describes the electrode that was used to apply '
'or record this data.'},
{'name': 'gain', 'type': float, 'doc': 'Units: Volt/Amp (v-clamp) or Volt/Volt (c-clamp)'}, # required
{'name': 'stimulus_description', 'type': str, 'doc': 'the stimulus name/protocol', 'default': "N/A"},
*get_docval(TimeSeries.__init__, 'resolution', 'conversion', 'timestamps', 'starting_time', 'rate',
'comments', 'description', 'control', 'control_description', 'offset'),
{'name': 'sweep_number', 'type': (int, 'uint32', 'uint64'),
'doc': 'Sweep number, allows for grouping different PatchClampSeries together '
'via the sweep_table', 'default': None})
__nwbfields__ = (
'electrode',
'gain',
'stimulus_description',
'sweep_number',
)

@docval(
*get_docval(TimeSeries.__init__, 'name'), # required
{
"name": "data",
"type": ("array_data", "data", TimeSeries),
"doc": "The data values. The first dimension must be time.",
"shape": (None,),
}, # required
{
'name': 'unit',
'type': str,
'doc': 'The base unit of measurement (should be SI unit)',
}, # required
{
'name': 'electrode',
'type': IntracellularElectrode,
'doc': 'IntracellularElectrode group that describes the electrode that was '
'used to apply or record this data.',
}, # required
{
'name': 'gain',
'type': float,
'doc': 'Units: Volt/Amp (v-clamp) or Volt/Volt (c-clamp)',
}, # required
{
'name': 'stimulus_description',
'type': str,
'doc': 'the stimulus name/protocol',
'default': "N/A",
},
*get_docval(
TimeSeries.__init__,
'resolution',
'conversion',
'timestamps',
'starting_time',
'rate',
'comments',
'description',
'control',
'control_description',
'offset',
),
{
'name': 'sweep_number', 'type': (int, 'uint32', 'uint64'),
'doc': 'Sweep number, allows for grouping different PatchClampSeries '
'together via the sweep_table',
'default': None,
}
)
def __init__(self, **kwargs):
name, data, unit, stimulus_description = popargs('name', 'data', 'unit', 'stimulus_description', kwargs)
electrode, gain, sweep_number = popargs('electrode', 'gain', 'sweep_number', kwargs)
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/test_icephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,19 @@ def test_sweepNumber_throws_with_Float(self):
PatchClampSeries('test_pCS', list(), 'unit',
electrode_name, 1.0, timestamps=list(), sweep_number=1.5)

def test_data_shape(self):
electrode_name = GetElectrode()

with self.assertRaises(ValueError):
PatchClampSeries(
name="test_pCS",
data=np.ones((30, 2)),
unit="unit",
electrode=electrode_name,
gain=1.0,
rate=100_000.,
)


class CurrentClampSeriesConstructor(TestCase):

Expand Down

0 comments on commit 31b887d

Please sign in to comment.