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

make PatchClampSeries gain optional to match the schema #1975

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
### Bug fixes
- Fixed bug in how `ElectrodeGroup.__init__` validates its `position` argument. @oruebel [#1770](https://github.com/NeurodataWithoutBorders/pynwb/pull/1770)

### Enhancements and minor changes
- Made gain an optional argument for PatchClampSeries to match the schema. @stephprince [#1975](https://github.com/NeurodataWithoutBorders/pynwb/pull/1975)

## PyNWB 2.8.2 (September 9, 2024)

### Enhancements and minor changes
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
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)

Comment on lines +157 to +163
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add an analogous roundtrip test to make sure read is OK?

def test_sweepNumber_valid(self):
electrode_name = GetElectrode()

Expand Down
Loading