Exemplo n.º 1
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.pcs1 = PatchClampSeries(name="pcs1",
                                     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))
        self.pcs2a = PatchClampSeries(name="pcs2a",
                                      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(4712))
        self.pcs2b = PatchClampSeries(name="pcs2b",
                                      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(4712))

        # 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
Exemplo n.º 2
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)
Exemplo n.º 3
0
    def setUpSweepTable(self):
        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.pcs1 = PatchClampSeries(name="pcs1",
                                     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)
        self.pcs2a = PatchClampSeries(name="pcs2a",
                                      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=4712)
        self.pcs2b = PatchClampSeries(name="pcs2b",
                                      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=4712)

        self.sweep_table = SweepTable(name='sweep_table')
        self.sweep_table.add_entry(self.pcs1)
        self.sweep_table.add_entry(self.pcs2a)
        self.sweep_table.add_entry(self.pcs2b)
Exemplo n.º 4
0
    def test_init(self):
        electrode_name = GetElectrode()

        pCS = PatchClampSeries('test_pCS', 'a hypothetical source', list(), 'unit',
                               electrode_name, 1.0, timestamps=list())
        self.assertEqual(pCS.name, 'test_pCS')
        self.assertEqual(pCS.source, 'a hypothetical source')
        self.assertEqual(pCS.unit, 'unit')
        self.assertEqual(pCS.electrode, electrode_name)
        self.assertEqual(pCS.gain, 1.0)
Exemplo n.º 5
0
    def test_sweepNumber_throws_with_Float(self):
        electrode_name = GetElectrode()

        with self.assertRaises(TypeError):
            PatchClampSeries('test_pCS',
                             list(),
                             'unit',
                             electrode_name,
                             1.0,
                             timestamps=list(),
                             sweep_number=1.5)
Exemplo n.º 6
0
 def setUpContainer(self):
     self.setUpElectrode()
     return 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)
Exemplo n.º 7
0
    def test_default(self):
        electrode_name = GetElectrode()

        pCS = PatchClampSeries('test_pCS',
                               list(),
                               'unit',
                               electrode_name,
                               1.0,
                               timestamps=list())
        self.assertEqual(pCS.name, 'test_pCS')
        self.assertEqual(pCS.unit, 'unit')
        self.assertEqual(pCS.electrode, electrode_name)
        self.assertEqual(pCS.gain, 1.0)
Exemplo n.º 8
0
    def test_sweepNumber_large_and_valid(self):
        electrode_name = GetElectrode()

        pCS = PatchClampSeries('test_pCS',
                               list(),
                               'unit',
                               electrode_name,
                               1.0,
                               timestamps=list(),
                               sweep_number=np.uint64(2**63 - 1))
        self.assertEqual(pCS.name, 'test_pCS')
        self.assertEqual(pCS.unit, 'unit')
        self.assertEqual(pCS.electrode, electrode_name)
        self.assertEqual(pCS.gain, 1.0)
        self.assertEqual(pCS.sweep_number, 2**63 - 1)
Exemplo n.º 9
0
    def test_sweepNumber_valid_np(self):
        electrode_name = GetElectrode()

        pCS = PatchClampSeries('test_pCS',
                               list(),
                               'unit',
                               electrode_name,
                               1.0,
                               timestamps=list(),
                               sweep_number=1)
        self.assertEqual(pCS.name, 'test_pCS')
        self.assertEqual(pCS.unit, 'unit')
        self.assertEqual(pCS.electrode, electrode_name)
        self.assertEqual(pCS.gain, 1.0)
        self.assertEqual(pCS.sweep_number, np.uint32(1))
Exemplo n.º 10
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))
     return SweepTable(name='sweep_table')
Exemplo n.º 11
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])