コード例 #1
0
ファイル: test_repro.py プロジェクト: Garyfallidis/nipy
def apply_repro_analysis_analysis(dataset, thresholds=[3.0], method = 'crfx'):
    """
    perform the reproducibility  analysis according to the 
    """
    from nipy.io.imageformats import Nifti1Image 

    nsubj, dimx, dimy = dataset.shape
    
    func = np.reshape(dataset,(nsubj, dimx*dimy)).T
    var = np.ones((dimx*dimy, nsubj))
    #xyz = np.reshape(np.indices((dimx, dimy,1)).T,(dimx*dimy,3))
    #coord = xyz.astype(np.float)
    mask = Nifti1Image(np.ones((dimx, dimy, 1)),np.eye(4))
    
    ngroups = 10
    sigma = 2.0
    csize = 10
    niter = 10
    verbose = 0
    swap = False

    kap = []
    clt = []
    for threshold in thresholds:
        kappa = []
        cls = []
        kwargs={'threshold':threshold,'csize':csize}        
        for i in range(niter):
            k = voxel_reproducibility(func, var, mask, ngroups,
                                  method, swap, verbose, **kwargs)
            kappa.append(k)
            cld = cluster_reproducibility(func, var, mask, ngroups, sigma,
                                      method, swap, verbose, **kwargs)
            cls.append(cld)
        
        kap.append(np.array(kappa))
        clt.append(np.array(cls))
    kap = np.array(kap)
    clt = np.array(clt)
    return kap,clt
コード例 #2
0
# do not use permutations
swap = False

 
kap = []
clt = []
pk = []
sens = []
for threshold in thresholds:
    kwargs={'threshold':threshold,'csize':csize}
    kappa = []
    cls = []
    sent = []
    peaks = []
    for i in range(niter):
        k = voxel_reproducibility(func, var, mask, ngroups,
                                  method, swap, verbose, **kwargs)
        kappa.append(k)
        cld = cluster_reproducibility(func, var, mask, ngroups, sigma,
                                      method, swap, verbose, **kwargs)
        cls.append(cld)
        peak = peak_reproducibility(func, var, mask, ngroups, sigma,
                                      method, swap, verbose, **kwargs)
        peaks.append(peak)
        seni = map_reproducibility(func, var, mask, ngroups,
                           method, True, verbose, threshold=threshold,
                           csize=csize).mean()/ngroups
        sent.append(seni)
    sens.append(np.array(sent))
    kap.append(np.array(kappa))
    clt.append(np.array(cls))
    pk.append(np.array(peaks))
コード例 #3
0
method = "crfx"
verbose = 0

# apply random sign swaps to the data to test the reproducibility
# under the H0 hypothesis
swap = False

kap = []
clt = []
for threshold in thresholds:
    kappa = []
    cls = []
    kwargs = {"threshold": threshold, "csize": csize}

    for i in range(niter):
        k = voxel_reproducibility(Functional, VarFunctional, xyz, ngroups, method, swap, verbose, **kwargs)
        kappa.append(k)
        cld = cluster_reproducibility(
            Functional, VarFunctional, xyz, ngroups, coord, sigma, method, swap, verbose, **kwargs
        )
        cls.append(cld)

    kap.append(np.array(kappa))
    clt.append(np.array(cls))

import matplotlib.pylab as mp

mp.figure()
mp.subplot(1, 2, 1)
mp.boxplot(kap)
mp.title("voxel-level reproducibility")