Esempio n. 1
0
def test_show_single_sweep_sequence():

    device = Device(name='Axon Patch-Clamp')
    electrode = IntracellularElectrode(name='Patch Clamp',
                                       device=device,
                                       description='whole-cell')

    stimulus_data = np.random.rand(160, 2)
    stimulus = TimeSeries(name='test_timeseries',
                          data=stimulus_data,
                          unit='m',
                          starting_time=0.0,
                          rate=1.0)
    response_data = np.random.rand(160, 2)
    response = TimeSeries(name='test_timeseries',
                          data=response_data,
                          unit='m',
                          starting_time=0.0,
                          rate=1.0)

    icr = IntracellularRecordings()
    icr.add_recording(electrode=electrode,
                      stimulus_start_index=0,
                      stimulus_index_count=100,
                      stimulus=stimulus,
                      response_start_index=0,
                      response_index_count=100,
                      response=response)

    sweeps_table = Sweeps(intracellular_recordings_table=icr)
    assert isinstance(show_single_sweep_sequence(sweeps_table), plt.Figure)
Esempio n. 2
0
 def setUpContainer(self):
     """ Return the test SweepTable to read/write """
     self.device = Device(name='device_name')
     self.elec = IntracellularElectrode(
         name="elec0",
         slice='tissue slice',
         resistance='something measured in ohms',
         seal='sealing method',
         description='a fake electrode object',
         location='Springfield Elementary School',
         filtering='a meaningless free-form text field',
         initial_access_resistance='I guess this changes',
         device=self.device)
     self.pcs = PatchClampSeries(name="pcs",
                                 data=[1, 2, 3, 4, 5],
                                 unit='A',
                                 starting_time=123.6,
                                 rate=10e3,
                                 electrode=self.elec,
                                 gain=0.126,
                                 stimulus_description="gotcha ya!",
                                 sweep_number=np.uint(4711))
     # Create the SweepTable but ignore the DeprecationWarning
     with warnings.catch_warnings(record=True) as w:
         warnings.simplefilter('ignore', DeprecationWarning)
         sweeptable = SweepTable(name='sweep_table')
         # Reissue any other warnings that may have occured
         for i in w:
             warnings.warn(i.message, i.category)
     return sweeptable
Esempio n. 3
0
    def addContainer(self, nwbfile):
        device = Device(name='device_name')
        nwbfile.add_device(device)
        elec = IntracellularElectrode(
            name="elec0",
            slice='tissue slice',
            resistance='something measured in ohms',
            seal='sealing method',
            description='a fake electrode object',
            location='Springfield Elementary School',
            filtering='a meaningless free-form text field',
            initial_access_resistance='I guess this changes',
            device=device)
        nwbfile.add_ic_electrode(elec)
        pcs = PatchClampSeries(name="pcs",
                               data=[1, 2, 3, 4, 5],
                               unit='A',
                               starting_time=123.6,
                               rate=10e3,
                               electrode=elec,
                               gain=0.126,
                               stimulus_description="gotcha ya!",
                               sweep_number=4711)
        nwbfile.add_acquisition(pcs)
        self.container = nwbfile.sweep_table

        self.assertEqual(len(self.container['series'].data), 1)
        self.assertEqual(self.container.id[0], 0)
        self.assertEqual(self.container['sweep_number'].data[0], 4711)
Esempio n. 4
0
    def _createElectrodes(self, device):
        """
        Create pynwb ic_electrodes objects from the ABF file contents.
        """

        return [IntracellularElectrode(f"Electrode {x:d}",
                                       device,
                                       description=PLACEHOLDER)
                for x in self.refabf.channelList]
Esempio n. 5
0
 def setUpElectrode(self):
     """ Set up the test IntracellularElectrode """
     self.device = Device(name='device_name')
     self.elec = IntracellularElectrode(name="elec0", slice='tissue slice',
                                        resistance='something measured in ohms',
                                        seal='sealing method', description='a fake electrode object',
                                        location='Springfield Elementary School',
                                        filtering='a meaningless free-form text field',
                                        initial_access_resistance='I guess this changes',
                                        device=self.device)
Esempio n. 6
0
 def setUpElectrode(self):
     self.elec = IntracellularElectrode(name="elec0",
                                        source='',
                                        slice='',
                                        resistance='',
                                        seal='',
                                        description='',
                                        location='',
                                        filtering='',
                                        initial_access_resistance='',
                                        device='')
Esempio n. 7
0
def GetElectrode():
    device = Device(name='device_name')
    elec = IntracellularElectrode(
        name='test_iS',
        device=device,
        description='description',
        slice='slice',
        seal='seal',
        location='location',
        resistance='resistance',
        filtering='filtering',
        initial_access_resistance='initial_access_resistance')
    return elec
Esempio n. 8
0
def GetElectrode():
        device = Device(name='device_name', source='device_source')
        elec = IntracellularElectrode('test_iS',
                                      device,
                                      'a test source',
                                      'slice',
                                      'seal',
                                      'description',
                                      'location',
                                      'resistance',
                                      'filtering',
                                      'initial_access_resistance')
        return elec
Esempio n. 9
0
 def GetElectrode(self):
     device = Device(name='device_name', source='device_source')
     elec = IntracellularElectrode('slice', 'seal', 'description', 'location', 'resistance',
                                   'filtering', 'initial_access_resistance',
                                   device)
     self.assertEqual(elec.slice, 'slice')
     self.assertEqual(elec.seal, 'seal')
     self.assertEqual(elec.description, 'description')
     self.assertEqual(elec.location, 'location')
     self.assertEqual(elec.resistance, 'resistance')
     self.assertEqual(elec.filtering, 'filtering')
     self.assertEqual(elec.initial_access_resistance, 'initial_access_resistance')
     self.assertEqual(elec.device, device)
Esempio n. 10
0
 def setUpContainer(self):
     elec = IntracellularElectrode(
         name="elec0",
         source='ice source',
         slice='tissue slice',
         resistance='something measured in ohms',
         seal='sealing method',
         description='a fake electrode object',
         location='Springfield Elementary School',
         filtering='a meaningless free-form text field',
         initial_access_resistance='I guess this changes',
         device='I should be a Device object, but just a name will do')
     return elec
Esempio n. 11
0
 def setUpContainer(self):
     """ Return the test SweepTable to read/write """
     self.device = Device(name='device_name')
     self.elec = IntracellularElectrode(name="elec0", slice='tissue slice',
                                        resistance='something measured in ohms',
                                        seal='sealing method', description='a fake electrode object',
                                        location='Springfield Elementary School',
                                        filtering='a meaningless free-form text field',
                                        initial_access_resistance='I guess this changes',
                                        device=self.device)
     self.pcs = PatchClampSeries(name="pcs", data=[1, 2, 3, 4, 5], unit='A',
                                 starting_time=123.6, rate=10e3, electrode=self.elec, gain=0.126,
                                 stimulus_description="gotcha ya!", sweep_number=4711)
     return SweepTable(name='sweep_table')
Esempio n. 12
0
 def test_constructor(self):
     device = Device(name='device_name')
     elec = IntracellularElectrode('test_iS', device, 'description',
                                   'slice', 'seal', 'location',
                                   'resistance', 'filtering',
                                   'initial_access_resistance')
     self.assertEqual(elec.name, 'test_iS')
     self.assertEqual(elec.device, device)
     self.assertEqual(elec.description, 'description')
     self.assertEqual(elec.slice, 'slice')
     self.assertEqual(elec.seal, 'seal')
     self.assertEqual(elec.location, 'location')
     self.assertEqual(elec.resistance, 'resistance')
     self.assertEqual(elec.filtering, 'filtering')
     self.assertEqual(elec.initial_access_resistance,
                      'initial_access_resistance')
Esempio n. 13
0
    def _createElectrodes(self, device):
        """
        Create pynwb ic_electrodes objects from the DAT file contents.

        Parameters
        ----------
        pynwb.Device

        Returns
        -------
        pynwb.IntracellularElectrode
        """

        return [
            IntracellularElectrode(f"Electrode {x:d}",
                                   device,
                                   description=PLACEHOLDER)
            for x in self.electrodeDict.values()
        ]
Esempio n. 14
0
    def addContainer(self, nwbfile):
        device = Device(name='device_name')
        nwbfile.add_device(device)
        elec = IntracellularElectrode(
            name="elec0",
            slice='tissue slice',
            resistance='something measured in ohms',
            seal='sealing method',
            description='a fake electrode object',
            location='Springfield Elementary School',
            filtering='a meaningless free-form text field',
            initial_access_resistance='I guess this changes',
            device=device)
        nwbfile.add_ic_electrode(elec)

        self.pcs1 = PatchClampSeries(name="pcs1",
                                     data=[1, 2, 3, 4, 5],
                                     unit='A',
                                     starting_time=123.6,
                                     rate=10e3,
                                     electrode=elec,
                                     gain=0.126,
                                     stimulus_description="gotcha ya!",
                                     sweep_number=4711)
        nwbfile.add_acquisition(self.pcs1)

        self.pcs2a = PatchClampSeries(name="pcs2a",
                                      data=[1, 2, 3, 4, 5],
                                      unit='A',
                                      starting_time=123.6,
                                      rate=10e3,
                                      electrode=elec,
                                      gain=0.126,
                                      stimulus_description="gotcha ya!",
                                      sweep_number=4712)
        nwbfile.add_stimulus_template(self.pcs2a)

        self.pcs2b = PatchClampSeries(name="pcs2b",
                                      data=[1, 2, 3, 4, 5],
                                      unit='A',
                                      starting_time=123.6,
                                      rate=10e3,
                                      electrode=elec,
                                      gain=0.126,
                                      stimulus_description="gotcha ya!",
                                      sweep_number=4712)
        nwbfile.add_stimulus(self.pcs2b)

        self.container = nwbfile.sweep_table

        self.assertEqual(len(self.container['series'].data), 3)
        self.assertEqual(self.container['sweep_number'].data[0], 4711)
        self.assertEqual(self.container['sweep_number'].data[1], 4712)
        self.assertEqual(self.container['sweep_number'].data[2], 4712)

        series = self.container.get_series(4711)
        self.assertEqual(len(series), 1)
        names = [elem.name for elem in series]
        self.assertEqual(names, ["pcs1"])
        sweep_numbers = [elem.sweep_number for elem in series]
        self.assertEqual(sweep_numbers, [4711])

        series = self.container.get_series(4712)
        self.assertEqual(len(series), 2)
        names = [elem.name for elem in series]
        self.assertEqual(names, ["pcs2a", "pcs2b"])
        sweep_numbers = [elem.sweep_number for elem in series]
        self.assertEqual(sweep_numbers, [4712, 4712])