예제 #1
0
def read_in_data(ddir):
    seglen = np.loadtxt(os.path.join(ddir, 'seglength'))
    n_seg = len(seglen)
    ground_truth = np.loadtxt(os.path.join(ddir, 'membcurr'))
    time = np.loadtxt(os.path.join(ddir, 'tvec.txt'))
    somav = np.loadtxt(os.path.join(ddir, 'somav.txt'))
    ground_truth = ground_truth/seglen[:, None]*1e-3
    Data = utils.LoadData(ddir)
    Data.ele_pos = Data.ele_pos/scaling_factor
    Data.LFP = Data.LFP/scaling_factor_LFP
    Data.morphology[:, 2:6] = Data.morphology[:, 2:6]/scaling_factor
    
    return ground_truth, Data, time, somav
예제 #2
0
def load_data(data_dir):
    """
    Load sKCSD estimation data and measured LFPs

    pots are the measured LFPs

    Parameters
    ----------
    data_dir : str

    Returns
    -------
    pots : np.array
    est_csd : np.array
    est_pot : np.array
    cell_obj : sKCSDcell object
    """
    try:
        data = sKCSD_utils.LoadData(data_dir)
    except KeyError:
        print('Could not load %s LFP from' % data_dir)
        data = None
    if data:
        pots = data.LFP
    else:
        pots = None

    try:
        est_csd, est_pot, morphology, ele_pos, n_src = sKCSD_utils.load_sim(
            data_dir)
        cell_object = kcsd.sKCSDcell(morphology, ele_pos, n_src)
    except IOError:
        if sys.version_info < (3, 0):
            path = os.path.join(data_dir, "preprocessed_data/Python_2")
        else:
            path = os.path.join(data_dir, "preprocessed_data/Python_3")

        est_csd, est_pot, morphology, ele_pos, n_src = sKCSD_utils.load_sim(
            path)
        cell_object = kcsd.sKCSDcell(morphology, ele_pos, n_src)

    return (pots, est_csd, est_pot, cell_obj)
예제 #3
0
                                 weight=0.01,
                                 n_syn=1000,
                                 simulate_what='oscillatory',
                                 electrode_distribution=1,
                                 electrode_orientation=3,
                                 xmin=xmin,
                                 xmax=xmax,
                                 ymin=ymin,
                                 ymax=ymax,
                                 colnb=colnb,
                                 rownb=rownb,
                                 dt=dt)
        c.save_for_R_kernel()
        data_dir.append(c.return_paths_skCSD_python())

    data = utils.LoadData(data_dir[0])
    ele_pos = data.ele_pos / scale_factor
    data.LFP = data.LFP / scale_factor_LFP
    morphology = data.morphology
    morphology[:, 2:6] = morphology[:, 2:6] / scale_factor
    seglen = np.loadtxt(os.path.join(data_dir[0], 'seglength'))
    ground_truth = np.loadtxt(os.path.join(
        data_dir[0], 'membcurr')) / seglen[:, None] * 1e-3
    somav = np.loadtxt(os.path.join(data_dir[0], 'somav.txt'))
    time = np.linspace(0, tstop, len(somav))
    plt.figure()
    plt.plot(time, somav)

    dt = c.cell_parameters['dt']
    t0 = int(247.5 / dt)  #np.argmax(somav)
    print(t0 * dt)
예제 #4
0
                             electrode_distribution=1,
                             dt=dt)

    data_dir = c.return_paths_skCSD_python()

    seglen = np.loadtxt(os.path.join(data_dir, 'seglength'))

    ground_truth = np.loadtxt(os.path.join(data_dir, 'membcurr'))

    ground_truth = ground_truth / seglen[:, None] * 1e-3

    fig, ax = plt.subplots(2, 3, figsize=(8, 20))
    fname = "Figure_9.png"
    fig_name = sKCSD_utils.make_fig_names(fname)

    data = utils.LoadData(data_dir)
    ele_pos = data.ele_pos / scaling_factor
    data.LFP = data.LFP / scaling_factor_LFP
    morphology = data.morphology
    morphology[:, 2:6] = morphology[:, 2:6] / scaling_factor
    std = data.LFP.var()**.5
    shape = data.LFP.shape
    cell = sKCSDcell(morphology,
                     ele_pos,
                     n_src,
                     tolerance=2e-6,
                     xmin=-120e-6,
                     xmax=120e-6,
                     zmin=-50e-6,
                     zmax=550e-6)
    ground_truth_grid = cell.transform_to_3D(ground_truth, what="morpho")
예제 #5
0
    cax = ax_gt.imshow(ground_truth,
                       extent=[0, tstop, 1, ground_truth.shape[0]],
                       origin='lower',
                       aspect='auto',
                       cmap='seismic_r',
                       vmax=gvmax,
                       vmin=gvmin)
    ax_gt.set_title('Ground truth')
    ax_gt.set_xlabel('time (s)')
    ax_gt.set_ylabel('#segment')
    new_fname = fname_base + '.png'
    fig_name = sKCSD_utils.make_fig_names(new_fname)
    for i, datd in enumerate(data_dir):
        print(datd)
        data = utils.LoadData(datd)
        ele_pos = data.ele_pos / scaling_factor
        data.LFP = data.LFP / scaling_factor_LFP
        morphology = data.morphology
        morphology[:, 2:6] = morphology[:, 2:6] / scaling_factor
        k = sKCSD(ele_pos,
                  data.LFP,
                  morphology,
                  n_src_init=n_src,
                  src_type='gauss',
                  lambd=lambd,
                  dist_table_density=50,
                  R_init=R)
        csd = k.values(transformation='segments')
        print(csd.shape)
        print(csd.max(), csd.min())
예제 #6
0
                          morphology=2,
                          colnb=rownb[i],
                          rownb=colnb[i],
                          xmin=-100,
                          xmax=xmax[i],
                          ymin=-100,
                          ymax=ymax[i],
                          tstop=tstop,
                          seed=1988,
                          weight=0.01,
                          n_syn=100,
                          simulate_what="symmetric",
                          electrode_orientation=electrode_orientation,
                          dt=dt)
 data_dir.append(c.return_paths_skCSD_python())
 data = utils.LoadData(data_dir[i])
 ele_pos = data.ele_pos/scaling_factor
 morphology = data.morphology
 morphology[:, 2:6] = morphology[:, 2:6]/scaling_factor
 if i == 0:
     cell_itself.append(sKCSDcell(morphology,
                                  ele_pos,
                                  n_src,
                                  xmin=-120e-6,
                                  xmax=120e-6,
                                  ymin=-200e-6,
                                  ymax=200e-6,
                                  zmin=-150e-6,
                                  zmax=550e-6))
 else:
     cell_itself.append(sKCSDcell(morphology,
예제 #7
0
                             morphology=2,
                             colnb=colnb,
                             rownb=rownb,
                             xmin=0,
                             xmax=500,
                             ymin=-100,
                             ymax=100,
                             tstop=tstop,
                             seed=1988,
                             weight=0.04,
                             n_syn=100,
                             electrode_orientation=2,
                             simulate_what='symmetric',
                             dt=dt)
    new_path = c.return_paths_skCSD_python()
    data = utils.LoadData(new_path)
    ele_pos = data.ele_pos / scale_factor
    pots = data.LFP / scale_factor_LFP
    morphology = data.morphology
    morphology[:, 2:6] = morphology[:, 2:6] / scale_factor

    ground_truth = np.loadtxt(os.path.join(new_path, 'membcurr'))
    seglen = np.loadtxt(os.path.join(new_path, 'seglength'))
    ground_truth = ground_truth / seglen[:, None] * 1e-3
    outs = np.zeros((len(n_srcs), len(lambdas), len(R_inits)))
    for i, n_src in enumerate(n_srcs):
        for j, l in enumerate(lambdas):
            for k, R in enumerate(R_inits):
                lambd = l / (16 * np.pi**3 * R**2 * n_src)
                ker = sKCSD(ele_pos,
                            pots,