def test_fdr(): n = 100 x = np.linspace(.5 / n, 1. - .5 / n, n) x[:10] = .0005 x = norm.isf(x) np.random.shuffle(x) assert_almost_equal(fdr_threshold(x, .1), norm.isf(.0005)) assert fdr_threshold(x, .001) == np.infty with pytest.raises(ValueError): fdr_threshold(x, -.1) with pytest.raises(ValueError): fdr_threshold(x, 1.5)
def test_fdr(): rng = np.random.RandomState(42) n = 100 x = np.linspace(.5 / n, 1. - .5 / n, n) x[:10] = .0005 x = norm.isf(x) rng.shuffle(x) assert_almost_equal(fdr_threshold(x, .1), norm.isf(.0005)) assert fdr_threshold(x, .001) == np.infty with pytest.raises(ValueError): fdr_threshold(x, -.1) with pytest.raises(ValueError): fdr_threshold(x, 1.5) # addresses #2879 n = 10 pvals = np.linspace(1 / n, 1, n) pvals[0] = 0.007 assert np.isfinite(fdr_threshold(norm.isf(pvals), .1))
z_maps = [ pjoin(work_dir, acq, 'z_surf', 'effects_interest_%s.gii' % hemi) for acq in acqs ] mean_z = np.mean([ np.ravel([darrays.data for darrays in load(z_map).darrays]) for z_map in z_maps ], 0) n_maps = len(z_maps) fixed_effects = mean_z * np.sqrt(n_maps) gii = GiftiImage( darrays=[GiftiDataArray().from_array(fixed_effects, 't test')]) gii.to_filename(pjoin(write_dir, 'retinotopicity_%s.gii' % hemi)) fixed_effects[np.isnan(fixed_effects)] = 0 bh = fdr_threshold(fixed_effects, alpha) print(bh) mask = fixed_effects > bh # todo: plot on a surface """ output_file = pjoin(write_dir, 'retinotopicity_%s.png' % hemi) if hemi == 'lh': plot_surf_stat_map( lh_inflated, fixed_effects, bg_map=sulc_left, output_file=output_file, hemi='left', view='medial', bg_on_data=True, darkness=1, alpha=1, threshold=THRESHOLD) else: plot_surf_stat_map( rh_inflated, fixed_effects, bg_map=sulc_right, output_file=output_file, hemi='right', view='medial', bg_on_data=True, darkness=1, alpha=1,