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, dt=None)[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()
__init__(input, dt=None)[source]

Constructor.

addargs()[source]

Decorator used by fslmaths methods. Allows them to just return a list of arguments to add to the command invocation.

add(*args, **kwargs)[source]
sub(*args, **kwargs)[source]
mul(*args, **kwargs)[source]
div(*args, **kwargs)[source]
rem(*args, **kwargs)[source]
mas(*args, **kwargs)[source]
thr(*args, **kwargs)[source]
thrp(*args, **kwargs)[source]
thrP(*args, **kwargs)[source]
uthr(*args, **kwargs)[source]
uthrp(*args, **kwargs)[source]
uthrP(*args, **kwargs)[source]
max(*args, **kwargs)[source]
min(*args, **kwargs)[source]
seed(*args, **kwargs)[source]
restart(*args, **kwargs)[source]
save(*args, **kwargs)[source]
exp(*args, **kwargs)[source]
log(*args, **kwargs)[source]
sin(*args, **kwargs)[source]
cos(*args, **kwargs)[source]
tan(*args, **kwargs)[source]
asin(*args, **kwargs)[source]
acos(*args, **kwargs)[source]
atan(*args, **kwargs)[source]
sqr(*args, **kwargs)[source]
sqrt(*args, **kwargs)[source]
recip(*args, **kwargs)[source]
abs(*args, **kwargs)[source]
bin(*args, **kwargs)[source]
binv(*args, **kwargs)[source]
fillh(*args, **kwargs)[source]
fillh26(*args, **kwargs)[source]
index(*args, **kwargs)[source]
grid(*args, **kwargs)[source]
edge(*args, **kwargs)[source]
dog_edge(*args, **kwargs)[source]
tfce(*args, **kwargs)[source]
tfceS(*args, **kwargs)[source]
nan(*args, **kwargs)[source]
nanm(*args, **kwargs)[source]
rand(*args, **kwargs)[source]
randn(*args, **kwargs)[source]
inm(*args, **kwargs)[source]
ing(*args, **kwargs)[source]
range(*args, **kwargs)[source]
tensor_decomp(*args, **kwargs)[source]
kernel(*args, **kwargs)[source]
dilM(*args, **kwargs)[source]
dilD(*args, **kwargs)[source]
dilF(*args, **kwargs)[source]
dilall(*args, **kwargs)[source]
ero(*args, **kwargs)[source]
eroF(*args, **kwargs)[source]
fmedian(*args, **kwargs)[source]
fmean(*args, **kwargs)[source]
fmeanu(*args, **kwargs)[source]
s(*args, **kwargs)[source]
smooth(*args, **kwargs)
subsamp2(*args, **kwargs)[source]
subsamp2offc(*args, **kwargs)[source]
Tmean(*args, **kwargs)[source]
Tstd(*args, **kwargs)[source]
Tmin(*args, **kwargs)[source]
Tmax(*args, **kwargs)[source]
Tmaxn(*args, **kwargs)[source]
Tmedian(*args, **kwargs)[source]
Tperc(*args, **kwargs)[source]
Tar1(*args, **kwargs)[source]
pval(*args, **kwargs)[source]
pval0(*args, **kwargs)[source]
cpval(*args, **kwargs)[source]
ztop(*args, **kwargs)[source]
ptoz(*args, **kwargs)[source]
rank(*args, **kwargs)[source]
ranknorm(*args, **kwargs)[source]
roi(*args, **kwargs)[source]
bptf(*args, **kwargs)[source]
run(output=None, odt=None, **kwargs)[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.

All other arguments are ultimately passed through to the fsl.utils.run.run() function.

__run(*cmd)

Run the given fslmaths command.

__dict__ = mappingproxy({'__module__': 'fsl.wrappers.fslmaths', '__doc__': "Perform mathematical manipulation of images.\n\n    ``fslmaths`` is unlike the other FSL wrapper tools in that it provides an\n    object-oriented method-chaining interface, which is hopefully easier to\n    use than constructing a ``fslmaths`` command-line call. For example, the\n    following call to the ``fslmaths`` wrapper function::\n\n        fslmaths('input.nii').thr(0.25).mul(-1).run('output.nii')\n\n    will be translated into the following command-line call::\n\n        fslmaths input.nii -thr 0.25 -mul -1 output.nii\n\n    The ``fslmaths`` wrapper function can also be used with in-memory\n    images. If no output file name is passed to the :meth:`run` method, the\n    result is loaded into memory and returned as a ``nibabel`` image.  For\n    example::\n\n        import nibabel as nib\n        input  = nib.load('input.nii')\n        output = fslmaths(input).thr(0.25).mul(-1).run()\n    ", '__init__': <function fslmaths.__init__>, 'addargs': <function fslmaths.addargs>, 'add': <function fslmaths.addargs.<locals>.wrapper>, 'sub': <function fslmaths.addargs.<locals>.wrapper>, 'mul': <function fslmaths.addargs.<locals>.wrapper>, 'div': <function fslmaths.addargs.<locals>.wrapper>, 'rem': <function fslmaths.addargs.<locals>.wrapper>, 'mas': <function fslmaths.addargs.<locals>.wrapper>, 'thr': <function fslmaths.addargs.<locals>.wrapper>, 'thrp': <function fslmaths.addargs.<locals>.wrapper>, 'thrP': <function fslmaths.addargs.<locals>.wrapper>, 'uthr': <function fslmaths.addargs.<locals>.wrapper>, 'uthrp': <function fslmaths.addargs.<locals>.wrapper>, 'uthrP': <function fslmaths.addargs.<locals>.wrapper>, 'max': <function fslmaths.addargs.<locals>.wrapper>, 'min': <function fslmaths.addargs.<locals>.wrapper>, 'seed': <function fslmaths.addargs.<locals>.wrapper>, 'restart': <function fslmaths.addargs.<locals>.wrapper>, 'save': <function fslmaths.addargs.<locals>.wrapper>, 'exp': <function fslmaths.addargs.<locals>.wrapper>, 'log': <function fslmaths.addargs.<locals>.wrapper>, 'sin': <function fslmaths.addargs.<locals>.wrapper>, 'cos': <function fslmaths.addargs.<locals>.wrapper>, 'tan': <function fslmaths.addargs.<locals>.wrapper>, 'asin': <function fslmaths.addargs.<locals>.wrapper>, 'acos': <function fslmaths.addargs.<locals>.wrapper>, 'atan': <function fslmaths.addargs.<locals>.wrapper>, 'sqr': <function fslmaths.addargs.<locals>.wrapper>, 'sqrt': <function fslmaths.addargs.<locals>.wrapper>, 'recip': <function fslmaths.addargs.<locals>.wrapper>, 'abs': <function fslmaths.addargs.<locals>.wrapper>, 'bin': <function fslmaths.addargs.<locals>.wrapper>, 'binv': <function fslmaths.addargs.<locals>.wrapper>, 'fillh': <function fslmaths.addargs.<locals>.wrapper>, 'fillh26': <function fslmaths.addargs.<locals>.wrapper>, 'index': <function fslmaths.addargs.<locals>.wrapper>, 'grid': <function fslmaths.addargs.<locals>.wrapper>, 'edge': <function fslmaths.addargs.<locals>.wrapper>, 'dog_edge': <function fslmaths.addargs.<locals>.wrapper>, 'tfce': <function fslmaths.addargs.<locals>.wrapper>, 'tfceS': <function fslmaths.addargs.<locals>.wrapper>, 'nan': <function fslmaths.addargs.<locals>.wrapper>, 'nanm': <function fslmaths.addargs.<locals>.wrapper>, 'rand': <function fslmaths.addargs.<locals>.wrapper>, 'randn': <function fslmaths.addargs.<locals>.wrapper>, 'inm': <function fslmaths.addargs.<locals>.wrapper>, 'ing': <function fslmaths.addargs.<locals>.wrapper>, 'range': <function fslmaths.addargs.<locals>.wrapper>, 'tensor_decomp': <function fslmaths.addargs.<locals>.wrapper>, 'kernel': <function fslmaths.addargs.<locals>.wrapper>, 'dilM': <function fslmaths.addargs.<locals>.wrapper>, 'dilD': <function fslmaths.addargs.<locals>.wrapper>, 'dilF': <function fslmaths.addargs.<locals>.wrapper>, 'dilall': <function fslmaths.addargs.<locals>.wrapper>, 'ero': <function fslmaths.addargs.<locals>.wrapper>, 'eroF': <function fslmaths.addargs.<locals>.wrapper>, 'fmedian': <function fslmaths.addargs.<locals>.wrapper>, 'fmean': <function fslmaths.addargs.<locals>.wrapper>, 'fmeanu': <function fslmaths.addargs.<locals>.wrapper>, 's': <function fslmaths.addargs.<locals>.wrapper>, 'smooth': <function fslmaths.addargs.<locals>.wrapper>, 'subsamp2': <function fslmaths.addargs.<locals>.wrapper>, 'subsamp2offc': <function fslmaths.addargs.<locals>.wrapper>, 'Tmean': <function fslmaths.addargs.<locals>.wrapper>, 'Tstd': <function fslmaths.addargs.<locals>.wrapper>, 'Tmin': <function fslmaths.addargs.<locals>.wrapper>, 'Tmax': <function fslmaths.addargs.<locals>.wrapper>, 'Tmaxn': <function fslmaths.addargs.<locals>.wrapper>, 'Tmedian': <function fslmaths.addargs.<locals>.wrapper>, 'Tperc': <function fslmaths.addargs.<locals>.wrapper>, 'Tar1': <function fslmaths.addargs.<locals>.wrapper>, 'pval': <function fslmaths.addargs.<locals>.wrapper>, 'pval0': <function fslmaths.addargs.<locals>.wrapper>, 'cpval': <function fslmaths.addargs.<locals>.wrapper>, 'ztop': <function fslmaths.addargs.<locals>.wrapper>, 'ptoz': <function fslmaths.addargs.<locals>.wrapper>, 'rank': <function fslmaths.addargs.<locals>.wrapper>, 'ranknorm': <function fslmaths.addargs.<locals>.wrapper>, 'roi': <function fslmaths.addargs.<locals>.wrapper>, 'bptf': <function fslmaths.addargs.<locals>.wrapper>, 'run': <function fslmaths.run>, '_fslmaths__run': <function fslmaths.__run>, '__dict__': <attribute '__dict__' of 'fslmaths' objects>, '__weakref__': <attribute '__weakref__' of 'fslmaths' objects>, '__annotations__': {}})
__module__ = 'fsl.wrappers.fslmaths'
__weakref__

list of weak references to the object (if defined)