algorithms.kernel_smooth

Module: algorithms.kernel_smooth

Inheritance diagram for nipy.algorithms.kernel_smooth:

digraph inheritance47a48ff640 { rankdir=LR; size="8.0, 12.0"; "algorithms.kernel_smooth.LinearFilter" [URL="#nipy.algorithms.kernel_smooth.LinearFilter",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="A class to implement some FFT smoothers for Image objects."]; }

Linear filter(s). For the moment, only a Gaussian smoothing filter

Class

LinearFilter

class nipy.algorithms.kernel_smooth.LinearFilter(coordmap, shape, fwhm=6.0, scale=1.0, location=0.0, cov=None)[source]

Bases: object

A class to implement some FFT smoothers for Image objects. By default, this does a Gaussian kernel smooth. More choices would be better!

__init__(coordmap, shape, fwhm=6.0, scale=1.0, location=0.0, cov=None)[source]
Parameters

coordmap : CoordinateMap

shape : sequence

fwhm : float, optional

fwhm for Gaussian kernel, default is 6.0

scale : float, optional

scaling to apply to data after smooth, default 1.0

location : float

offset to apply to data after smooth and scaling, default 0

cov : None or array, optional

Covariance matrix

normalization = 'l1sum'
smooth(inimage, clean=False, is_fft=False)[source]

Apply smoothing to inimage

Parameters

inimage : Image

The image to be smoothed. Should be 3D.

clean : bool, optional

Should we call nan_to_num on the data before smoothing?

is_fft : bool, optional

Has the data already been fft’d?

Returns

s_image : Image

New image, with smoothing applied

Functions

nipy.algorithms.kernel_smooth.fwhm2sigma(fwhm)[source]

Convert a FWHM value to sigma in a Gaussian kernel.

Parameters

fwhm : array-like

FWHM value or values

Returns

sigma : array or float

sigma values corresponding to fwhm values

Examples

>>> sigma = fwhm2sigma(6)
>>> sigmae = fwhm2sigma([6, 7, 8])
>>> sigma == sigmae[0]
True
nipy.algorithms.kernel_smooth.sigma2fwhm(sigma)[source]

Convert a sigma in a Gaussian kernel to a FWHM value

Parameters

sigma : array-like

sigma value or values

Returns

fwhm : array or float

fwhm values corresponding to sigma values

Examples

>>> fwhm = sigma2fwhm(3)
>>> fwhms = sigma2fwhm([3, 4, 5])
>>> fwhm == fwhms[0]
True