Ejemplo n.º 1
0
def run_recs_fifos(pardir, outdir, ttime, recnames, fifonames, fifo_trange):
    stimpar = jspar.load(os.path.join(pardir, 'stimpar.json'))
    cellpar = jspar.load(os.path.join(pardir, 'cellpar.json'))
    spkthr = jspar.load(os.path.join(pardir, 'spkthr.json'))

    if not os.path.exists(outdir):
        os.makedirs(outdir)

    simfunc = run.cellpar_wrapper(run.simulation, cellpar, spkthr)
    spkt, stimvec, recs, fifos = simfunc(ttime,
                                         'OU',
                                         stimpar,
                                         None,
                                         retstim=True,
                                         recnames=recnames,
                                         fifonames=fifonames,
                                         fifo_trange=fifo_trange)

    with open(os.path.join(outdir, 'fifos.p'), 'w') as f:
        pickle.dump(fifos, f)
    with open(os.path.join(outdir, 'recs.p'), 'w') as f:
        pickle.dump(recs, f)
    runpar = dict(hpar=run.hpar,
                  ttime=ttime,
                  stimpar=stimpar,
                  cellpar=cellpar,
                  spkthr=spkthr,
                  fifo_trange=fifo_trange)
    rpfile = os.path.join(outdir, 'runpar.json')
    jspar.save(rpfile, runpar)
Ejemplo n.º 2
0
def run_contours(outdir_base,
                 cellpar,
                 spkthr,
                 bracket,
                 statname,
                 targ_list,
                 fxvec,
                 xname,
                 tau,
                 ttime,
                 fvsplit=None):
    spkthrfile = os.path.join(outdir_base, 'spkthr.json')
    jspar.save(spkthrfile, spkthr)
    cpfile = os.path.join(outdir_base, 'cellpar.json')
    jspar.save(cpfile, cellpar)

    for targ in targ_list:
        outdir = os.path.join(outdir_base, targ_lab(statname,
                                                    targ,
                                                    dirlab=True))
        if not os.path.exists(outdir):
            os.mkdir(outdir)

        if fvsplit:
            spfxvec = np.split(fxvec, fvsplit)
            for i, fxv in enumerate(spfxvec):
                subdir = os.path.join(outdir, '%.2d' % i)
                if not os.path.exists(subdir):
                    os.mkdir(subdir)
                run_contour(fxv, bracket, xname, tau, statname, targ, ttime,
                            cpfile, spkthr, subdir)
        else:
            jobname = 'ctg{:.0f}t{:.0f}'.format(cellpar['gkbar'] * 1e3, targ)
            run_contour(fxvec, bracket, xname, tau, statname, targ, ttime,
                        cpfile, spkthr, outdir, jobname)
Ejemplo n.º 3
0
def run_fifos(ttime, pardir, outdir):
    stimpar = jspar.load(os.path.join(pardir, 'stimpar.json'))
    cellpar = jspar.load(os.path.join(pardir, 'cellpar.json'))
    spkthr = jspar.load(os.path.join(pardir, 'spkthr.json'))

    if not os.path.exists(outdir):
        os.makedirs(outdir)

    simfunc = run.cellpar_wrapper(run.simulation, cellpar, spkthr)

    fifonames = ('time', 'v_ais', 'icap_ais', 'nav_m')
    fifo_trange = (-40, 0)

    spkt, fifos = simfunc(ttime,
                          'OU',
                          stimpar,
                          None,
                          fifonames=fifonames,
                          fifo_trange=fifo_trange)
    pff.save_fifos(fifos, outdir)
    runpar = dict(hpar=run.hpar,
                  ttime=ttime,
                  stimpar=stimpar,
                  cellpar=cellpar,
                  spkthr=spkthr,
                  fifo_trange=fifo_trange)
    rpfile = os.path.join(outdir, 'runpar.json')
    jspar.save(rpfile, runpar)
Ejemplo n.º 4
0
def run_optstimpar(outdir, cellpar, spkthr, x0, *optmargs):
    spkthrfile = os.path.join(outdir, 'spkthr.json')
    jspar.save(spkthrfile, spkthr)
    cpfile = os.path.join(outdir, 'cellpar.json')
    jspar.save(cpfile, cellpar)

    args = [outdir, cpfile, spkthr, x0[0], x0[1]]
    args.extend(optmargs)
    submit_to_cluster('optstm', '../../run/run_optstimpar.py', args)
Ejemplo n.º 5
0
def run_ficurve(curtvec, cellpar, outdir, noise=0, tau=0):
    cpfile = os.path.join(outdir, 'cellpar.json')
    jspar.save(cpfile, cellpar)

    ctvfile = os.path.join(outdir, 'curtvec.npy')
    np.save(ctvfile, curtvec)

    args = [ctvfile, cpfile, spkthr, outdir, '--noise', noise, '--tau', tau]
    submit_to_cluster('ficurve', '../../run/run_ficurve.py', args)
Ejemplo n.º 6
0
def run_optstimpar(qname, outdir, cellpar, spkthr, x0, *optmargs):
    spkthrfile = os.path.join(outdir, 'spkthr.json')
    jspar.save(spkthrfile, spkthr)
    cpfile = os.path.join(outdir, 'cellpar.json')
    jspar.save(cpfile, cellpar)

    args = [outdir, cpfile, spkthr, x0[0], x0[1]]
    args.extend(optmargs)
    scpath = os.path.join(rjpath, 'run_optstimpar.py')
    submit_to_cluster(qname, 'optstm', scpath, args)
Ejemplo n.º 7
0
def run_ficurve(qname, curtvec, cellpar, spkthr, outdir, noise=0, tau=0):
    cpfile = os.path.join(outdir, 'cellpar.json')
    jspar.save(cpfile, cellpar)

    ctvfile = os.path.join(outdir, 'curtvec.npy')
    np.save(ctvfile, curtvec)

    args = [ctvfile, cpfile, spkthr, outdir, '--noise', noise, '--tau', tau]
    scpath = os.path.join(rjpath, 'run_ficurve.py')
    submit_to_cluster(qname, 'ficurve', scpath, args)
Ejemplo n.º 8
0
    moddir = '.'
run = imp.load_source('run', os.path.join(moddir, 'run.py'))

stimpar = jspar.load(args.spfile)
cellpar = jspar.load(args.cpfile)
outdir = args.outdir

if not os.path.exists(outdir):
    raise OSError('No such directory: {}'.format(outdir))

spktimes, stimvec = run.simulation(cellpar,
                                   args.spkthr,
                                   args.ttime,
                                   args.stimtyp,
                                   stimpar,
                                   retstim=True)

runpar = dict(hpar=run.hpar,
              ttime=args.ttime,
              stimpar=stimpar,
              cellpar=cellpar,
              spkthr=args.spkthr)
rpfile = os.path.join(outdir, 'runpar.json')
jspar.save(rpfile, runpar)

with open(os.path.join(outdir, 'stimvec.npy'), 'w') as f:
    np.save(f, stimvec)

with open(os.path.join(outdir, 'spktimes.npy'), 'w') as f:
    np.save(f, spktimes)
Ejemplo n.º 9
0
parser.add_argument('spkthr',
                    type=float,
                    help='voltage thresh for spike detection')
parser.add_argument('outdir', help='output directory')
parser.add_argument('--moddir', help='path for model definition')
parser.add_argument(
    '--noise',
    type=float,
    help='0: no noise, non-0: standard deviation of OU process')
parser.add_argument('--tau', type=float, help='tau for OU process')
args = parser.parse_args()

if args.moddir:
    moddir = args.moddir
else:
    moddir = '.'
run = imp.load_source('run', os.path.join(moddir, 'run.py'))

curtvec = np.load(args.ctvfile)
cellpar = jspar.load(args.cpfile)
outdir = args.outdir

if not os.path.exists(outdir):
    raise Exception('No such directory: %s' % outdir)

simfunc = run.cellpar_wrapper(run.simulation, cellpar, args.spkthr)
frtvec = ficurve.get_frtvec(simfunc, curtvec, noise=args.noise, tau=args.tau)
np.save(os.path.join(outdir, 'frtvec.npy'), frtvec)

jspar.save(os.path.join(outdir, 'fipar.json'), vars(args))
Ejemplo n.º 10
0
                    type=float,
                    help='total simulation time for one evaluation')

parser.add_argument('frttarg', type=float, help='target firing rate')
parser.add_argument('cvtarg', type=float, help='target cv')
parser.add_argument('--moddir', help='path for model definition')

args = parser.parse_args()

if args.moddir:
    moddir = args.moddir
else:
    moddir = '.'
run = imp.load_source('run', os.path.join(moddir, 'run.py'))

outdir = args.outdir
if not os.path.exists(outdir):
    raise Exception('No such output directory: %s' % outdir)
cellpar = jspar.load(args.cpfile)
x0 = (args.mean0, args.std0)

logfile = os.path.join(outdir, 'optstimpar.log')
logging.basicConfig(filename=logfile, level=logging.INFO)

simfunc = run.cellpar_wrapper(run.simulation, cellpar, args.spkthr)
ostimpar, res = optstimpar.optstimpar(simfunc, x0, args.tau, args.ttime,
                                      args.frttarg, args.cvtarg)

spfile = os.path.join(outdir, 'stimpar.json')
jspar.save(spfile, ostimpar)
Ejemplo n.º 11
0
parser.add_argument('statname', help='spike statistic variable for contour')
parser.add_argument('targ', type=float, help='value of statistic variable for contour')
parser.add_argument('ttime', type=float, help='total simulation time')
parser.add_argument('--rseed', type=int, default=3,  help='random number seed for OU')
parser.add_argument('--moddir', help='path for model definition')
args = parser.parse_args()

if args.moddir:
    moddir = args.moddir
else:
    moddir = '.'
run = imp.load_source('run', os.path.join(moddir, 'run.py'))

outdir = args.outdir
if not os.path.exists(outdir):
    raise OSError('No such output directory: %s' % outdir)
cellpar = jspar.load(args.cpfile)
fxvec = np.load(args.fxvfile)

logfile = os.path.join(outdir, 'contour.log')
logging.basicConfig(filename=logfile, level=logging.INFO)

simfunc = run.cellpar_wrapper(run.simulation, cellpar, args.spkthr)
targfunc = contour.targfunc_wrapper(simfunc, args.xname, args.tau, args.statname, args.targ, args.ttime, rseed=args.rseed)
xvec = contour.get_contour(targfunc, fxvec, args.bracket)

logging.info(str(xvec))
np.save(os.path.join(args.outdir, 'xvec.npy'), xvec)

jspar.save(os.path.join(args.outdir, 'ctpar.json'), vars(args))