def runsim(): t0 = time.time() # clock start time pc.set_maxstep( 10) # sets the default max solver step in ms (purposefully large) for elec in lelec: elec.setup() elec.LFPinit() h.finitialize( ) # initialize cells to -65 mV, after all the NetCon delays have been specified if pcID == 0: for tt in range(0, int(h.tstop), printdt): h.cvode.event(tt, prsimtime) # print time callbacks h.fcurrent() h.frecord_init( ) # set state variables if they have been changed since h.finitialize pc.psolve(h.tstop) # actual simulation - run the solver pc.barrier() # these calls aggregate data across procs/nodes pc.allreduce(dp_rec_L2, 1) pc.allreduce( dp_rec_L5, 1) # combine dp_rec on every node, 1=add contributions together for elec in lelec: elec.lfp_final() net.aggregate_currents( ) # aggregate the currents independently on each proc # combine net.current{} variables on each proc pc.allreduce(net.current['L5Pyr_soma'], 1) pc.allreduce(net.current['L2Pyr_soma'], 1) pc.barrier() # write time and calculated dipole to data file only if on the first proc # only execute this statement on one proc savedat(p, pcID, t_vec, dp_rec_L2, dp_rec_L5, net) for elec in lelec: print('end; t_vec.size()', t_vec.size(), 'elec.lfp_t.size()', elec.lfp_t.size()) if pcID == 0: if debug: print("Simulation run time: %4.4f s" % (time.time() - t0)) if debug: print("Simulation directory is: %s" % ddir.dsim) if paramrw.find_param(doutf['file_param'], 'save_spec_data') or usingOngoingInputs( doutf['file_param']): runanalysis(p, doutf['file_param'], doutf['file_dpl_norm'], doutf['file_spec']) # run spectral analysis if paramrw.find_param(doutf['file_param'], 'save_figs'): savefigs(ddir, p, p_exp) # save output figures pc.barrier() # make sure all done in case multiple trials
def getInputs (self): """ get a dictionary of input types used in simulation with distal/proximal specificity for evoked,ongoing inputs """ dinty = {'Evoked':False,'Ongoing':False,'Poisson':False,'Tonic':False,'EvokedDist':False,\ 'EvokedProx':False,'OngoingDist':False,'OngoingProx':False} try: dinty['Evoked'] = usingEvokedInputs(dfile['outparam']) dinty['EvokedDist'] = usingEvokedInputs(dfile['outparam'], lsuffty = ['_evdist_']) dinty['EvokedProx'] = usingEvokedInputs(dfile['outparam'], lsuffty = ['_evprox_']) dinty['Ongoing'] = usingOngoingInputs(dfile['outparam']) dinty['OngoingDist'] = usingOngoingInputs(dfile['outparam'], lty = ['_dist']) dinty['OngoingProx'] = usingOngoingInputs(dfile['outparam'], lty = ['_prox']) dinty['Poisson'] = usingPoissonInputs(dfile['outparam']) dinty['Tonic'] = usingTonicInputs(dfile['outparam']) except: pass return dinty
dclr = {'L2_pyramidal' : 'g', 'L5_pyramidal' : 'r', 'L2_basket' : 'w', 'L5_basket' : 'b'} ntrial = 1; tstop = -1; outparamf = spkpath = paramf = ''; EvokedInputs = OngoingInputs = PoissonInputs = False; for i in range(len(sys.argv)): if sys.argv[i].endswith('.txt'): spkpath = sys.argv[i] elif sys.argv[i].endswith('.param'): paramf = sys.argv[i] tstop = paramrw.quickgetprm(paramf,'tstop',float) ntrial = paramrw.quickgetprm(paramf,'N_trials',int) EvokedInputs = paramrw.usingEvokedInputs(paramf) OngoingInputs = paramrw.usingOngoingInputs(paramf) PoissonInputs = paramrw.usingPoissonInputs(paramf) outparamf = os.path.join(dconf['datdir'],paramf.split('.param')[0].split(os.path.sep)[-1],'param.txt') try: extinputs = spikefn.ExtInputs(spkpath, outparamf) except ValueError: print("Error: could not load spike timings from %s" % spkpath) extinputs.add_delay_times() alldat = {} ncell = len(net.cells) binsz = 5.0