X = np.load(os.path.join(INPUT, "X.npy")) y = np.load(os.path.join(INPUT, "y.npy")) Z = X[:, :3] Y = X[:, 3:] assert np.sum(mask_arr) == Y.shape[1] DesignMat = np.zeros((Z.shape[0], Z.shape[1] + 1)) # y, intercept, age, sex DesignMat[:, 0] = (y.ravel() - y.ravel().mean()) # y DesignMat[:, 1] = 1 # intercept DesignMat[:, 2] = Z[:, 1] # age DesignMat[:, 3] = Z[:, 2] # sex muols = MUOLS(Y=Y, X=DesignMat) muols.fit() tvals, pvals, dfs = muols.t_test(contrasts=[1, 0, 0, 0], pval=True) np.savez(os.path.join(OUTPUT, "pvals", "pvals.npz"), pvals[0]) np.savez(os.path.join(OUTPUT, "tvals", "tvals.npz"), tvals[0]) np.savez(os.path.join(OUTPUT, "log10pvals", "log10pvals.npz"), -np.log10(pvals[0])) create_texture.create_texture_file(OUTPUT=os.path.join(OUTPUT, "pvals"), TEMPLATE_PATH=TEMPLATE_PATH, MASK_PATH=MASK_PATH, beta_path=os.path.join( OUTPUT, "pvals", "pvals.npz"), penalty_start=3, threshold=False) create_texture.create_texture_file(OUTPUT=os.path.join(OUTPUT, "tvals"), TEMPLATE_PATH=TEMPLATE_PATH,
state_X[curr_pos:curr_pos + l] = 0 contrasts[k] = -1 curr_pos = curr_pos + l k = k + 1 l = len(curr[(curr['periods'] == n) & (curr['State'] == 'transi')]) if l != 0: DesignMat[curr_pos:curr_pos + l, k] = np.arange(1, l + 1) #on state_X[curr_pos:curr_pos + l] = 1 contrasts[k] = 1 curr_pos = curr_pos + l k = k + 1 muols = MUOLS(Y=X, X=DesignMat) muols.fit() tvals, pvals, dfs = muols.t_test(contrasts, pval=True, two_tailed=True) T[t, :] = tvals[0] t = t + 1 print t #Store variables ############################################################################# np.save(os.path.join(BASE_PATH, 'toward_on', 'univariate', 'T.npy'), T) #Retreive variables ############################################################################# T = np.load(os.path.join(BASE_PATH, 'toward_on', 'univariate', 'T.npy')) #Second Level analysis ############################################################################
np.save(f, Y) del Y contrasts = np.identity(X.shape[1]) ## Read data Y as a memory map ############################## Y_memmap = np.load(f + '.npy', mmap_mode='r') # univariate analysis: fit by blocks of 2**26 elements muols = MUOLS(Y=Y_memmap, X=X) time1 = time.time() muols.fit(block=True, max_elements=2 ** 26) time2 = time.time() tvals, pvals, dfs = muols.t_test(contrasts=contrasts, pval=True, two_tailed=True) print time2 - time1 del muols # univariate analysis: fit by blocks of 2**27 elements muols = MUOLS(Y=Y_memmap, X=X) time3 = time.time() muols.fit(block=True, max_elements=2 ** 27) time4 = time.time() tvals, pvals, dfs = muols.t_test(contrasts=contrasts, pval=True, two_tailed=True) print time4 - time3 del muols
detrend=True, standardize=True, confounds=None, low_pass=None, high_pass=None, t_r=3) #mean_X=(X[lab==1].mean(axis=0) + X[0:20,:].mean(axis=0) ) / float(2) #X=X-mean_X X = X - X.mean(axis=0) muols = MUOLS(Y=X, X=DesignMat) muols.fit() contrasts = np.identity((8)) tvals, pvals, dfs = muols.t_test(contrasts, pval=True, two_tailed=True) for m in range(0, 8): T[t, :] = tvals[m] betas[t, :] = muols.coef[m, :] subject[t] = subject_num t = t + 1 print t BASE_PATH = "/neurospin/brainomics/2016_classif_hallu_fmri" y = np.zeros((128)) np.save(os.path.join(BASE_PATH, 'results', 'svm_with_HC', 'T_IMA.npy'), T_IMA) np.save(os.path.join(BASE_PATH, 'results', 'svm_with_HC', 'betas_IMA.npy'), betas_IMA) np.save(os.path.join(BASE_PATH, 'results', 'svm_with_HC', 'y_IMA.npy'), y_IMA) np.save(os.path.join(BASE_PATH, 'results', 'svm_with_HC', 'subject_IMA.npy'),
fsl5.0-randomise -i /neurospin/ciclops/projects/BIPLi7/Clinicaldata/Analysis/Processing_February_2019/Reconstruct_gridding/Processing_quantif/TPI_Analysisoutputs_fsl-thres3.5/ALLcs.nii.gz -m /neurospin/ciclops/projects/BIPLi7/Clinicaldata/Analysis/Processing_February_2019/Reconstruct_gridding/Processing_quantif/TPI_Analysisoutputs_fsl-thres3.5/mask.nii.gz -o /neurospin/ciclops/projects/BIPLi7/Clinicaldata/Analysis/Processing_February_2019/Reconstruct_gridding/Processing_quantif/TPI_Analysisoutputs_fsl-thres3.5/li~1+age+sex -d /neurospin/ciclops/projects/BIPLi7/Clinicaldata/Analysis/Processing_February_2019/Reconstruct_gridding/Processing_quantif/TPI_Analysisoutputs_fsl-thres3.5/li~1+age+sex_design.mat -t /neurospin/ciclops/projects/BIPLi7/Clinicaldata/Analysis/Processing_February_2019/Reconstruct_gridding/Processing_quantif/TPI_Analysisoutputs_fsl-thres3.5/li~1+age+sex_contrast.mat -T -n 2000 -C 3.5 fsl5.0-randomise -i /neurospin/ciclops/projects/BIPLi7/Clinicaldata/Analysis/Processing_February_2019/Reconstruct_gridding/Processing_quantif/TPI_Analysisoutputs_fsl-thres4/ALLcs.nii.gz -m /neurospin/ciclops/projects/BIPLi7/Clinicaldata/Analysis/Processing_February_2019/Reconstruct_gridding/Processing_quantif/TPI_Analysisoutputs_fsl-thres4/mask.nii.gz -o /neurospin/ciclops/projects/BIPLi7/Clinicaldata/Analysis/Processing_February_2019/Reconstruct_gridding/Processing_quantif/TPI_Analysisoutputs_fsl-thres4/li~1+age+sex -d /neurospin/ciclops/projects/BIPLi7/Clinicaldata/Analysis/Processing_February_2019/Reconstruct_gridding/Processing_quantif/TPI_Analysisoutputs_fsl-thres4/li~1+age+sex_design.mat -t /neurospin/ciclops/projects/BIPLi7/Clinicaldata/Analysis/Processing_February_2019/Reconstruct_gridding/Processing_quantif/TPI_Analysisoutputs_fsl-thres4/li~1+age+sex_contrast.mat -T -n 2000 -C 4 """ ############################################################################### """ ~/git/scripts/brainomics/image_clusters_analysis_nilearn.py li~1+age+sex_tstat1.nii.gz -o li~1+age+sex_tstat1 --thresh_neg_low 0 --thresh_neg_high 0 --thresh_pos_low 3 --thresh_size 10 """ ############################################################################### ## OLDIES muols = MUOLS(Y=X,X=DesignMat) muols.fit() print('launching the t_test') tvals, pvals_ttest, df1 = muols.t_test(contrasts=[1, 0, 0], pval=True) #%time tvals, pvals_ttest, df1 = muols.t_test(contrasts=[1, 0, 0], pval=True) print('t_test done') print('launching maxT test') #tvals2, pvals_maxT, df2 = muols.t_test_maxT(contrasts=np.array([1, 0, 0]), nperms=1000, two_tailed=False) #print('maxT test done') tvals, pvals_maxT, df3 = muols.t_test_maxT(contrasts=np.array([1, 0, 0]), nperms=1000, two_tailed=True) #♣tvals3, minP, df3 = muols.t_test_minP(contrasts=np.array([1, 0, 0]), nperms=5, two_tailed=True) mhist, bins, patches= plt.hist([pvals_ttest[0,:],pvals_maxT[0,:]], color=['blue','red'], label=['pvals_ttest','pvals_maxT']) mycoefs=np.zeros(mask_arr.shape) mycoefs[mask_arr]=muols.coef[0,:] ##Wilcoxon Test