Esempio n. 1
0
    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)
Esempio n. 2
0
    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)
Esempio n. 3
0
# 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)
Esempio n. 4
0
# 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)
Esempio n. 5
0
import cluster
import BUM
import neuropower
import peakdistribution
from nipy.algorithms.statistics.empirical_pvalue import NormalEmpiricalNull
import matplotlib.pyplot as plt
from palettable.colorbrewer.qualitative import Paired_12
import numpy as np
import scipy.stats as stats
import math

spm = nib.load("/Users/Joke/Documents/Onderzoek/Studie_7_neuropower_improved/WORKDIR/zstat1.nii").get_data()

ps = spm.flatten()
ps = [x for x in ps if x!=0]
enn = NormalEmpiricalNull(ps)
enn.learn()
spm[spm==0] = 'nan'
spm = spm-enn.mu

ps = spm.flatten()
ps = [x for x in ps if x == x]


xn = np.arange(-10,10,0.01)
twocol = Paired_12.mpl_colors
plt.figure(figsize=(7,5))
plt.hist(ps,lw=0,facecolor=twocol[0],normed=True,bins=np.arange(-2,10,0.3),label="observed distribution")
plt.xlim([-2,10])
plt.ylim([0,0.5])
plt.plot(xn,stats.norm.pdf(xn),color=twocol[1],lw=3,label="null distribution")