Skip to content

Commit

Permalink
make PatchClampSeries gain optional to match the schema (NeurodataWit…
Browse files Browse the repository at this point in the history
…houtBorders#1975)

Co-authored-by: Ryan Ly <[email protected]>
  • Loading branch information
stephprince and rly authored Nov 8, 2024
1 parent 3c0dbfa commit ad04661
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 17 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
- Fixed bug in how `ElectrodeGroup.__init__` validates its `position` argument. @oruebel [#1770](https://github.com/NeurodataWithoutBorders/pynwb/pull/1770)
- Changed `SpatialSeries.reference_frame` from required to optional as specified in the schema. @rly [#1986](https://github.com/NeurodataWithoutBorders/pynwb/pull/1986)

### Enhancements and minor changes`
### Enhancements and minor changes
- Made gain an optional argument for PatchClampSeries to match the schema. @stephprince [#1975](https://github.com/NeurodataWithoutBorders/pynwb/pull/1975)
- Added warning when writing files with `NWBHDF5IO` without the `.nwb` extension. @stephprince [#1978](https://github.com/NeurodataWithoutBorders/pynwb/pull/1978)

## PyNWB 2.8.2 (September 9, 2024)
Expand Down
33 changes: 17 additions & 16 deletions src/pynwb/icephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ class PatchClampSeries(TimeSeries):
'name': 'gain',
'type': float,
'doc': 'Units: Volt/Amp (v-clamp) or Volt/Volt (c-clamp)',
}, # required
'default': None,
},
{
'name': 'stimulus_description',
'type': str,
Expand Down Expand Up @@ -164,7 +165,7 @@ class CurrentClampSeries(PatchClampSeries):
'capacitance_compensation')

@docval(*get_docval(PatchClampSeries.__init__, 'name', 'data', 'electrode'), # required
{'name': 'gain', 'type': float, 'doc': 'Units - Volt/Volt'},
{'name': 'gain', 'type': float, 'doc': 'Units - Volt/Volt', 'default': None},
*get_docval(PatchClampSeries.__init__, 'stimulus_description'),
{'name': 'bias_current', 'type': float, 'doc': 'Unit - Amp', 'default': None},
{'name': 'bridge_balance', 'type': float, 'doc': 'Unit - Ohm', 'default': None},
Expand Down Expand Up @@ -196,7 +197,7 @@ class IZeroClampSeries(CurrentClampSeries):
__nwbfields__ = ()

@docval(*get_docval(CurrentClampSeries.__init__, 'name', 'data', 'electrode'), # required
{'name': 'gain', 'type': float, 'doc': 'Units: Volt/Volt'}, # required
{'name': 'gain', 'type': float, 'doc': 'Units: Volt/Volt', 'default': None},
{'name': 'stimulus_description', 'type': str,
'doc': ('The stimulus name/protocol. Setting this to a value other than "N/A" is deprecated as of '
'NWB 2.3.0.'),
Expand Down Expand Up @@ -238,16 +239,16 @@ class CurrentClampStimulusSeries(PatchClampSeries):

__nwbfields__ = ()

@docval(*get_docval(PatchClampSeries.__init__, 'name', 'data', 'electrode', 'gain'), # required
*get_docval(PatchClampSeries.__init__, 'stimulus_description', 'resolution', 'conversion', 'timestamps',
'starting_time', 'rate', 'comments', 'description', 'control', 'control_description',
'sweep_number', 'offset'),
@docval(*get_docval(PatchClampSeries.__init__, 'name', 'data', 'electrode'), # required
*get_docval(PatchClampSeries.__init__, 'gain', 'stimulus_description', 'resolution', 'conversion',
'timestamps', 'starting_time', 'rate', 'comments', 'description', 'control',
'control_description', 'sweep_number', 'offset'),
{'name': 'unit', 'type': str, 'doc': "The base unit of measurement (must be 'amperes')",
'default': 'amperes'})
def __init__(self, **kwargs):
name, data, unit, electrode, gain = popargs('name', 'data', 'unit', 'electrode', 'gain', kwargs)
name, data, unit, electrode = popargs('name', 'data', 'unit', 'electrode', kwargs)
unit = ensure_unit(self, name, unit, 'amperes', '2.1.0')
super().__init__(name, data, unit, electrode, gain, **kwargs)
super().__init__(name, data, unit, electrode, **kwargs)


@register_class('VoltageClampSeries', CORE_NAMESPACE)
Expand All @@ -267,7 +268,7 @@ class VoltageClampSeries(PatchClampSeries):
'whole_cell_series_resistance_comp')

@docval(*get_docval(PatchClampSeries.__init__, 'name', 'data', 'electrode'), # required
{'name': 'gain', 'type': float, 'doc': 'Units - Volt/Amp'}, # required
{'name': 'gain', 'type': float, 'doc': 'Units - Volt/Amp', 'default': None},
*get_docval(PatchClampSeries.__init__, 'stimulus_description'),
{'name': 'capacitance_fast', 'type': float, 'doc': 'Unit - Farad', 'default': None},
{'name': 'capacitance_slow', 'type': float, 'doc': 'Unit - Farad', 'default': None},
Expand Down Expand Up @@ -307,16 +308,16 @@ class VoltageClampStimulusSeries(PatchClampSeries):

__nwbfields__ = ()

@docval(*get_docval(PatchClampSeries.__init__, 'name', 'data', 'electrode', 'gain'), # required
*get_docval(PatchClampSeries.__init__, 'stimulus_description', 'resolution', 'conversion', 'timestamps',
'starting_time', 'rate', 'comments', 'description', 'control', 'control_description',
'sweep_number', 'offset'),
@docval(*get_docval(PatchClampSeries.__init__, 'name', 'data', 'electrode'), # required
*get_docval(PatchClampSeries.__init__, 'gain', 'stimulus_description', 'resolution', 'conversion',
'timestamps', 'starting_time', 'rate', 'comments', 'description', 'control',
'control_description', 'sweep_number', 'offset'),
{'name': 'unit', 'type': str, 'doc': "The base unit of measurement (must be 'volts')",
'default': 'volts'})
def __init__(self, **kwargs):
name, data, unit, electrode, gain = popargs('name', 'data', 'unit', 'electrode', 'gain', kwargs)
name, data, unit, electrode = popargs('name', 'data', 'unit', 'electrode', kwargs)
unit = ensure_unit(self, name, unit, 'volts', '2.1.0')
super().__init__(name, data, unit, electrode, gain, **kwargs)
super().__init__(name, data, unit, electrode, **kwargs)


@register_class('SweepTable', CORE_NAMESPACE)
Expand Down
21 changes: 21 additions & 0 deletions tests/integration/hdf5/test_icephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,27 @@ def addContainer(self, nwbfile):
nwbfile.add_device(self.device)
super().addContainer(nwbfile)

class TestPatchClampSeriesMin(AcquisitionH5IOMixin, TestCase):
""" Test a PatchClampSeries with minimum required args to read/write """

def setUpElectrode(self):
""" Set up the test IntracellularElectrode """
self.device = Device(name='device_name')
self.elec = IntracellularElectrode(name="elec0", description='a fake electrode object',
device=self.device)

def setUpContainer(self):
self.setUpElectrode()
return PatchClampSeries(name="pcs", data=[1, 2, 3, 4, 5], unit='A',
starting_time=123.6, rate=10e3, electrode=self.elec)

def addContainer(self, nwbfile):
"""
Add the test PatchClampSeries as an acquisition and IntracellularElectrode and Device to the given NWBFile
"""
nwbfile.add_icephys_electrode(self.elec)
nwbfile.add_device(self.device)
super().addContainer(nwbfile)

class TestCurrentClampStimulusSeries(TestPatchClampSeries):

Expand Down
7 changes: 7 additions & 0 deletions tests/unit/test_icephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ def test_default(self):
self.assertEqual(pCS.electrode, electrode_name)
self.assertEqual(pCS.gain, 1.0)

def test_gain_optional(self):
electrode_name = GetElectrode()

pCS = PatchClampSeries('test_pCS', list(), 'unit',
electrode_name, timestamps=list())
self.assertIsNone(pCS.gain)

def test_sweepNumber_valid(self):
electrode_name = GetElectrode()

Expand Down

0 comments on commit ad04661

Please sign in to comment.