コード例 #1
0
ファイル: test_cells.py プロジェクト: rcrowder/cnmodel
    def run_test(self, args):
        """
        Run either vc or cc test, and plot the result
        
        Parameters
        ----------
        args : argparse args from command line
        
        """
        self.cell.set_temperature(float(args.temp))
        print self.cell.status
        V0 = self.cell.find_i0(showinfo=True)
        #        self.cell.cell_initialize()
        print 'Currents at nominal Vrest= %.2f I = 0: I = %g ' % (
            V0, self.cell.i_currents(V=V0))
        self.cell.print_mechs(self.cell.soma)
        instant = self.cell.compute_rmrintau(auto_initialize=False,
                                             vrange=None)
        print(
            '    From Inst: Rin = {:7.1f}  Tau = {:7.1f}  Vm = {:7.1f}'.format(
                instant['Rin'], instant['tau'], instant['v']))
        if args.cc is True:
            # define the current clamp electrode and default settings
            self.iv = IVCurve()
            self.iv.run(ccivrange[args.species][args.celltype],
                        self.cell,
                        durs=default_durs,
                        sites=sites,
                        reppulse=ptype,
                        temp=float(args.temp))
            ret = self.iv.input_resistance_tau()
            print('    From IV: Rin = {:7.1f}  Tau = {:7.1f}  Vm = {:7.1f}'.
                  format(ret['slope'], ret['tau'], ret['intercept']))
            self.iv.show(cell=self.cell)

        elif args.rmp is True:
            print 'temperature: ', self.cell.status['temperature']
            self.iv = IVCurve()
            self.iv.run({'pulse': (0, 0, 1)},
                        self.cell,
                        durs=default_durs,
                        sites=sites,
                        reppulse=ptype,
                        temp=float(args.temp))
            self.iv.show(cell=self.cell, rmponly=True)

        elif args.vc is True:
            # define the voltage clamp electrode and default settings
            self.vc = VCCurve()
            self.vc.run((-120, 40, 5), self.cell)
            self.vc.show(cell=self.cell)

        else:
            raise ValueError(
                "Nothing to run. Specify one of --cc, --vc, --rmp.")
コード例 #2
0
ファイル: test_decorator.py プロジェクト: johnsonc/cnmodel
 def __init__(self, filename):
     # build plotting area
     #
     self.filename = filename
     self.iv = IVCurve()  # use standard IVCurve here...
     self.temperature = 34
     self.initdelay = 150.
コード例 #3
0
    def run_test(self, cell):
        # run I/V test on cell
        V0 = cell.find_i0(showinfo=True)
        rmrintau = cell.compute_rmrintau(auto_initialize=False, vrange=None)
        iv = IVCurve()
        self.iv = iv
        iv.run(cell.i_test_range, cell)
        if self.audit:
            iv.show(cell)

        info = dict(
            temp=iv.temp,
            icmd=iv.current_cmd,
            spikes=iv.spike_times(),
            rmp=iv.rest_vm(),
            rm_taum=iv.input_resistance_tau(),
            vpeak=iv.peak_vm(),
            vss=iv.steady_vm(),
            rmrintau=rmrintau,
        )
        return info
コード例 #4
0
    def run(self):
        sre = re.compile(
            '(?P<cell>\w+)(?:[, ]*)(?P<type>[\w-]*)(?:[, ]*)(?P<species>[\w-]*)'
        )  # regex for keys in cell types
        self.celltypes = OrderedDict([
            ('Bushy, II', (cells.Bushy, "II", 'guineapig', (-0.5, 0.5, 11),
                           22)),
            ('Bushy, II-I', (cells.Bushy, "II-I", 'guineapig', (-0.5, 0.5, 11),
                             22)),
            ('DStellate, I-II', (cells.DStellate, 'I-II', 'guineapig',
                                 (-0.3, 0.3, 9), 22)),
            ('TStellate, I-c', (cells.TStellate, "I-c", 'guineapig',
                                (-0.15, 0.15, 9), 22)),
            ('TStellate, I-t', (cells.TStellate, "I-t", 'guineapig',
                                (-0.15, 0.15, 9), 22)),
            ('Octopus, II-o', (cells.Octopus, 'II-o', 'guineapig', (-2.5, 2.5,
                                                                    11), 22)),
            ('Bushy, II, Mouse', (cells.Bushy, "II", 'mouse', (-1, 1.2, 13),
                                  34)),
            ('TStellate, I-c, Mouse', (cells.TStellate, "I-c", 'mouse',
                                       (-1, 1, 9), 34)),
            ('DStellate, I-II, Mouse', (cells.DStellate, 'I-II', 'mouse',
                                        (-0.5, 0.5, 9), 34)),
            ('Pyramidal, I, Rat', (cells.Pyramidal, 'I', 'rat', (-0.3, 0.4,
                                                                 11), 34)),
            ('Cartwheel, I, Mouse', (cells.Cartwheel, 'I', 'mouse', (-0.5, 0.5,
                                                                     9), 34)),
            ('Tuberculoventral, I, Mouse', (cells.Tuberculoventral, 'I',
                                            'mouse', (-0.35, 1, 11), 34)),
            ('SGC, bm, Mouse', (cells.SGC, "bm", 'mouse', (-0.2, 0.6, 9), 34)),
            ('SGC, a, Mouse', (cells.SGC, "a", 'mouse', (-0.2, 0.6, 9), 34)),
        ])

        dt = 0.025
        h.dt = dt
        h.celsius = 22

        stim = {
            'NP': 1,
            'delay': 10,
            'dur': 100,
            'amp': 0.,
            'dt': h.dt,
        }
        tend = stim['delay'] + stim['dur'] + 20.

        netcells = {}
        for c in self.celltypes.keys():
            g = sre.match(c)
            cellname = g.group('cell')
            modelType = g.group('type')
            species = self.celltypes[c][2]
            if g.group('type') == '':
                netcells[c] = self.celltypes[c][0].create()
            else:
                netcells[c] = self.celltypes[c][0].create(modelType=modelType,
                                                          species=species,
                                                          debug=False)
        # dicts to hold data
        pl = OrderedDict([])
        pl2 = OrderedDict([])
        rvec = OrderedDict([])
        vec = OrderedDict([])
        istim = OrderedDict([])
        ncells = len(self.celltypes.keys())
        #
        # build plotting area
        #
        app = pg.mkQApp()
        self.win = pg.GraphicsWindow()
        self.win.setBackground('w')
        self.win.resize(800, 600)
        cols, rows = autorowcol(ncells)

        row = 0
        col = 0
        labelStyle = {'color': '#000', 'font-size': '9pt', 'weight': 'normal'}
        tickStyle = pg.QtGui.QFont('Arial', 9, pg.QtGui.QFont.Light)
        self.iv = IVCurve()  # use standard IVCurve here...
        for n, name in enumerate(self.celltypes.keys()):
            nrn_cell = netcells[
                name]  # get the Neuron object we are using for this cell class
            injcmds = list(self.celltypes[name][3])  # list of injections
            injcmds[2] = (injcmds[1] - injcmds[0]) / (
                float(injcmds[2] - 1))  # convert to pulse format for IVCurve
            temperature = self.celltypes[name][4]
            nrn_cell.set_temperature(float(temperature))
            ninjs = len(injcmds)
            print('cell: ', name)
            # print( 'injs: ', injcmds)
            pl[name] = self.win.addPlot(labels={
                'left': 'V (mV)',
                'bottom': 'Time (ms)'
            })
            PH.nice_plot(pl[name])
            pl[name].setTitle(title=name, font=pg.QtGui.QFont('Arial', 10))
            col += 1
            if col >= cols:
                col = 0
                self.win.nextRow()
                row += 1
            self.iv.reset()
            self.iv.run({'pulse': [injcmds]},
                        nrn_cell,
                        durs=(stim['delay'], stim['dur'], 20.),
                        sites=None,
                        reppulse=None,
                        temp=float(temperature))
            for k in range(len(self.iv.voltage_traces)):
                pl[name].plot(self.iv.time_values,
                              self.iv.voltage_traces[k],
                              pen=pg.mkPen('k', width=0.75))
            pl[name].setRange(xRange=(0., 130.), yRange=(-160., 40.))
            PH.noaxes(pl[name])
            PH.calbar(pl[self.celltypes.keys()[0]],
                      calbar=[0, -120., 10., 20.],
                      unitNames={
                          'x': 'ms',
                          'y': 'mV'
                      })
            text = (u"{0:2d}\u00b0C {1:.2f}-{2:.2f} nA".format(
                int(temperature), np.min(self.iv.current_cmd),
                np.max(self.iv.current_cmd)))
            ti = pg.TextItem(text, anchor=(1, 0))
            ti.setFont(pg.QtGui.QFont('Arial', 9))
            ti.setPos(120., -120.)
            pl[name].addItem(ti)
        # get overall Rin, etc; need to initialize all cells
        nrn_cell.cell_initialize()
        for n, name in enumerate(self.celltypes.keys()):
            nrn_cell = netcells[name]
            nrn_cell.vm0 = nrn_cell.soma.v
            pars = nrn_cell.compute_rmrintau(auto_initialize=False)
            print(
                u'{0:>14s} [{1:>24s}]   *** Rin = {2:6.1f} M\ohm  Tau = {3:6.1f} ms   Vm = {4:6.1f} mV'
                .format(nrn_cell.status['name'], name, pars['Rin'],
                        pars['tau'], pars['v']))