def test_4():
	# checks that neighbor_smoothing_binary works
	zeros = np.zeros((5, 5, 5))

	rachel = np.zeros((5, 5, 5))
	rachel[2, 2:4, 2] = 1
	rachel_n = neighbor_smoothing_binary(rachel, 3)
	assert_array_almost_equal(rachel_n, zeros)
Beispiel #2
0
    #####################################
    # Run bh_procedure for each subject #
    #####################################
    p_3d = np.load("../data/p-values/" + name + "_pvalue.npy")
    p_1d = np.ravel(p_3d)

    mask = fitted_mask
    mask_1d = np.ravel(mask)
    p_bh = p_1d[mask_1d == 1]

    bh_first = bh_procedure(p_bh, q)
    bh_3d = masking_reshape_end(bh_first, mask, off_value=.5)
    bh_3d[bh_3d < .5] = 0
    bh_3d_1_good = 1 - bh_3d

    bh_final = neighbor_smoothing_binary(bh_3d_1_good, neighbors)

    bh_mean[..., i] = bh_3d_1_good

    #####################################
    # Run t_grouping for each subject   #
    #####################################
    t_3d = np.load("../data/t_stat/" + name + "_tstat.npy")

    #mask = fitted_mask
    t_group = t_grouping_neighbor(t_3d,
                                  mask,
                                  prop_t,
                                  neighbors=neighbors,
                                  prop=True,
                                  abs_on=True,
toolbar_width = len(q1)
sys.stdout.write("Benjamini Hochberg: ")
sys.stdout.write("[%s]" % (" " * toolbar_width))
sys.stdout.flush()
sys.stdout.write("\b" *
                 (toolbar_width + 1))  # return to start of line, after '['

bh = []  # values a*6 + b - 1
count_a = 0
for a, b in itertools.product(range(len(q1)), range(5)):
    bh_first = bh_procedure(p_bh, q1[a])
    bh_3d = masking_reshape_end(bh_first, mask, off_value=.5)
    bh_3d[bh_3d < .5] = 0

    bh_3d_1_good = 1 - bh_3d
    first = neighbor_smoothing_binary(bh_3d_1_good, neighbors1[b])

    bh.append(first)

    if count_a == a and b == 4:
        sys.stdout.write("-")
        sys.stdout.flush()
        count_a += 1

sys.stdout.write("\n")

#------------------#
# Image comparison #
#------------------#

present_bh = np.ones((len(q1) * 64, 5 * 64))
sys.stdout.flush()
sys.stdout.write("\b" * (toolbar_width+1)) # return to start of line, after '['
    


bh=[] # values a*6 + b - 1
count_a=0
for a,b in itertools.product(range(len(q1)),range(5)):
	bh_first = bh_procedure(p_bh,q1[a])
	bh_3d    = masking_reshape_end(bh_first,mask,off_value=.5)
	bh_3d[bh_3d<.5]=0

	

	bh_3d_1_good = 1-bh_3d	
	first  = neighbor_smoothing_binary(bh_3d_1_good,neighbors1[b])

	bh.append(first)


	if count_a==a and b==4:
		sys.stdout.write("-")
		sys.stdout.flush()
		count_a+=1
	

sys.stdout.write("\n")


#------------------#
# Image comparison #
	#####################################
	# Run bh_procedure for each subject #
	#####################################
	p_3d = np.load("../data/p-values/" + name + "_pvalue.npy")
	p_1d = np.ravel(p_3d)

	mask = fitted_mask
	mask_1d = np.ravel(mask)
	p_bh = p_1d[mask_1d == 1]

	bh_first = bh_procedure(p_bh, q)
	bh_3d    = masking_reshape_end(bh_first, mask, off_value = .5)
	bh_3d[bh_3d < .5] = 0
	bh_3d_1_good = 1 - bh_3d

	bh_final  = neighbor_smoothing_binary(bh_3d_1_good, neighbors)

	bh_mean[..., i] = bh_3d_1_good

	#####################################
	# Run t_grouping for each subject   #
	#####################################
	t_3d = np.load("../data/t_stat/" + name + "_tstat.npy")

	#mask = fitted_mask
	t_group = t_grouping_neighbor(t_3d, mask, prop_t, neighbors = neighbors,
					prop = True, abs_on = True, binary = True, off_value = 0, masked_value = .5)[0]

	t_mean[..., i] = t_group

	######################################