Exemple #1
0
def pick_stable_features(R, shape, nboot=500, connectivity=None):
    # generate the boots
    boots = [
        np.random.random_integers(0,
                                  len(R) - 1, len(R)) for i in xrange(nboot)
    ]

    # run tfce on each subj and cond
    if True:
        Rt = np.zeros([R.shape[0], R.shape[1]] + list(shape))
        for i in range(Rt.shape[0]):
            for j in range(Rt.shape[1]):
                Rt[i, j] = cluster.tfce(np.arctanh(R[i, j]).reshape(*shape),
                                        dt=.05,
                                        tail=1,
                                        connectivity=connectivity,
                                        E=1.0,
                                        H=2.0)
                Rt[i, j] += cluster.tfce(np.arctanh(R[i, j]).reshape(*shape),
                                         dt=.05,
                                         tail=-1,
                                         connectivity=connectivity,
                                         E=1.0,
                                         H=2.0)
    else:
        # convert to Z
        Rt = np.arctanh(R)

    # calc bootstrap ratio
    Rtb = np.array([Rt[boots[b]].mean(0) for b in range(len(boots))])
    Rtbr = Rt.mean(0) / Rtb.std(0)
    return Rtbr
Exemple #2
0
def R_to_tfce(R, connectivity=None, shape=None, dt=.01, E=2 / 3., H=2.0):
    """Apply TFCE to the R values."""
    # allocate for tfce
    Rt = np.zeros_like(R)
    # Z = np.arctanh(R)
    Z = R
    # loop
    for i in range(Rt.shape[0]):
        for j in range(Rt.shape[1]):
            # apply tfce in pos and neg direction
            Zin = Z[i, j]
            if connectivity is None:
                # reshape back
                Zin = Zin.reshape(*shape)
            Rt[i, j] += cluster.tfce(Zin,
                                     dt=dt,
                                     tail=1,
                                     connectivity=connectivity,
                                     E=E,
                                     H=H).flatten()
            Rt[i, j] += cluster.tfce(Zin,
                                     dt=dt,
                                     tail=-1,
                                     connectivity=connectivity,
                                     E=E,
                                     H=H).flatten()
    return Rt
Exemple #3
0
Fichier : meld.py Projet : ctw/ptsa
def R_to_tfce(R, connectivity=None, shape=None, 
              dt=.01, E=2/3., H=2.0):
    """Apply TFCE to the R values."""
    # allocate for tfce
    Rt = np.zeros_like(R)
    Z = np.arctanh(R)
    # loop
    for i in range(Rt.shape[0]):
        for j in range(Rt.shape[1]):
            # apply tfce in pos and neg direction
            Rt[i,j] += cluster.tfce(Z[i,j].reshape(*shape),
                                   dt=dt,tail=1,connectivity=connectivity, 
                                   E=E,H=H).flatten()
            Rt[i,j] += cluster.tfce(Z[i,j].reshape(*shape),
                                    dt=dt,tail=-1,connectivity=connectivity, 
                                    E=E,H=H).flatten()
    return Rt
Exemple #4
0
def R_to_tfce(R, connectivity=None, shape=None, 
              dt=.01, E=2/3., H=2.0):
    """Apply TFCE to the R values."""
    # allocate for tfce
    #Rt = np.zeros([R.shape[0],R.shape[1]]+list(shape))
    #Rt = np.zeros_like(R)
    #Rt = R.copy()
    Rt = np.arctanh(R)
    # loop
    for i in range(Rt.shape[0]):
        for j in range(Rt.shape[1]):
            Rt[i,j] = cluster.tfce(Rt[i,j].reshape(*shape),
                                   dt=dt,tail=1,connectivity=connectivity, 
                                   E=E,H=H).flatten()
            Rt[i,j] += cluster.tfce(Rt[i,j].reshape(*shape),
                                    dt=dt,tail=-1,connectivity=connectivity, 
                                    E=E,H=H).flatten()
    return Rt
Exemple #5
0
def R_to_tfce(R, connectivity=None, shape=None, dt=.01, E=2 / 3., H=2.0):
    """Apply TFCE to the R values."""
    # allocate for tfce
    #Rt = np.zeros([R.shape[0],R.shape[1]]+list(shape))
    #Rt = np.zeros_like(R)
    #Rt = R.copy()
    Rt = np.arctanh(R)
    # loop
    for i in range(Rt.shape[0]):
        for j in range(Rt.shape[1]):
            Rt[i, j] = cluster.tfce(Rt[i, j].reshape(*shape),
                                    dt=dt,
                                    tail=1,
                                    connectivity=connectivity,
                                    E=E,
                                    H=H).flatten()
            Rt[i, j] += cluster.tfce(Rt[i, j].reshape(*shape),
                                     dt=dt,
                                     tail=-1,
                                     connectivity=connectivity,
                                     E=E,
                                     H=H).flatten()
    return Rt
Exemple #6
0
def pick_stable_features(R, shape, nboot=500, connectivity=None):
    # generate the boots
    boots = [np.random.random_integers(0,len(R)-1,len(R))
             for i in xrange(nboot)]

    # run tfce on each subj and cond
    if True:
        Rt = np.zeros([R.shape[0],R.shape[1]]+list(shape))
        for i in range(Rt.shape[0]):
            for j in range(Rt.shape[1]):
                Rt[i,j] = cluster.tfce(np.arctanh(R[i,j]).reshape(*shape),
                                       dt=.05,tail=1,connectivity=connectivity, 
                                       E=1.0,H=2.0)
                Rt[i,j] += cluster.tfce(np.arctanh(R[i,j]).reshape(*shape),
                                        dt=.05,tail=-1,connectivity=connectivity, 
                                        E=1.0,H=2.0)
    else:
        # convert to Z
        Rt = np.arctanh(R)

    # calc bootstrap ratio
    Rtb = np.array([Rt[boots[b]].mean(0) for b in range(len(boots))])
    Rtbr = Rt.mean(0)/Rtb.std(0)
    return Rtbr