save_folder = os.path.join(
    save_folder, '{}_DistanceThr_{:.2f}'.format(trace_window, distance_thr))
if not os.path.isdir(save_folder):
    os.makedirs(save_folder)

nwb_fns = [f for f in os.listdir(nwb_folder) if f[-4:] == '.nwb']
nwb_fns.sort()

bc = dt.BoutonClassifier(skew_filter_sigma=skew_filter_sigma,
                         skew_thr=skew_thr,
                         lowpass_sigma=lowpass_sigma,
                         detrend_sigma=detrend_sigma,
                         event_std_thr=event_std_thr,
                         peri_event_dur=peri_event_dur,
                         corr_len_thr=corr_len_thr,
                         corr_abs_thr=corr_abs_thr,
                         corr_std_thr=corr_std_thr,
                         is_cosine_similarity=is_cosine_similarity,
                         distance_metric=distance_metric,
                         linkage_method=linkage_method,
                         distance_thr=distance_thr)

for nwb_fi, nwb_fn in enumerate(nwb_fns):

    print('processing {}, {}/{}'.format(nwb_fn, nwb_fi + 1, len(nwb_fns)))

    nwb_f = h5py.File(os.path.join(nwb_folder, nwb_fn), 'r')

    plane_ns = dt.get_plane_ns(nwb_f=nwb_f)
    plane_ns.sort()
Exemplo n.º 2
0
import os
import h5py
import corticalmapping.DatabaseTools as dt

nwb_folder = "nwbs"
clu_folder = r"intermediate_results\bouton_clustering\AllStimuli_DistanceThr_1.30"
strf_t_win = [-0.5, 2.]

curr_folder = os.path.dirname(os.path.realpath(__file__))
os.chdir(curr_folder)

clu_fns = [f for f in os.listdir(clu_folder) if f[-5:] == '.hdf5']
clu_fns.sort()
print('total number of planes: {}'.format(len(clu_fns)))

for clu_fi, clu_fn in enumerate(clu_fns):

    date, mid, plane_n, _, _ = clu_fn.split('_')

    print('processing {}_{}_{}, {} / {}'.format(date, mid, plane_n, clu_fi + 1, len(clu_fns)))

    nwb_fn = '{}_{}_110_repacked.nwb'.format(date, mid)
    nwb_f = h5py.File(os.path.join(nwb_folder, nwb_fn), 'r')

    clu_f = h5py.File(os.path.join(clu_folder, clu_fn))

    bc = dt.BoutonClassifier()
    bc.add_axon_strf(nwb_f=nwb_f, clu_f=clu_f, plane_n=plane_n, t_win=strf_t_win, verbose=False)

    nwb_f.close()
    clu_f.close()