def test_anovStat():
    # create a test dataset
    t_data = np.reshape(np.array([2, 0.1, 3, 0.04, 2.1, 0.01, 0, 0, 1.2, 0.05, 2.2, 2]), (-1, 2))
    # Significance level chosen to be 0.05, 0.05/5 = 0.01 after bonferroni correction
    # Should give: 0.01 significant out of 0.1, 0.04, 0.01, 0.05, 2
    test_prop = 1/5
    # my function
    my_prop = anovStat(t_data)
    # Assert
    assert_allclose(test_prop, my_prop)
        parameters = merge_cond(behav_cond, task_cond1, task_cond2, task_cond3, task_cond4)
        neural_prediction = events2neural_extend(parameters,TR, n_vols)
        gain, loss, linear_dr, quad_dr = getRegressor(TR, n_vols, hrf_at_trs, neural_prediction)
        data, gain, loss, linear_dr, quad_dr = deleteOutliers(data, gain, loss, linear_dr, quad_dr, i, run, dvars_out, fd_out)
        run_count[j-1] = data.shape[3]     ## dummy variable indicating the groups
        data_full = np.concatenate((data_full,data),axis=3)
        gain_full = np.concatenate((gain_full,gain),axis=0)
        loss_full = np.concatenate((loss_full,loss),axis=0)
        linear_full = np.concatenate((linear_full,linear_dr),axis=0)
        quad_full = np.concatenate((quad_full,quad_dr),axis=0)
        
    run_group = np.concatenate((np.repeat(1, run_count[0]), 
                                np.repeat(2, run_count[1]), np.repeat(3, run_count[2])), axis=0)
    thrshd = 400 ## set a threshold to idenfity the voxels inside the brain
    print "calculating parameters of subject "+str(i)
    beta = calcBetaLme(data_full, gain_full, loss_full, linear_full, quad_full, run_group, thrshd)
    sig_level = 0.05
    sig_gain_prop[i-1], sig_loss_prop[i-1] = calcSigProp(beta, sig_level)
    write=pathtofolder + 'ds005/sub0'+str(i).zfill(2)+'/model/model001/onsets/sub0'+str(i).zfill(2)+'_lme_beta.txt'
    np.savetxt(write, beta)
    anov_test = calcAnov(data_full, run_group, thrshd)
    anov_prop[i-1] = anovStat(anov_test)

write=pathtofolder + 'ds005/models/lme_sig_gain_prop.txt'
np.savetxt(write,  sig_gain_prop)
write=pathtofolder + 'ds005/models/lme_sig_loss_prop.txt'
np.savetxt(write,  sig_loss_prop)
write=pathtofolder + 'ds005/models/anova_prop.txt'
np.savetxt(write,  anov_prop)

        parameters = merge_cond(behav_cond, task_cond1, task_cond2, task_cond3, task_cond4)
        neural_prediction = events2neural_extend(parameters,TR, n_vols)
        gain, loss, linear_dr, quad_dr = getRegressor(TR, n_vols, hrf_at_trs, neural_prediction)
        data, gain, loss, linear_dr, quad_dr = deleteOutliers(data, gain, loss, linear_dr, quad_dr, i, run, dvars_out, fd_out)
        run_count[j-1] = data.shape[3]     ## dummy variable indicating the groups
        data_full = np.concatenate((data_full,data),axis=3)
        gain_full = np.concatenate((gain_full,gain),axis=0)
        loss_full = np.concatenate((loss_full,loss),axis=0)
        linear_full = np.concatenate((linear_full,linear_dr),axis=0)
        quad_full = np.concatenate((quad_full,quad_dr),axis=0)
        
    run_group = np.concatenate((np.repeat(1, run_count[0]), 
                                np.repeat(2, run_count[1]), np.repeat(3, run_count[2])), axis=0)
    thrshd = 400 ## set a threshold to idenfity the voxels inside the brain
    print "calculating parameters of subject "+str(i)
    beta = calcBetaLme(data_full, gain_full, loss_full, linear_full, quad_full, run_group, thrshd)
    sig_level = 0.05
    sig_gain_prop[i-1], sig_loss_prop[i-1] = calcSigProp(beta, sig_level)
    write=pathtofolder + 'ds005/sub0'+str(i).zfill(2)+'/model/model001/onsets/sub0'+str(i).zfill(2)+'_lme_beta.txt'
    np.savetxt(write, beta)
    anov_test = calcAnov(data_full, run_group)
    anov_prop[i-1] = anovStat(anov_test)

write=pathtofolder + 'ds005/models/lme_sig_gain_prop.txt'
np.savetxt(write,  sig_gain_prop)
write=pathtofolder + 'ds005/models/lme_sig_loss_prop.txt'
np.savetxt(write,  sig_loss_prop)
write=pathtofolder + 'ds005/models/anova_prop.txt'
np.savetxt(write,  anov_prop)