Пример #1
0
 def setUpContainer(self):
     self.setUpElectrode()
     return CurrentClampStimulusSeries(name="ccss",
                                       data=[1, 2, 3, 4, 5],
                                       starting_time=123.6,
                                       rate=10e3,
                                       electrode=self.elec,
                                       gain=0.126)
Пример #2
0
    def test_init(self):
        electrode_name = GetElectrode()

        cCSS = CurrentClampStimulusSeries('test_cCSS', 'a hypothetical source', list(),
                                          'unit', electrode_name, 1.0, timestamps=list())
        self.assertEqual(cCSS.name, 'test_cCSS')
        self.assertEqual(cCSS.source, 'a hypothetical source')
        self.assertEqual(cCSS.unit, 'unit')
        self.assertEqual(cCSS.electrode, electrode_name)
        self.assertEqual(cCSS.gain, 1.0)
Пример #3
0
 def setUpContainer(self):
     self.setUpElectrode()
     ccss = CurrentClampStimulusSeries(name="ccss",
                                       source="command",
                                       data=[1, 2, 3, 4, 5],
                                       unit='A',
                                       starting_time=123.6,
                                       rate=10e3,
                                       electrode=self.elec,
                                       gain=0.126)
     return ccss
Пример #4
0
    def test_init(self):
        electrode_name = GetElectrode()

        cCSS = CurrentClampStimulusSeries('test_cCSS',
                                          list(),
                                          electrode_name,
                                          1.0,
                                          timestamps=list())
        self.assertEqual(cCSS.name, 'test_cCSS')
        self.assertEqual(cCSS.unit, 'amperes')
        self.assertEqual(cCSS.electrode, electrode_name)
        self.assertEqual(cCSS.gain, 1.0)
Пример #5
0
    def test_unit_warning(self):
        electrode_name = GetElectrode()

        msg = (
            "Unit for CurrentClampStimulusSeries 'test_cCSS' is ignored and will be set to 'amperes' as per NWB "
            "2.1.0.")
        with self.assertWarnsWith(UserWarning, msg):
            cCSS = CurrentClampStimulusSeries('test_cCSS',
                                              list(),
                                              electrode_name,
                                              1.0,
                                              timestamps=list(),
                                              unit='unit')
        self.assertEqual(cCSS.unit, 'amperes')
Пример #6
0
def test_stimulus_round_trip(nwb_filename):

    nwbfile = NWBFile(session_description='test ephys',
                      identifier='session_uuid',
                      session_start_time=datetime.datetime.now(),
                      file_create_date=datetime.datetime.now())
    device = nwbfile.create_device(name='electrode_0')

    electrode = nwbfile.create_ic_electrode(
        name="elec0", description=' some kind of electrode', device=device)

    data = np.array([1., 3.76, 0., 67, -2.89])
    meta_data = {
        "name": "test_stimulus_sweep",
        "sweep_number": 4,
        "unit": "amperes",
        "gain": 32.0,
        "resolution": 1.0,
        "conversion": 1.0E-3,
        "starting_time": 1.5,
        "rate": 7000.0,
        "stimulus_description": "STIMULUS_CODE"
    }

    time_series = CurrentClampStimulusSeries(data=data,
                                             electrode=electrode,
                                             **meta_data)

    nwbfile.add_stimulus(time_series)

    with NWBHDF5IO(nwb_filename, mode='w') as io:
        io.write(nwbfile)
    nwbfile_in = NWBHDF5IO(nwb_filename, mode='r').read()

    time_series_in = nwbfile_in.get_stimulus(meta_data["name"])

    assert np.allclose(data, time_series_in.data)
    for k, v in meta_data.items():
        assert getattr(time_series_in, k) == v
Пример #7
0
# Intracellular stimulus and response data are represented with subclasses of
# :py:class:`~pynwb.icephys.PatchClampSeries`. There are two classes for representing stimulus
# data--:py:class:`~pynwb.icephys.VoltageClampStimulusSeries` and
# :py:class:`~pynwb.icephys.CurrentClampStimulusSeries`--, and three classes for representing response
# data--:py:class:`~pynwb.icephys.VoltageClampSeries`,
# :py:class:`~pynwb.icephys.VoltageClampSeries`, :py:class:`~pynwb.icephys.CurrentClampSeries`, and
# :py:class:`~pynwb.icephys.IZeroClampSeries`.
#
# Here, we will use :py:class:`~pynwb.icephys.CurrentClampStimulusSeries` to store current clamp stimulus
# data and then add it to our NWBFile as stimulus data using the :py:class:`~pynwb.file.NWBFile` method
# :py:meth:`~pynwb.file.NWBFile.add_stimulus`.

from pynwb.icephys import CurrentClampStimulusSeries

ccss = CurrentClampStimulusSeries(
    name="ccss", source="command", data=[1, 2, 3, 4, 5], unit='A',
    starting_time=123.6, rate=10e3, electrode=elec, gain=0.02)

nwbfile.add_stimulus(ccss)

# Here, we will use :py:class:`~pynwb.icephys.VoltageClampSeries` to store voltage clamp
# data and then add it to our NWBFile as acquired data using the :py:class:`~pynwb.file.NWBFile` method
# :py:meth:`~pynwb.file.NWBFile.add_acquisition`.

from pynwb.icephys import VoltageClampSeries

vcs = VoltageClampSeries(
    name='vcs', source="command", data=[0.1, 0.2, 0.3, 0.4, 0.5],
    unit='A', conversion=1e-12, resolution=np.nan, starting_time=123.6, rate=20e3,
    electrode=elec, gain=0.02, capacitance_slow=100e-12, resistance_comp_correction=70.0,
    capacitance_fast=np.nan, resistance_comp_bandwidth=np.nan, resistance_comp_prediction=np.nan,
Пример #8
0
# :py:class:`~pynwb.icephys.PatchClampSeries`. There are two classes for representing stimulus
# data--:py:class:`~pynwb.icephys.VoltageClampStimulusSeries` and
# :py:class:`~pynwb.icephys.CurrentClampStimulusSeries`--, and three classes for representing response
# data--:py:class:`~pynwb.icephys.VoltageClampSeries`, :py:class:`~pynwb.icephys.CurrentClampSeries`, and
# :py:class:`~pynwb.icephys.IZeroClampSeries`.
#
# Here, we will use :py:class:`~pynwb.icephys.CurrentClampStimulusSeries` to store current clamp stimulus
# data and then add it to our NWBFile as stimulus data using the :py:class:`~pynwb.file.NWBFile` method
# :py:meth:`~pynwb.file.NWBFile.add_stimulus`.

from pynwb.icephys import CurrentClampStimulusSeries

ccss = CurrentClampStimulusSeries(name="ccss",
                                  data=[1, 2, 3, 4, 5],
                                  unit='A',
                                  starting_time=123.6,
                                  rate=10e3,
                                  electrode=elec,
                                  gain=0.02,
                                  sweep_number=15)

nwbfile.add_stimulus(ccss)

#######################
# Here, we will use :py:class:`~pynwb.icephys.VoltageClampSeries` to store voltage clamp
# data and then add it to our NWBFile as acquired data using the :py:class:`~pynwb.file.NWBFile` method
# :py:meth:`~pynwb.file.NWBFile.add_acquisition`.

from pynwb.icephys import VoltageClampSeries

vcs = VoltageClampSeries(name='vcs',
                         data=[0.1, 0.2, 0.3, 0.4, 0.5],
Пример #9
0
def nwbfile_to_test():
    """
    Create a simple nwbfile for testing

    Returns
    -------
    nwbfile
    """

    nwbfile = pynwb.NWBFile(session_description="test nwb data",
                            identifier='test session',
                            session_start_time=datetime.datetime.now(),
                            file_create_date=datetime.datetime.now())

    device = nwbfile.create_device(name='electrode_0')

    electrode = nwbfile.create_icephys_electrode(name="electrode 0",
                                                 description='fancy electrode',
                                                 device=device)

    stimulus_data = [0, 3, 3, 3, 0]

    stimulus_meta_data = {
        "name": "stimulus",
        "sweep_number": 4,
        "unit": "A",
        "gain": 32.0,
        "resolution": 1.0,
        "conversion": 1.0E-3,
        "starting_time": 1.5,
        "rate": 7000.0,
        "stimulus_description": "STIMULUS_CODE"
    }

    stimulus_series = CurrentClampStimulusSeries(data=stimulus_data,
                                                 electrode=electrode,
                                                 **stimulus_meta_data)

    nwbfile.add_stimulus(stimulus_series)

    response_data = [1, 2, 3, 4, 5]
    response_meta_data = {
        "name": "acquisition",
        "sweep_number": 4,
        "unit": "V",
        "gain": 32.0,
        "resolution": 1.0,
        "conversion": 1.0E-3,
        "bridge_balance": 500.0,
        "bias_current": 100.0,
        "starting_time": 1.5,
        "rate": 7000.0,
        "stimulus_description": "STIMULUS_CODE"
    }

    acquisition_series = CurrentClampSeries(data=response_data,
                                            electrode=electrode,
                                            **response_meta_data)

    nwbfile.add_acquisition(acquisition_series)

    return nwbfile
Пример #10
0
                            'DC': dc
                        }

                        # Access sweep data in the ABF files
                        abfFiles = glob.glob(dpath + '/*.abf')
                        abfFile = pyabf.ABF(abfFiles[i])
                        sweepADC = abfFile.sweepY
                        sweepDAC = abfFile.sweepC

                        # Create time series

                        stimulus = CurrentClampStimulusSeries(
                            name="ccss",
                            data=sweepADC,
                            unit='pA',
                            electrode=elec,
                            rate=10e4,
                            gain=float(metadata['Gain'][5:8]),
                            starting_time=0.0,
                            description='DC%s' % dc)

                        acquisition = CurrentClampSeries(
                            name='ccs',
                            data=sweepDAC,
                            electrode=elec,
                            unit='mV',
                            rate=10e4,
                            gain=0.00,
                            starting_time=0.0,
                            bias_current=np.nan,
                            bridge_balance=np.nan,