In [11]:
% matplotlib inline
import os
import numpy as np
import nibabel as nib
from nipy.labs.utils.simul_multisubject_fmri_dataset import surrogate_3d_dataset
import nipy.algorithms.statistics.rft as rft
from __future__ import print_function, division
import math
import matplotlib.pyplot as plt
import palettable.colorbrewer as cb
from nipype.interfaces import fsl
import pandas as pd
import nipy.algorithms.statistics.intvol as intvol
from matplotlib import colors
import scipy.stats as stats
import scipy.ndimage as nd

In [31]:
nr = np.random.RandomState([500])
shape = [1000,1000,1000]
noise = nr.randn(shape[0], shape[1], shape[2])

In [32]:
plt.figure(figsize=(6,4))
plt.imshow(noise[1:20,1:20,1])
plt.colorbar()
plt.show()



In [ ]:
np.var(noise)

In [24]:
smooth_FWHM = 3
smooth_sigma = smooth_FWHM/(2*math.sqrt(2*math.log(2)))
noise_sm = nd.gaussian_filter(noise, smooth_sigma)


Out[24]:
1.2739827004320285

In [25]:
plt.figure(figsize=(6,4))
plt.imshow(noise_sm[1:20,1:20,1])
plt.colorbar()
plt.show()



In [26]:
np.var(noise_sm)


Out[26]:
0.011015989661950849

In [28]:
kernel = np.zeros((20,20,20))
kernel[10,10,10] = 1
kernel_sm = nd.gaussian_filter(kernel, smooth_sigma)

In [30]:
np.sum(kernel_sm**2)


Out[30]:
0.010857260543508631

In [ ]: