Esempio n. 1
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
Esempio n. 2
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.")