예제 #1
0
def savedat(p, rank, t_vec, dp_rec_L2, dp_rec_L5, net):
    global doutf
    # write time and calculated dipole to data file only if on the first proc
    # only execute this statement on one proc
    if rank == 0:
        # write params to the file
        paramrw.write(doutf['file_param'], p, net.gid_dict)
        # write the raw dipole
        with open(doutf['file_dpl'], 'w') as f:
            for k in range(int(t_vec.size())):
                f.write("%03.3f\t" % t_vec.x[k])
                f.write("%5.4f\t" % (dp_rec_L2.x[k] + dp_rec_L5.x[k]))
                f.write("%5.4f\t" % dp_rec_L2.x[k])
                f.write("%5.4f\n" % dp_rec_L5.x[k])
        # renormalize the dipole and save
        dpl = Dipole(
            doutf['file_dpl'])  # fix to allow init from data rather than file
        dpl.baseline_renormalize(doutf['file_param'])
        dpl.convert_fAm_to_nAm()
        dconf['dipole_scalefctr'] = dpl.scale(
            paramrw.find_param(doutf['file_param'], 'dipole_scalefctr'))
        dpl.smooth(
            paramrw.find_param(doutf['file_param'], 'dipole_smooth_win') /
            h.dt)
        dpl.write(doutf['file_dpl_norm'])
        # write the somatic current to the file
        # for now does not write the total but just L2 somatic and L5 somatic
        with open(doutf['file_current'], 'w') as fc:
            for t, i_L2, i_L5 in zip(t_vec.x, net.current['L2Pyr_soma'].x,
                                     net.current['L5Pyr_soma'].x):
                fc.write("%03.3f\t" % t)
                # fc.write("%5.4f\t" % (i_L2 + i_L5))
                fc.write("%5.4f\t" % i_L2)
                fc.write("%5.4f\n" % i_L5)
    # write output spikes
    file_spikes_tmp = fio.file_spike_tmp(dproj)
    spikes_write(net, file_spikes_tmp)
    # move the spike file to the spike dir
    if rank == 0: shutil.move(file_spikes_tmp, doutf['file_spikes'])
    if p['save_vsoma']: save_volt()
    if p['save_cai']: save_cai()
    if p['save_ica']: save_ica()
    for i, elec in enumerate(lelec):
        elec.lfpout(fn=doutf['file_lfp'].split('.txt')[0] + '_' + str(i) +
                    '.txt',
                    tvec=t_vec)
예제 #2
0
simparams = p = p_exp.return_pdict(
    expmt_group, 0)  # return the param dict for this simulation

pc.barrier()  # get all nodes to this place before continuing
pc.gid_clear()

# global variables, should be node-independent
h("dp_total_L2 = 0.")
h("dp_total_L5 = 0.")

# Set tstop before instantiating any classes
h.tstop = p['tstop']
h.dt = p['dt']  # simulation duration and time-step
h.celsius = p['celsius']  # 37.0 # p['celsius'] # set temperature
# spike file needs to be known by all nodes
file_spikes_tmp = fio.file_spike_tmp(dproj)
net = network.NetworkOnNode(p)  # create node-specific network

t_vec = h.Vector()
t_vec.record(h._ref_t)  # time recording
dp_rec_L2 = h.Vector()
dp_rec_L2.record(h._ref_dp_total_L2)  # L2 dipole recording
dp_rec_L5 = h.Vector()
dp_rec_L5.record(h._ref_dp_total_L5)  # L5 dipole recording

net.movecellstopos()  # position cells in 2D grid


def expandbbox(boxA, boxB):
    return [(min(boxA[i][0], boxB[i][0]), max(boxA[i][1], boxB[i][1]))
            for i in range(3)]