def run(self): for fname in self.inputs.spmT_images: img = nifti.load(fname) data = np.array(img.get_data()) fdr = ENN(data.ravel()) th = fdr.threshold(0.05) plt.figure() ax = plt.subplot(1, 1, 1) fdr.plot(mpaxes=ax) plt.savefig("histogram.pdf") active_map = data > th thresholded_map = np.zeros(data.shape) thresholded_map[active_map] = data[active_map] thresholded_map = np.reshape(thresholded_map, data.shape) new_img = nifti.Nifti1Image(thresholded_map, img.get_affine(), img.get_header()) nifti.save(new_img, 'thresholded_map.nii') runtime = Bunch(returncode=0, messages=None, errmessages=None) outputs = None return InterfaceResult(deepcopy(self), runtime, outputs=outputs)
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: import numpy as np from nipy.algorithms.statistics.empirical_pvalue import NormalEmpiricalNull x = np.c_[np.random.normal(size=10000), np.random.normal(scale=4, size=10000)] enn = NormalEmpiricalNull(x) enn.threshold(verbose=True)
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: import numpy as np from nipy.algorithms.statistics.empirical_pvalue import NormalEmpiricalNull x = np.c_[np.random.normal(size=1e4), np.random.normal(scale=4, size=1e4)] enn = NormalEmpiricalNull(x) enn.threshold(verbose=True)