Skip to content

Commit

Permalink
make patchclampseries gain optional
Browse files Browse the repository at this point in the history
  • Loading branch information
stephprince committed Oct 24, 2024
1 parent e938202 commit 2fff4f9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
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)

def test_sweepNumber_valid(self):
electrode_name = GetElectrode()

Expand Down

0 comments on commit 2fff4f9

Please sign in to comment.