@@ -0,0 +1,1436 @@
+%22%22%22 Tests for bh_procedure in benjamini_hochberg module%0A%0ARun at the project directory with:%0A    nosetests code/utils/tests/test_bh.py%0A%22%22%22%0A%0A# Loading modules.%0Aimport numpy as np%0Aimport itertools%0Aimport scipy.ndimage%0Afrom scipy.ndimage.filters import gaussian_filter%0Aimport matplotlib.pyplot as plt%0Aimport nibabel as nib%0Aimport os%0Aimport sys%0Afrom numpy.testing import assert_almost_equal%0Afrom nose.tools import assert_not_equals%0Afrom hypothesis import t_stat%0A%0A# Path to the subject 009 fMRI data used in class. %0Apathtoclassdata = %22data/ds114/%22%0A%0A# Add path to functions to the system path.%0Asys.path.append(os.path.join(os.path.dirname(__file__), %22../functions/%22))%0A%0A# Load our benjamini-hochberg function%0Afrom benjamini_hochberg import bh_procedure%0A%0Adef test_bh():%0A%09img = nib.load(pathtoclassdata + %22ds114_sub009_t2r1.nii%22)%0A    data = img.get_data()%5B..., 4:%5D%0A    # Read in the convolutions. %0A    convolved = np.loadtxt(pathtoclassdata + %22ds114_sub009_t2r1_conv.txt%22)%5B4:%5D%0A    # Create design matrix. %0A    %0A    beta,t,df,p = t_stat(data, convolved,%5B1,1%5D)%0A    beta2, t2,df2,p2 = t_stat(data, convolved,%5B0,1%5D)%0A%0A    Q = 1.0%0A    pval = p%0A    useless_bh = bh_procedure(pval, Q)%0A%0A    # Since the FDR is 100%25, the bh_procedure should return the exact same thing as the original data.%0A    assert_almost_equal(data%5B...,7%5D, useless_bh%5B...,7%5D)%0A%0A    Q_real = .25%0A    real_bh = bh_procedure(pval, Q_real)%0A    assert_not_equals(data%5B...,7%5D, real_bh%5B...,7%5D)

add bh test file