def compute_hurst_and_stat(metric='dfa', regu='off', OUTPUT_PATH = '/volatile/hubert/beamer/test_hurst/', plot=False): conn = Hurst_Estimator(metric=metric, mask=dataset.mask,smoothing_fwhm=0, regu=regu, n_jobs=5) os.write(1,'fit\n') fc = conn.fit(dataset.func1) #conn.load_map(INPUT_PATH) os.write(1,'save\n') #stat_function_tst(conn, metric+' '+regu+' ', OUTPUT_PATH) conn.save(save_path=OUTPUT_PATH) if plot: os.write(1,'plot\n') a = Parallel(n_jobs=3, verbose=5)(delayed(classify_group)(group, fc) for group in groups) tst = Parallel(n_jobs=3, verbose=5)(delayed(ttest_group)(group, .05, fc) for group in groups) ost = Parallel(n_jobs=3, verbose=5)(delayed(ttest_onesample)(group, 0.05, fc) for group in ['v', 'av', 'avn']) mht = Parallel(n_jobs=3, verbose=5)(delayed(ttest_onesample_Hmean)(group, 0.05, fc) for group in ['v', 'av', 'avn']) mpt = Parallel(n_jobs=3, verbose=5)(delayed(mne_permutation_ttest)(group,0.05, fc, 1) for group in ['v', 'av', 'avn']) cot = Parallel(n_jobs=3, verbose=5)(delayed(ttest_onesample_coef)(np.reshape(coef['coef'], (coef['coef'].shape[0], coef['coef'].shape[-1])), 0.05, fc) for coef in a) gr = ['v', 'av', 'avn'] if regu=='off': OUTPUT_PATH = os.path.join(OUTPUT_PATH, metric) else: OUTPUT_PATH = os.path.join(OUTPUT_PATH, metric, regu) for i in range(3): title = '_'.join(groups[i]) output_file = os.path.join(OUTPUT_PATH, title) img = conn.masker.inverse_transform(tst[i]) plot_stat_map(img, cut_coords=(3, -63, 36), title=title, output_file=output_file + '.pdf') img = conn.masker.inverse_transform(cot[i]) plot_stat_map(img, title='coef_map ' + title, output_file=output_file + 'coef_map.pdf') title = gr[i] output_file = os.path.join(OUTPUT_PATH, title) img = conn.masker.inverse_transform(ost[i]) plot_stat_map(img, title='t-test H0 : H = 0.5 pvalue in -log10 scale groupe : ' + title, output_file= output_file + '.pdf') img = conn.masker.inverse_transform(mht[i]) plot_stat_map(img, title='t-test H0 : H = 0.5 pvalue in -log10 scale groupe : ' + title, output_file= output_file + 'meanH.pdf') img = conn.masker.inverse_transform(mpt[i]) plot_stat_map(img, title='t-test H0 : H = 0.5 pvalue in -log10 scale groupe : ' + title, output_file= output_file + 'mnepermutH.pdf') plt.figure() plt.boxplot(map(lambda x: x['accuracy'], a)) plt.savefig(os.path.join(OUTPUT_PATH, 'boxplot.pdf'))
def wavelet4_estimation( INPUT_PATH='/volatile/hubert/beamer/test_hurst/wavelet4'): conn = Hurst_Estimator(metric='wavelet', mask=dataset.mask, regu='tv', nb_vanishmoment=4, j1=3, j2=7, n_jobs=5) conn.fit(dataset.func1) conn.save(INPUT_PATH)
def compute_hurst_and_stat(metric='wavelet', regu='off', lbda = 1, OUTPUT_PATH = '/volatile/hubert/beamer/HEES0/', plot=False): conn = Hurst_Estimator(metric=metric, lbda = lbda, mask=dataset.mask,smoothing_fwhm=0, regu=regu, n_jobs=5) os.write(1,'fit\n') fc = conn.fit(dataset.func1) #conn.load_map(INPUT_PATH = OUTPUT_PATH, save_file= 'hurstmap_metric_wavelet_regu_l2' +str(lbda)) fc = conn.hurst os.write(1,'save\n') #stat_function_tst(conn, metric+' '+regu+' ', OUTPUT_PATH) conn.save(save_path=OUTPUT_PATH) if plot: os.write(1,'plot\n') if regu=='off': OUTPUT_PATH = os.path.join(OUTPUT_PATH, metric) else: OUTPUT_PATH = os.path.join(OUTPUT_PATH, metric, regu) stat_function(conn, prefix = 'lbda' + str(lbda), OUTPUT_PATH=OUTPUT_PATH) return conn
def compute_hurst_and_stat(metric='dfa', regu='off', OUTPUT_PATH='/volatile/hubert/beamer/test_hurst/', plot=False): conn = Hurst_Estimator(metric=metric, mask=dataset.mask, smoothing_fwhm=0, regu=regu, n_jobs=5) os.write(1, 'fit\n') fc = conn.fit(dataset.func1) #conn.load_map(INPUT_PATH) os.write(1, 'save\n') #stat_function_tst(conn, metric+' '+regu+' ', OUTPUT_PATH) conn.save(save_path=OUTPUT_PATH) if plot: os.write(1, 'plot\n') a = Parallel(n_jobs=3, verbose=5)(delayed(classify_group)(group, fc) for group in groups) tst = Parallel(n_jobs=3, verbose=5)(delayed(ttest_group)(group, .05, fc) for group in groups) ost = Parallel(n_jobs=3, verbose=5)(delayed(ttest_onesample)(group, 0.05, fc) for group in ['v', 'av', 'avn']) mht = Parallel(n_jobs=3, verbose=5)( delayed(ttest_onesample_Hmean)(group, 0.05, fc) for group in ['v', 'av', 'avn']) mpt = Parallel(n_jobs=3, verbose=5)( delayed(mne_permutation_ttest)(group, 0.05, fc, 1) for group in ['v', 'av', 'avn']) cot = Parallel(n_jobs=3, verbose=5)( delayed(ttest_onesample_coef)(np.reshape(coef['coef'], ( coef['coef'].shape[0], coef['coef'].shape[-1])), 0.05, fc) for coef in a) gr = ['v', 'av', 'avn'] if regu == 'off': OUTPUT_PATH = os.path.join(OUTPUT_PATH, metric) else: OUTPUT_PATH = os.path.join(OUTPUT_PATH, metric, regu) for i in range(3): title = '_'.join(groups[i]) output_file = os.path.join(OUTPUT_PATH, title) img = conn.masker.inverse_transform(tst[i]) plot_stat_map(img, cut_coords=(3, -63, 36), title=title, output_file=output_file + '.pdf') img = conn.masker.inverse_transform(cot[i]) plot_stat_map(img, title='coef_map ' + title, output_file=output_file + 'coef_map.pdf') title = gr[i] output_file = os.path.join(OUTPUT_PATH, title) img = conn.masker.inverse_transform(ost[i]) plot_stat_map( img, title='t-test H0 : H = 0.5 pvalue in -log10 scale groupe : ' + title, output_file=output_file + '.pdf') img = conn.masker.inverse_transform(mht[i]) plot_stat_map( img, title='t-test H0 : H = 0.5 pvalue in -log10 scale groupe : ' + title, output_file=output_file + 'meanH.pdf') img = conn.masker.inverse_transform(mpt[i]) plot_stat_map( img, title='t-test H0 : H = 0.5 pvalue in -log10 scale groupe : ' + title, output_file=output_file + 'mnepermutH.pdf') plt.figure() plt.boxplot(map(lambda x: x['accuracy'], a)) plt.savefig(os.path.join(OUTPUT_PATH, 'boxplot.pdf'))
def wavelet4_estimation(INPUT_PATH = '/volatile/hubert/beamer/test_hurst/wavelet4'): conn = Hurst_Estimator(metric='wavelet', mask=dataset.mask, regu='tv', nb_vanishmoment=4, j1 =3, j2=7, n_jobs=5) conn.fit(dataset.func1) conn.save(INPUT_PATH)