示例#1
0
 def __init__(self, filename):
     # build plotting area
     #
     self.filename = filename
     self.iv = IVCurve()  # use standard IVCurve here...
     self.temperature = 34
     self.initdelay = 150.
示例#2
0
    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.")
示例#3
0
class F5():
    def __init__(self, filename):
        # build plotting area
        #
        self.filename = filename
        self.iv = IVCurve()  # use standard IVCurve here...
        self.temperature = 34
        self.initdelay = 150.

    def run(self):
        self.post_cell = cells.Bushy.create(morphology=self.filename,
                                            decorator=Decorator,
                                            species='mouse',
                                            modelType='XM13')
        self.post_cell.set_temperature(float(self.temperature))
        self.post_cell.set_d_lambda(
            freq=2000.)  # necessary to ensure appropriate spatial
        self.iv.reset()
        irange = self.post_cell.i_test_range
        irange = {'pulse': (-0.6, 1.1, 0.2)}
        self.durs = (self.initdelay + 20., 100., 50.)
        self.iv.run(irange,
                    self.post_cell,
                    durs=self.durs,
                    temp=float(self.temperature),
                    initdelay=self.initdelay)

    def plot(self):
        pg.setConfigOption('background', 'w')  # set background to white
        pg.setConfigOption('foreground', 'k')
        self.app = pg.mkQApp()

        wintitle = 'test_decorator'
        self.view = pg.GraphicsView()
        self.layout = pg.GraphicsLayout()  #(border=(100,100,100))
        self.view.setCentralItem(self.layout)
        self.view.resize(800, 600)
        self.view.show()
        self.plots = {}
        nr1 = 6
        nc = 10
        for i in range(1, nr1):
            self.plots['p%d' % i] = None
        for i in range(1, nr1 + 1):
            self.layout.addLayout(row=i, col=nc)
        for i in range(1, nc + 1):
            self.layout.addLayout(row=nr1 + 2, col=i)

        self.plots['p1'] = self.layout.addPlot(row=1,
                                               col=1,
                                               rowspan=6,
                                               colspan=9,
                                               labels={
                                                   'left': 'V (mV)',
                                                   'bottom': 'Time (ms)'
                                               })
        self.plots['p2'] = self.layout.addPlot(row=7,
                                               col=1,
                                               rowspan=1,
                                               colspan=9,
                                               labels={
                                                   'left': 'I (nA)',
                                                   'bottom': 'Time (ms)'
                                               })

        for k in range(len(self.iv.voltage_traces)):
            self.plots['p1'].plot(self.iv.time_values,
                                  np.array(self.iv.voltage_traces[k]),
                                  pen=pg.mkPen('k', width=0.75))
            self.plots['p2'].plot(self.iv.time_values,
                                  np.array(self.iv.current_traces[k]),
                                  pen=pg.mkPen('k', width=0.75))
        self.plots['p1'].setRange(xRange=(0.,
                                          np.sum(self.durs) - self.initdelay),
                                  yRange=(-160., 40.))
        self.plots['p2'].setRange(xRange=(0.,
                                          np.sum(self.durs) - self.initdelay),
                                  yRange=(-1, 1))
        PH.noaxes(self.plots['p1'])
        PH.calbar(self.plots['p1'],
                  calbar=[125., -120., 10., 20.],
                  unitNames={
                      'x': 'ms',
                      'y': 'mV'
                  })
        PH.noaxes(self.plots['p2'])
        PH.calbar(self.plots['p2'],
                  calbar=[125, 0.1, 0., 0.5],
                  unitNames={
                      'x': 'ms',
                      'y': 'nA'
                  })

        text = (u"{0:2d}\u00b0C {1:.2f}-{2:.2f} nA".format(
            int(self.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.)
        self.plots['p1'].addItem(ti)
示例#4
0
class Toy(Protocol):
    """
    Calls to encapsulate the model runs
    Run a set of cells with defined parameters to show excitability patterns. 
    Note that cells from Rothman and Manis are run at 22C; others at various
    temperatures depending on how they were initially measured and defined.
    
    """
    def __init__(self):
        super(Toy, self).__init__()

    def current_name(self, name, n):
        """
        From the name of the current model, get the current injection information
        
        Parameters
        ---------
        name : str (no default)
            name of the cell type
        n : int (no default)
        """
        if len(self.celltypes[name][3]) > 2:
            injs = self.celltypes[name][3]
            injarr = np.linspace(injs[0], injs[1], injs[2], endpoint=True)
            return '%.3f' % injarr[n]
        else:
            return '%.3f' % self.celltypes[name][3][n]

    def getname(self, cell, ninj):
        name = self.make_name(cell)
        iname = self.current_name(name, ninj)
        nname = name + ' ' + iname
        return name, nname

    def make_name(self, cell):
        return cell + ', ' + self.celltypes[cell][1] + ':'

    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']))
示例#5
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 = QtGui.QFont('Arial', 9, 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=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(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\u03A9  \u03C4 = {3:6.1f} ms   Vm = {4:6.1f} mV'.
                format(nrn_cell.status['name'], name, pars['Rin'], pars['tau'], pars['v']))
示例#6
0
class Tests():
    """
    Class to select cells for tests
    """
    def __init__(self):
        pass

    def selectCell(self, args):
        """
        Parameters
        ----------
        args : argparse args from command line
        
        Returns
        -------
        cell
            Instantiated cell of the selected celltype
        """
        h.celsius = float(args.temp)
        #
        # Spiral Ganglion cell tests
        #
        if args.celltype == 'sgc':  # morphology is always "point" for SGCs
            cell = cells.SGC.create(debug=debugFlag,
                                    species=args.species,
                                    nach=args.nav,
                                    ttx=args.ttx,
                                    modelType=args.type)

        #
        # Bushy tests
        #
        elif args.celltype == 'bushy' and args.morphology == 'point':
            cell = cells.Bushy.create(model='RM03',
                                      species=args.species,
                                      modelType=args.type,
                                      ttx=args.ttx,
                                      nach=args.nav,
                                      debug=debugFlag)


#            cell.soma().klt.gbar = 0.0003

        elif args.celltype == 'bushy' and args.morphology == 'waxon':
            cell = cells.Bushy.create(model='RM03',
                                      species=args.species,
                                      modelType=args.type,
                                      nach=args.nav,
                                      ttx=args.ttx,
                                      debug=debugFlag)
            cell.add_axon()

        elif args.celltype == 'bushy' and args.morphology == 'stick':
            cell = cells.Bushy.create(
                model='RM03',
                species=args.species,
                modelType=args.type,
                morphology='cnmodel/morphology/bushy_stick.hoc',
                decorator=True,
                nach=args.nav,
                ttx=args.ttx,
                debug=debugFlag)
            h.topology()

        elif args.celltype == 'bushycoop' and args.morphology == 'point':
            cell = cells.Bushy.create(model='RM03',
                                      species=args.species,
                                      modelType=args.type,
                                      ttx=args.ttx,
                                      nach=args.nav,
                                      debug=debugFlag)

        #
        # T-stellate tests
        #
        elif args.celltype == 'tstellate' and args.morphology == 'point':
            cell = cells.TStellate.create(model='RM03',
                                          species=args.species,
                                          modelType=args.type,
                                          nach=args.nav,
                                          ttx=args.ttx,
                                          debug=debugFlag)

        elif args.celltype == 'tstellate' and args.morphology == 'stick':
            cell = cells.TStellate.create(
                model='RM03',
                species=args.species,
                modelType=args.type,
                nach=args.nav,
                ttx=args.ttx,
                debug=debugFlag,
                morphology='cnmodel/morphology/tstellate_stick.hoc',
                decorator=True)

        elif args.celltype == 'tstellatenav11' and args.morphology == 'point':  # note this uses a different model...
            print 'test_cells: Stellate NAV11'
            cell = cells.TStellateNav11.create(model='Nav11',
                                               species=args.species,
                                               modelType=None,
                                               ttx=args.ttx,
                                               debug=debugFlag)

        elif args.celltype == 'tstellatenav11' and args.morphology == 'stick':  # note this uses a different model...
            cell = cells.TStellateNav11.create(
                model='Nav11',
                species=args.species,
                modelType=None,
                morphology='cnmodel/morphology/tstellate_stick.hoc',
                decorator=True,
                ttx=args.ttx,
                debug=debugFlag,
            )
            h.topology()

        #
        # Octopus cell tests
        #
        elif args.celltype == 'octopus' and args.morphology == 'point':
            cell = cells.Octopus.create(
                species=args.species,
                modelType='RM03',  # args.type,
                nach=args.nav,
                ttx=args.ttx,
                debug=debugFlag)

        elif args.celltype == 'octopus' and args.morphology == 'stick':  # Go to spencer et al. model
            cell = cells.Octopus.create(
                modelType='Spencer',
                species=args.species,
                morphology='cnmodel/morphology/octopus_spencer_stick.hoc',
                decorator=True,
                nach=args.nav,
                ttx=args.ttx,
                debug=debugFlag)
            h.topology()

        #
        # D-stellate tests
        #
        elif args.celltype == 'dstellate':
            cell = cells.DStellate.create(debug=debugFlag,
                                          species=args.species,
                                          ttx=args.ttx,
                                          modelType=args.type)

        elif args.celltype == 'dstellateeager':
            cell = cells.DStellateEager.create(debug=debugFlag,
                                               ttx=args.ttx,
                                               modelType=args.type)

        #
        # DCN pyramidal cell tests
        #
        elif args.celltype == 'pyramidal':
            cell = cells.Pyramidal.create(modelType=args.type,
                                          ttx=args.ttx,
                                          debug=debugFlag)

        #
        # DCN tuberculoventral cell tests
        #
        elif args.celltype == 'tuberculoventral' and args.morphology == 'point':
            cell = cells.Tuberculoventral.create(species='mouse',
                                                 modelType='TVmouse',
                                                 ttx=args.ttx,
                                                 nach=args.nav,
                                                 debug=debugFlag)

        elif args.celltype == 'tuberculoventral' and args.morphology == 'stick':
            cell = cells.Tuberculoventral.create(
                species='mouse',
                modelType='TVmouse',
                morphology='cnmodel/morphology/tv_stick.hoc',
                decorator=True,
                ttx=args.ttx,
                debug=debugFlag)
            h.topology()

        #
        # DCN cartwheel cell tests
        #
        elif args.celltype == 'cartwheel':
            cell = cells.Cartwheel.create(modelType=args.type,
                                          ttx=args.ttx,
                                          debug=debugFlag)

        #
        # MSO principal neuron tests
        #
        elif args.celltype == 'mso' and args.morphology == 'point':
            cell = cells.MSO.create(model='RM03',
                                    species=args.species,
                                    modelType=args.type,
                                    ttx=args.ttx,
                                    nach=args.nav,
                                    debug=debugFlag)

        else:
            raise ValueError(
                "Cell Type %s and configurations nav=%s or config=%s are not available"
                % (args.celltype, args.nav, args.morphology))

        print(cell.__doc__)
        self.cell = cell

    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.")
示例#7
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