From 2fff4f9eb9d4cbc51e5f82784d36bc8bab4c5768 Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Thu, 24 Oct 2024 09:44:42 -0700 Subject: [PATCH] make patchclampseries gain optional --- src/pynwb/icephys.py | 33 +++++++++++++++++---------------- tests/unit/test_icephys.py | 7 +++++++ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/pynwb/icephys.py b/src/pynwb/icephys.py index 3101649fd..ec44a2bd8 100644 --- a/src/pynwb/icephys.py +++ b/src/pynwb/icephys.py @@ -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, @@ -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}, @@ -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.'), @@ -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) @@ -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}, @@ -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) diff --git a/tests/unit/test_icephys.py b/tests/unit/test_icephys.py index e0e8332f9..5ada7ec12 100644 --- a/tests/unit/test_icephys.py +++ b/tests/unit/test_icephys.py @@ -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()