fsl.wrappers.fslmaths

This module provides the fslmaths class, which acts as a wrapper for the fslmaths command-line tool.

class fsl.wrappers.fslmaths.fslmaths(input)[source]

Bases: object

Perform mathematical manipulation of images.

fslmaths is unlike the other FSL wrapper tools in that it provides an object-oriented method-chaining interface, which is hopefully easier to use than constructing a fslmaths command-line call. For example, the following call to the fslmaths wrapper function:

fslmaths('input.nii').thr(0.25).mul(-1).run('output.nii')

will be translated into the following command-line call:

fslmaths input.nii -thr 0.25 -mul -1 output.nii

The fslmaths wrapper function can also be used with in-memory images. If no output file name is passed to the run() method, the result is loaded into memory and returned as a nibabel image. For example:

import nibabel as nib
input  = nib.load('input.nii')
output = fslmaths(input).thr(0.25).mul(-1).run()
abs()[source]

Absolute value.

bin()[source]

Use (current image>0) to binarise.

binv()[source]

Binarise and invert (binarisation and logical inversion).

recip()[source]

Reciprocal (1/current image).

Tmean()[source]

Mean across time.

Tstd()[source]

Standard deviation across time.

Tmin()[source]

Min across time.

Tmax()[source]

Max across time.

fillh()[source]

fill holes in a binary mask (holes are internal - i.e. do not touch the edge of the FOV).

ero(repeat=1)[source]

Erode by zeroing non-zero voxels when zero voxels in kernel.

dilM(repeat=1)[source]

Mean Dilation of non-zero voxels.

dilF(repeat=1)[source]

Maximum filtering of all voxels.

add(image)[source]

Add input to current image.

sub(image)[source]

Subtract image from current image.

mul(image)[source]

Multiply current image by image.

div(image)[source]

Divide current image by image.

mas(image)[source]

Use image (>0) to mask current image.

rem(image)[source]

Divide current image by following image and take remainder.

thr(image)[source]

use image number to threshold current image (zero < image).

uthr(image)[source]

use image number to upper-threshold current image (zero anything above the number).

inm(image)[source]

Intensity normalisation (per 3D volume mean)

bptf(hp_sigma, lp_sigma)[source]

Bandpass temporal filtering; nonlinear highpass and Gaussian linear lowpass (with sigmas in volumes, not seconds); set either sigma<0 to skip that filter.

run(output=None)[source]

Save output of operations to image. Set output to a filename to have the result saved to file, or omit output entirely to have the result returned as a nibabel image.