Esempio n. 1
0
        maxthr=global_params['max_thr'],
        extract_cc=True,
        se=None,
        ss=None,
        dview=dview)
    A_thr_bin = A_thr > 0
    size_neurons = A_thr_bin.sum(0)
    idx_size_neurons = np.where((size_neurons > min_size_neuro)
                                & (size_neurons < max_size_neuro))[0]
    #A_thr = A_thr[:,idx_size_neuro]
    print(A_thr.shape)
    #%%
    duplicates_gt, indeces_keep_gt, indeces_remove_gt, D_gt, overlap_gt = detect_duplicates_and_subsets(
        A_gt_thr_bin[:, idx_size_neurons_gt].reshape(
            [dims[0], dims[1], -1], order='F').transpose([2, 0, 1]) * 1.,
        predictions=None,
        r_values=None,
        dist_thr=0.1,
        min_dist=10,
        thresh_subset=0.6)

    idx_components_gt = idx_size_neurons_gt.copy()

    if len(duplicates_gt) > 0:
        if plot_on:
            pl.figure()
            pl.subplot(1, 3, 1)
            pl.imshow(A_gt_thr_bin[:, idx_size_neurons_gt].reshape(
                [dims[0], dims[1], -1], order='F').transpose(
                    [2, 0, 1])[np.array(duplicates_gt).flatten()].sum(0))
            pl.colorbar()
            pl.subplot(1, 3, 2)
    A_gt_thr_bin = A_gt_thr > 0
    size_neurons_gt = A_gt_thr_bin.sum(0)
    idx_size_neurons_gt = np.where((size_neurons_gt>min_size_neuro) & (size_neurons_gt < max_size_neuro) )[0]
    print(A_gt_thr.shape)
    #%% filter for size found neurons
    A_thr = cm.source_extraction.cnmf.spatial.threshold_components(A.tocsc()[:,:].toarray(), dims, medw=None, thr_method='max', maxthr=global_params['max_thr'], extract_cc=True,
                             se=None, ss=None, dview=dview)
    A_thr_bin = A_thr > 0
    size_neurons = A_thr_bin.sum(0)
    idx_size_neurons = np.where((size_neurons>min_size_neuro) & (size_neurons<max_size_neuro))[0]
    #A_thr = A_thr[:,idx_size_neuro]
    print(A_thr.shape)
    #%%
    duplicates_gt, indeces_keep_gt, indeces_remove_gt, D_gt, overlap_gt = detect_duplicates_and_subsets(
            A_gt_thr_bin[:,idx_size_neurons_gt].reshape([dims[0],dims[1],-1],order = 'F').transpose([2,0,1])*1.,
            predictions = None, r_values = None,
            dist_thr=0.1, min_dist = 10,thresh_subset = 0.6)

    idx_components_gt = idx_size_neurons_gt.copy()

    if len(duplicates_gt) > 0:
        if plot_on:
            pl.figure()
            pl.subplot(1,3,1)
            pl.imshow(A_gt_thr_bin[:,idx_size_neurons_gt].reshape([dims[0],dims[1],-1],order = 'F').transpose([2,0,1])[np.array(duplicates_gt).flatten()].sum(0))
            pl.colorbar()
            pl.subplot(1,3,2)
            pl.imshow(A_gt_thr_bin[:,idx_size_neurons_gt].reshape([dims[0],dims[1],-1],order = 'F').transpose([2,0,1])[np.array(indeces_keep_gt)[:]].sum(0))
            pl.colorbar()
            pl.subplot(1,3,3)
            pl.imshow(A_gt_thr_bin[:,idx_size_neurons_gt].reshape([dims[0],dims[1],-1],order = 'F').transpose([2,0,1])[np.array(indeces_remove_gt)[:]].sum(0))