nipype.interfaces.fsl.utils module

The fsl module provides classes for interfacing with the FSL command line tools. This was written to work with FSL version 4.1.4.

Examples

See the docstrings of the individual classes for examples.

AvScale

Link to code

Bases: CommandLine

Wrapped executable: avscale.

Use FSL avscale command to extract info from mat file output of FLIRT

Examples

>>> avscale = AvScale()
>>> avscale.inputs.mat_file = 'flirt.mat'
>>> res = avscale.run()  
Optional Inputs:
  • all_param (a boolean) – Maps to a command-line argument: --allparams.

  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • mat_file (a pathlike object or string representing an existing file) – Mat file to read. Maps to a command-line argument: %s (position: -2).

  • ref_file (a pathlike object or string representing an existing file) – Reference file to get center of rotation. Maps to a command-line argument: %s (position: -1).

Outputs:
  • average_scaling (a float) – Average Scaling.

  • backward_half_transform (a list of items which are a list of items which are a float) – Backwards Half Transform.

  • determinant (a float) – Determinant.

  • forward_half_transform (a list of items which are a list of items which are a float) – Forward Half Transform.

  • left_right_orientation_preserved (a boolean) – True if LR orientation preserved.

  • rot_angles (a list of items which are a float) – Rotation angles.

  • rotation_translation_matrix (a list of items which are a list of items which are a float) – Rotation and Translation Matrix.

  • scales (a list of items which are a float) – Scales (x,y,z).

  • skews (a list of items which are a float) – Skews.

  • translations (a list of items which are a float) – Translations.

Complex

Link to code

Bases: FSLCommand

Wrapped executable: fslcomplex.

fslcomplex is a tool for converting complex data

Examples

>>> cplx = Complex()
>>> cplx.inputs.complex_in_file = "complex.nii"
>>> cplx.real_polar = True
>>> res = cplx.run() 
Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • complex_cartesian (a boolean) – Maps to a command-line argument: -complex (position: 1). Mutually exclusive with inputs: real_polar, real_cartesian, complex_cartesian, complex_polar, complex_split, complex_merge.

  • complex_in_file (a pathlike object or string representing an existing file) – Maps to a command-line argument: %s (position: 2).

  • complex_in_file2 (a pathlike object or string representing an existing file) – Maps to a command-line argument: %s (position: 3).

  • complex_merge (a boolean) – Maps to a command-line argument: -complexmerge (position: 1). Mutually exclusive with inputs: real_polar, real_cartesian, complex_cartesian, complex_polar, complex_split, complex_merge, start_vol, end_vol.

  • complex_out_file (a pathlike object or string representing a file) – Maps to a command-line argument: %s (position: -3). Mutually exclusive with inputs: complex_out_file, magnitude_out_file, phase_out_file, real_out_file, imaginary_out_file, real_polar, real_cartesian.

  • complex_polar (a boolean) – Maps to a command-line argument: -complexpolar (position: 1). Mutually exclusive with inputs: real_polar, real_cartesian, complex_cartesian, complex_polar, complex_split, complex_merge.

  • complex_split (a boolean) – Maps to a command-line argument: -complexsplit (position: 1). Mutually exclusive with inputs: real_polar, real_cartesian, complex_cartesian, complex_polar, complex_split, complex_merge.

  • end_vol (an integer) – Maps to a command-line argument: %d (position: -1).

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • imaginary_in_file (a pathlike object or string representing an existing file) – Maps to a command-line argument: %s (position: 3).

  • imaginary_out_file (a pathlike object or string representing a file) – Maps to a command-line argument: %s (position: -3). Mutually exclusive with inputs: complex_out_file, magnitude_out_file, phase_out_file, real_polar, complex_cartesian, complex_polar, complex_split, complex_merge.

  • magnitude_in_file (a pathlike object or string representing an existing file) – Maps to a command-line argument: %s (position: 2).

  • magnitude_out_file (a pathlike object or string representing a file) – Maps to a command-line argument: %s (position: -4). Mutually exclusive with inputs: complex_out_file, real_out_file, imaginary_out_file, real_cartesian, complex_cartesian, complex_polar, complex_split, complex_merge.

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

  • phase_in_file (a pathlike object or string representing an existing file) – Maps to a command-line argument: %s (position: 3).

  • phase_out_file (a pathlike object or string representing a file) – Maps to a command-line argument: %s (position: -3). Mutually exclusive with inputs: complex_out_file, real_out_file, imaginary_out_file, real_cartesian, complex_cartesian, complex_polar, complex_split, complex_merge.

  • real_cartesian (a boolean) – Maps to a command-line argument: -realcartesian (position: 1). Mutually exclusive with inputs: real_polar, real_cartesian, complex_cartesian, complex_polar, complex_split, complex_merge.

  • real_in_file (a pathlike object or string representing an existing file) – Maps to a command-line argument: %s (position: 2).

  • real_out_file (a pathlike object or string representing a file) – Maps to a command-line argument: %s (position: -4). Mutually exclusive with inputs: complex_out_file, magnitude_out_file, phase_out_file, real_polar, complex_cartesian, complex_polar, complex_split, complex_merge.

  • real_polar (a boolean) – Maps to a command-line argument: -realpolar (position: 1). Mutually exclusive with inputs: real_polar, real_cartesian, complex_cartesian, complex_polar, complex_split, complex_merge.

  • start_vol (an integer) – Maps to a command-line argument: %d (position: -2).

Outputs:
  • complex_out_file (a pathlike object or string representing a file)

  • imaginary_out_file (a pathlike object or string representing a file)

  • magnitude_out_file (a pathlike object or string representing a file)

  • phase_out_file (a pathlike object or string representing a file)

  • real_out_file (a pathlike object or string representing a file)

ConvertWarp

Link to code

Bases: FSLCommand

Wrapped executable: convertwarp.

Use FSL convertwarp for combining multiple transforms into one.

Examples

>>> from nipype.interfaces.fsl import ConvertWarp
>>> warputils = ConvertWarp()
>>> warputils.inputs.warp1 = "warpfield.nii"
>>> warputils.inputs.reference = "T1.nii"
>>> warputils.inputs.relwarp = True
>>> warputils.inputs.output_type = "NIFTI_GZ"
>>> warputils.cmdline 
'convertwarp --ref=T1.nii --rel --warp1=warpfield.nii --out=T1_concatwarp.nii.gz'
>>> res = warputils.run() 
Mandatory Inputs:

reference (a pathlike object or string representing an existing file) – Name of a file in target space of the full transform. Maps to a command-line argument: --ref=%s (position: 1).

Optional Inputs:
  • abswarp (a boolean) – If set it indicates that the warps in –warp1 and –warp2 should be interpreted as absolute. I.e. the values in –warp1/2 are the coordinates in the next space, rather than displacements. This flag is ignored if –warp1/2 was created by fnirt, which always creates relative displacements. Maps to a command-line argument: --abs. Mutually exclusive with inputs: relwarp.

  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • cons_jacobian (a boolean) – Constrain the Jacobian of the warpfield to lie within specified min/max limits. Maps to a command-line argument: --constrainj.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • jacobian_max (a float) – Maximum acceptable Jacobian value for constraint (default 100.0). Maps to a command-line argument: --jmax=%f.

  • jacobian_min (a float) – Minimum acceptable Jacobian value for constraint (default 0.01). Maps to a command-line argument: --jmin=%f.

  • midmat (a pathlike object or string representing an existing file) – Name of file containing mid-warp-affine transform. Maps to a command-line argument: --midmat=%s.

  • out_abswarp (a boolean) – If set it indicates that the warps in –out should be absolute, i.e. the values in –out are displacements from the coordinates in –ref. Maps to a command-line argument: --absout. Mutually exclusive with inputs: out_relwarp.

  • out_file (a pathlike object or string representing a file) – Name of output file, containing warps that are the combination of all those given as arguments. The format of this will be a field-file (rather than spline coefficients) with any affine components included. Maps to a command-line argument: --out=%s (position: -1).

  • out_relwarp (a boolean) – If set it indicates that the warps in –out should be relative, i.e. the values in –out are displacements from the coordinates in –ref. Maps to a command-line argument: --relout. Mutually exclusive with inputs: out_abswarp.

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

  • postmat (a pathlike object or string representing an existing file) – Name of file containing an affine transform (applied last). It could e.g. be an affine transform that maps the MNI152-space into a better approximation to the Talairach-space (if indeed there is one). Maps to a command-line argument: --postmat=%s.

  • premat (a pathlike object or string representing an existing file) – Filename for pre-transform (affine matrix). Maps to a command-line argument: --premat=%s.

  • relwarp (a boolean) – If set it indicates that the warps in –warp1/2 should be interpreted as relative. I.e. the values in –warp1/2 are displacements from the coordinates in the next space. Maps to a command-line argument: --rel. Mutually exclusive with inputs: abswarp.

  • shift_direction (‘y-’ or ‘y’ or ‘x’ or ‘x-’ or ‘z’ or ‘z-’) – Indicates the direction that the distortions from –shiftmap goes. It depends on the direction and polarity of the phase-encoding in the EPI sequence. Maps to a command-line argument: --shiftdir=%s. Requires inputs: shift_in_file.

  • shift_in_file (a pathlike object or string representing an existing file) – Name of file containing a “shiftmap”, a non-linear transform with displacements only in one direction (applied first, before premat). This would typically be a fieldmap that has been pre-processed using fugue that maps a subjects functional (EPI) data onto an undistorted space (i.e. a space that corresponds to his/her true anatomy). Maps to a command-line argument: --shiftmap=%s.

  • warp1 (a pathlike object or string representing an existing file) – Name of file containing initial warp-fields/coefficients (follows premat). This could e.g. be a fnirt-transform from a subjects structural scan to an average of a group of subjects. Maps to a command-line argument: --warp1=%s.

  • warp2 (a pathlike object or string representing an existing file) – Name of file containing secondary warp-fields/coefficients (after warp1/midmat but before postmat). This could e.g. be a fnirt-transform from the average of a group of subjects to some standard space (e.g. MNI152). Maps to a command-line argument: --warp2=%s.

Outputs:

out_file (a pathlike object or string representing an existing file) – Name of output file, containing the warp as field or coefficients.

ConvertXFM

Link to code

Bases: FSLCommand

Wrapped executable: convert_xfm.

Use the FSL utility convert_xfm to modify FLIRT transformation matrices.

Examples

>>> import nipype.interfaces.fsl as fsl
>>> invt = fsl.ConvertXFM()
>>> invt.inputs.in_file = "flirt.mat"
>>> invt.inputs.invert_xfm = True
>>> invt.inputs.out_file = 'flirt_inv.mat'
>>> invt.cmdline
'convert_xfm -omat flirt_inv.mat -inverse flirt.mat'
Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – Input transformation matrix. Maps to a command-line argument: %s (position: -1).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • concat_xfm (a boolean) – Write joint transformation of two input matrices. Maps to a command-line argument: -concat (position: -3). Mutually exclusive with inputs: invert_xfm, concat_xfm, fix_scale_skew. Requires inputs: in_file2.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • fix_scale_skew (a boolean) – Use secondary matrix to fix scale and skew. Maps to a command-line argument: -fixscaleskew (position: -3). Mutually exclusive with inputs: invert_xfm, concat_xfm, fix_scale_skew. Requires inputs: in_file2.

  • in_file2 (a pathlike object or string representing an existing file) – Second input matrix (for use with fix_scale_skew or concat_xfm). Maps to a command-line argument: %s (position: -2).

  • invert_xfm (a boolean) – Invert input transformation. Maps to a command-line argument: -inverse (position: -3). Mutually exclusive with inputs: invert_xfm, concat_xfm, fix_scale_skew.

  • out_file (a pathlike object or string representing a file) – Final transformation matrix. Maps to a command-line argument: -omat %s (position: 1).

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

Outputs:

out_file (a pathlike object or string representing an existing file) – Output transformation matrix.

CopyGeom

Link to code

Bases: FSLCommand

Wrapped executable: fslcpgeom.

Use fslcpgeom to copy the header geometry information to another image. Copy certain parts of the header information (image dimensions, voxel dimensions, voxel dimensions units string, image orientation/origin or qform/sform info) from one image to another. Note that only copies from Analyze to Analyze or Nifti to Nifti will work properly. Copying from different files will result in loss of information or potentially incorrect settings.

Mandatory Inputs:
  • dest_file (a pathlike object or string representing an existing file) – Destination image. Maps to a command-line argument: %s (position: 1).

  • in_file (a pathlike object or string representing an existing file) – Source image. Maps to a command-line argument: %s (position: 0).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • ignore_dims (a boolean) – Do not copy image dimensions. Maps to a command-line argument: -d (position: -1).

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

Outputs:

out_file (a pathlike object or string representing an existing file) – Image with new geometry header.

ExtractROI

Link to code

Bases: FSLCommand

Wrapped executable: fslroi.

Uses FSL Fslroi command to extract region of interest (ROI) from an image.

You can a) take a 3D ROI from a 3D data set (or if it is 4D, the same ROI is taken from each time point and a new 4D data set is created), b) extract just some time points from a 4D data set, or c) control time and space limits to the ROI. Note that the arguments are minimum index and size (not maximum index). So to extract voxels 10 to 12 inclusive you would specify 10 and 3 (not 10 and 12).

Examples

>>> from nipype.interfaces.fsl import ExtractROI
>>> from nipype.testing import anatfile
>>> fslroi = ExtractROI(in_file=anatfile, roi_file='bar.nii', t_min=0,
...                     t_size=1)
>>> fslroi.cmdline == 'fslroi %s bar.nii 0 1' % anatfile
True
Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – Input file. Maps to a command-line argument: %s (position: 0).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • crop_list (a list of items which are a tuple of the form: (an integer, an integer)) – List of two tuples specifying crop options. Maps to a command-line argument: %s (position: 2). Mutually exclusive with inputs: x_min, x_size, y_min, y_size, z_min, z_size, t_min, t_size.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

  • roi_file (a pathlike object or string representing a file) – Output file. Maps to a command-line argument: %s (position: 1).

  • t_min (an integer) – Maps to a command-line argument: %d (position: 8).

  • t_size (an integer) – Maps to a command-line argument: %d (position: 9).

  • x_min (an integer) – Maps to a command-line argument: %d (position: 2).

  • x_size (an integer) – Maps to a command-line argument: %d (position: 3).

  • y_min (an integer) – Maps to a command-line argument: %d (position: 4).

  • y_size (an integer) – Maps to a command-line argument: %d (position: 5).

  • z_min (an integer) – Maps to a command-line argument: %d (position: 6).

  • z_size (an integer) – Maps to a command-line argument: %d (position: 7).

Outputs:

roi_file (a pathlike object or string representing an existing file)

FilterRegressor

Link to code

Bases: FSLCommand

Wrapped executable: fsl_regfilt.

Data de-noising by regressing out part of a design matrix

Uses simple OLS regression on 4D images

Mandatory Inputs:
  • design_file (a pathlike object or string representing an existing file) – Name of the matrix with time courses (e.g. GLM design or MELODIC mixing matrix). Maps to a command-line argument: -d %s (position: 3).

  • filter_all (a boolean) – Use all columns in the design file in denoising. Maps to a command-line argument: -f '%s' (position: 4). Mutually exclusive with inputs: filter_columns.

  • filter_columns (a list of items which are an integer) – (1-based) column indices to filter out of the data. Maps to a command-line argument: -f '%s' (position: 4). Mutually exclusive with inputs: filter_all.

  • in_file (a pathlike object or string representing an existing file) – Input file name (4D image). Maps to a command-line argument: -i %s (position: 1).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • mask (a pathlike object or string representing an existing file) – Mask image file name. Maps to a command-line argument: -m %s.

  • out_file (a pathlike object or string representing a file) – Output file name for the filtered data. Maps to a command-line argument: -o %s (position: 2).

  • out_vnscales (a boolean) – Output scaling factors for variance normalization. Maps to a command-line argument: --out_vnscales.

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

  • var_norm (a boolean) – Perform variance-normalization on data. Maps to a command-line argument: --vn.

Outputs:

out_file (a pathlike object or string representing an existing file) – Output file name for the filtered data.

ImageMaths

Link to code

Bases: FSLCommand

Wrapped executable: fslmaths.

Use FSL fslmaths command to allow mathematical manipulation of images FSL info

Examples

>>> from nipype.interfaces import fsl
>>> from nipype.testing import anatfile
>>> maths = fsl.ImageMaths(in_file=anatfile, op_string= '-add 5',
...                        out_file='foo_maths.nii')
>>> maths.cmdline == 'fslmaths %s -add 5 foo_maths.nii' % anatfile
True
Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – Maps to a command-line argument: %s (position: 1).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • in_file2 (a pathlike object or string representing an existing file) – Maps to a command-line argument: %s (position: 3).

  • mask_file (a pathlike object or string representing an existing file) – Use (following image>0) to mask current image. Maps to a command-line argument: -mas %s.

  • op_string (a string) – String defining the operation, i. e. -add. Maps to a command-line argument: %s (position: 2).

  • out_data_type (‘char’ or ‘short’ or ‘int’ or ‘float’ or ‘double’ or ‘input’) – Output datatype, one of (char, short, int, float, double, input). Maps to a command-line argument: -odt %s (position: -1).

  • out_file (a pathlike object or string representing a file) – Maps to a command-line argument: %s (position: -2).

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

  • suffix (a string) – Out_file suffix.

Outputs:

out_file (a pathlike object or string representing an existing file)

ImageMeants

Link to code

Bases: FSLCommand

Wrapped executable: fslmeants.

Use fslmeants for printing the average timeseries (intensities) to the screen (or saves to a file). The average is taken over all voxels in the mask (or all voxels in the image if no mask is specified)

Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – Input file for computing the average timeseries. Maps to a command-line argument: -i %s (position: 0).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • eig (a boolean) – Calculate Eigenvariate(s) instead of mean (output will have 0 mean). Maps to a command-line argument: --eig.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • mask (a pathlike object or string representing an existing file) – Input 3D mask. Maps to a command-line argument: -m %s.

  • nobin (a boolean) – Do not binarise the mask for calculation of Eigenvariates. Maps to a command-line argument: --no_bin.

  • order (an integer) – Select number of Eigenvariates. Maps to a command-line argument: --order=%d. (Nipype default value: 1)

  • out_file (a pathlike object or string representing a file) – Name of output text matrix. Maps to a command-line argument: -o %s.

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

  • show_all (a boolean) – Show all voxel time series (within mask) instead of averaging. Maps to a command-line argument: --showall.

  • spatial_coord (a list of items which are an integer) – <x y z> requested spatial coordinate (instead of mask). Maps to a command-line argument: -c %s.

  • transpose (a boolean) – Output results in transpose format (one row per voxel/mean). Maps to a command-line argument: --transpose.

  • use_mm (a boolean) – Use mm instead of voxel coordinates (for -c option). Maps to a command-line argument: --usemm.

Outputs:

out_file (a pathlike object or string representing an existing file) – Path/name of output text matrix.

ImageStats

Link to code

Bases: FSLCommand

Wrapped executable: fslstats.

Use FSL fslstats command to calculate stats from images FSL info

Examples

>>> from nipype.interfaces.fsl import ImageStats
>>> from nipype.testing import funcfile
>>> stats = ImageStats(in_file=funcfile, op_string= '-M')
>>> stats.cmdline == 'fslstats %s -M'%funcfile
True
Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Input file to generate stats of. Maps to a command-line argument: %s (position: 3).

  • op_string (a string) – String defining the operation, options are applied in order, e.g. -M -l 10 -M will report the non-zero mean, apply a threshold and then report the new nonzero mean. Maps to a command-line argument: %s (position: 4).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • index_mask_file (a pathlike object or string representing an existing file) – Generate separate n submasks from indexMask, for indexvalues 1..n where n is the maximum index value in indexMask, and generate statistics for each submask. Maps to a command-line argument: -K %s (position: 2).

  • mask_file (a pathlike object or string representing an existing file) – Mask file used for option -k %s.

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

  • split_4d (a boolean) – Give a separate output line for each 3D volume of a 4D timeseries. Maps to a command-line argument: -t (position: 1).

Outputs:

out_stat (any value) – Stats output.

ImageStats.aggregate_outputs(runtime=None, needed_outputs=None)

Collate expected outputs and apply output traits validation.

InvWarp

Link to code

Bases: FSLCommand

Wrapped executable: invwarp.

Use FSL Invwarp to invert a FNIRT warp

Examples

>>> from nipype.interfaces.fsl import InvWarp
>>> invwarp = InvWarp()
>>> invwarp.inputs.warp = "struct2mni.nii"
>>> invwarp.inputs.reference = "anatomical.nii"
>>> invwarp.inputs.output_type = "NIFTI_GZ"
>>> invwarp.cmdline
'invwarp --out=struct2mni_inverse.nii.gz --ref=anatomical.nii --warp=struct2mni.nii'
>>> res = invwarp.run() 
Mandatory Inputs:
  • reference (a pathlike object or string representing an existing file) – Name of a file in target space. Note that the target space is now different from the target space that was used to create the –warp file. It would typically be the file that was specified with the –in argument when running fnirt. Maps to a command-line argument: --ref=%s.

  • warp (a pathlike object or string representing an existing file) – Name of file containing warp-coefficients/fields. This would typically be the output from the –cout switch of fnirt (but can also use fields, like the output from –fout). Maps to a command-line argument: --warp=%s.

Optional Inputs:
  • absolute (a boolean) – If set it indicates that the warps in –warp should be interpreted as absolute, provided that it is not created by fnirt (which always uses relative warps). If set it also indicates that the output –out should be absolute. Maps to a command-line argument: --abs. Mutually exclusive with inputs: relative.

  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • inverse_warp (a pathlike object or string representing a file) – Name of output file, containing warps that are the “reverse” of those in –warp. This will be a field-file (rather than a file of spline coefficients), and it will have any affine component included as part of the displacements. Maps to a command-line argument: --out=%s.

  • jacobian_max (a float) – Maximum acceptable Jacobian value for constraint (default 100.0). Maps to a command-line argument: --jmax=%f.

  • jacobian_min (a float) – Minimum acceptable Jacobian value for constraint (default 0.01). Maps to a command-line argument: --jmin=%f.

  • niter (an integer) – Determines how many iterations of the gradient-descent search that should be run. Maps to a command-line argument: --niter=%d.

  • noconstraint (a boolean) – Do not apply Jacobian constraint. Maps to a command-line argument: --noconstraint.

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

  • regularise (a float) – Regularization strength (default=1.0). Maps to a command-line argument: --regularise=%f.

  • relative (a boolean) – If set it indicates that the warps in –warp should be interpreted as relative. I.e. the values in –warp are displacements from the coordinates in the –ref space. If set it also indicates that the output –out should be relative. Maps to a command-line argument: --rel. Mutually exclusive with inputs: absolute.

Outputs:

inverse_warp (a pathlike object or string representing an existing file) – Name of output file, containing warps that are the “reverse” of those in –warp.

Merge

Link to code

Bases: FSLCommand

Wrapped executable: fslmerge.

Use fslmerge to concatenate images

Images can be concatenated across time, x, y, or z dimensions. Across the time (t) dimension the TR is set by default to 1 sec.

Note: to set the TR to a different value, specify ‘t’ for dimension and specify the TR value in seconds for the tr input. The dimension will be automatically updated to ‘tr’.

Examples

>>> from nipype.interfaces.fsl import Merge
>>> merger = Merge()
>>> merger.inputs.in_files = ['functional2.nii', 'functional3.nii']
>>> merger.inputs.dimension = 't'
>>> merger.inputs.output_type = 'NIFTI_GZ'
>>> merger.cmdline
'fslmerge -t functional2_merged.nii.gz functional2.nii functional3.nii'
>>> merger.inputs.tr = 2.25
>>> merger.cmdline
'fslmerge -tr functional2_merged.nii.gz functional2.nii functional3.nii 2.25'
Mandatory Inputs:
  • dimension (‘t’ or ‘x’ or ‘y’ or ‘z’ or ‘a’) – Dimension along which to merge, optionally set tr input when dimension is t. Maps to a command-line argument: -%s (position: 0).

  • in_files (a list of items which are a pathlike object or string representing an existing file) – Maps to a command-line argument: %s (position: 2).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • merged_file (a pathlike object or string representing a file) – Maps to a command-line argument: %s (position: 1).

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

  • tr (a float) – Use to specify TR in seconds (default is 1.00 sec), overrides dimension and sets it to tr. Maps to a command-line argument: %.2f (position: -1).

Outputs:

merged_file (a pathlike object or string representing an existing file)

MotionOutliers

Link to code

Bases: FSLCommand

Wrapped executable: fsl_motion_outliers.

Use FSL fsl_motion_outliers`http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FSLMotionOutliers`_ to find outliers in timeseries (4d) data. .. rubric:: Examples

>>> from nipype.interfaces.fsl import MotionOutliers
>>> mo = MotionOutliers()
>>> mo.inputs.in_file = "epi.nii"
>>> mo.cmdline 
'fsl_motion_outliers -i epi.nii -o epi_outliers.txt -p epi_metrics.png -s epi_metrics.txt'
>>> res = mo.run() 
Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – Unfiltered 4D image. Maps to a command-line argument: -i %s.

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • dummy (an integer) – Number of dummy scans to delete (before running anything and creating EVs). Maps to a command-line argument: --dummy=%d.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • mask (a pathlike object or string representing an existing file) – Mask image for calculating metric. Maps to a command-line argument: -m %s.

  • metric (‘refrms’ or ‘dvars’ or ‘refmse’ or ‘fd’ or ‘fdrms’) – Metrics: refrms - RMS intensity difference to reference volume as metric [default metric], refmse - Mean Square Error version of refrms (used in original version of fsl_motion_outliers), dvars - DVARS, fd - frame displacement, fdrms - FD with RMS matrix calculation. Maps to a command-line argument: --%s.

  • no_motion_correction (a boolean) – Do not run motion correction (assumed already done). Maps to a command-line argument: --nomoco.

  • out_file (a pathlike object or string representing a file) – Output outlier file name. Maps to a command-line argument: -o %s.

  • out_metric_plot (a pathlike object or string representing a file) – Output metric values plot (DVARS etc.) file name. Maps to a command-line argument: -p %s.

  • out_metric_values (a pathlike object or string representing a file) – Output metric values (DVARS etc.) file name. Maps to a command-line argument: -s %s.

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

  • threshold (a float) – Specify absolute threshold value (otherwise use box-plot cutoff = P75 + 1.5*IQR). Maps to a command-line argument: --thresh=%g.

Outputs:
  • out_file (a pathlike object or string representing an existing file)

  • out_metric_plot (a pathlike object or string representing an existing file)

  • out_metric_values (a pathlike object or string representing an existing file)

Overlay

Link to code

Bases: FSLCommand

Wrapped executable: overlay.

Use FSL’s overlay command to combine background and statistical images

into one volume

Examples

>>> from nipype.interfaces import fsl
>>> combine = fsl.Overlay()
>>> combine.inputs.background_image = 'mean_func.nii.gz'
>>> combine.inputs.auto_thresh_bg = True
>>> combine.inputs.stat_image = 'zstat1.nii.gz'
>>> combine.inputs.stat_thresh = (3.5, 10)
>>> combine.inputs.show_negative_stats = True
>>> res = combine.run() 
Mandatory Inputs:
  • auto_thresh_bg (a boolean) – Automatically threshold the background image. Maps to a command-line argument: -a (position: 5). Mutually exclusive with inputs: auto_thresh_bg, full_bg_range, bg_thresh.

  • background_image (a pathlike object or string representing an existing file) – Image to use as background. Maps to a command-line argument: %s (position: 4).

  • bg_thresh (a tuple of the form: (a float, a float)) – Min and max values for background intensity. Maps to a command-line argument: %.3f %.3f (position: 5). Mutually exclusive with inputs: auto_thresh_bg, full_bg_range, bg_thresh.

  • full_bg_range (a boolean) – Use full range of background image. Maps to a command-line argument: -A (position: 5). Mutually exclusive with inputs: auto_thresh_bg, full_bg_range, bg_thresh.

  • stat_image (a pathlike object or string representing an existing file) – Statistical image to overlay in color. Maps to a command-line argument: %s (position: 6).

  • stat_thresh (a tuple of the form: (a float, a float)) – Min and max values for the statistical overlay. Maps to a command-line argument: %.2f %.2f (position: 7).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • out_file (a pathlike object or string representing a file) – Combined image volume. Maps to a command-line argument: %s (position: -1).

  • out_type (‘float’ or ‘int’) – Write output with float or int. Maps to a command-line argument: %s (position: 2). (Nipype default value: float)

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

  • show_negative_stats (a boolean) – Display negative statistics in overlay. Maps to a command-line argument: %s (position: 8). Mutually exclusive with inputs: stat_image2.

  • stat_image2 (a pathlike object or string representing an existing file) – Second statistical image to overlay in color. Maps to a command-line argument: %s (position: 9). Mutually exclusive with inputs: show_negative_stats.

  • stat_thresh2 (a tuple of the form: (a float, a float)) – Min and max values for second statistical overlay. Maps to a command-line argument: %.2f %.2f (position: 10).

  • transparency (a boolean) – Make overlay colors semi-transparent. Maps to a command-line argument: %s (position: 1). (Nipype default value: True)

  • use_checkerboard (a boolean) – Use checkerboard mask for overlay. Maps to a command-line argument: -c (position: 3).

Outputs:

out_file (a pathlike object or string representing an existing file) – Combined image volume.

PlotMotionParams

Link to code

Bases: FSLCommand

Wrapped executable: fsl_tsplot.

Use fsl_tsplot to plot the estimated motion parameters from a realignment program.

Examples

>>> import nipype.interfaces.fsl as fsl
>>> plotter = fsl.PlotMotionParams()
>>> plotter.inputs.in_file = 'functional.par'
>>> plotter.inputs.in_source = 'fsl'
>>> plotter.inputs.plot_type = 'rotations'
>>> res = plotter.run() 

Notes

The ‘in_source’ attribute determines the order of columns that are expected in the source file. FSL prints motion parameters in the order rotations, translations, while SPM prints them in the opposite order. This interface should be able to plot timecourses of motion parameters generated from other sources as long as they fall under one of these two patterns. For more flexibility, see the fsl.PlotTimeSeries interface.

Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file or a list of items which are a pathlike object or string representing an existing file) – File with motion parameters. Maps to a command-line argument: %s (position: 1).

  • in_source (‘spm’ or ‘fsl’) – Which program generated the motion parameter file - fsl, spm.

  • plot_type (‘rotations’ or ‘translations’ or ‘displacement’) – Which motion type to plot - rotations, translations, displacement. Maps to a command-line argument: %s.

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • out_file (a pathlike object or string representing a file) – Image to write. Maps to a command-line argument: -o %s.

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

  • plot_size (a tuple of the form: (an integer, an integer)) – Plot image height and width. Maps to a command-line argument: %s.

Outputs:

out_file (a pathlike object or string representing an existing file) – Image to write.

PlotTimeSeries

Link to code

Bases: FSLCommand

Wrapped executable: fsl_tsplot.

Use fsl_tsplot to create images of time course plots.

Examples

>>> import nipype.interfaces.fsl as fsl
>>> plotter = fsl.PlotTimeSeries()
>>> plotter.inputs.in_file = 'functional.par'
>>> plotter.inputs.title = 'Functional timeseries'
>>> plotter.inputs.labels = ['run1', 'run2']
>>> plotter.run() 
Mandatory Inputs:

in_file (a pathlike object or string representing an existing file or a list of items which are a pathlike object or string representing an existing file) – File or list of files with columns of timecourse information. Maps to a command-line argument: %s (position: 1).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • labels (a string or a list of items which are a string) – Label or list of labels. Maps to a command-line argument: %s.

  • legend_file (a pathlike object or string representing an existing file) – Legend file. Maps to a command-line argument: --legend=%s.

  • out_file (a pathlike object or string representing a file) – Image to write. Maps to a command-line argument: -o %s.

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

  • plot_finish (an integer) – Final column from in-file to plot. Maps to a command-line argument: --finish=%d. Mutually exclusive with inputs: plot_range.

  • plot_range (a tuple of the form: (an integer, an integer)) – First and last columns from the in-file to plot. Maps to a command-line argument: %s. Mutually exclusive with inputs: plot_start, plot_finish.

  • plot_size (a tuple of the form: (an integer, an integer)) – Plot image height and width. Maps to a command-line argument: %s.

  • plot_start (an integer) – First column from in-file to plot. Maps to a command-line argument: --start=%d. Mutually exclusive with inputs: plot_range.

  • sci_notation (a boolean) – Switch on scientific notation. Maps to a command-line argument: --sci.

  • title (a string) – Plot title. Maps to a command-line argument: %s.

  • x_precision (an integer) – Precision of x-axis labels. Maps to a command-line argument: --precision=%d.

  • x_units (an integer) – Scaling units for x-axis (between 1 and length of in file). Maps to a command-line argument: -u %d. (Nipype default value: 1)

  • y_max (a float) – Maximum y value. Maps to a command-line argument: --ymax=%.2f. Mutually exclusive with inputs: y_range.

  • y_min (a float) – Minimum y value. Maps to a command-line argument: --ymin=%.2f. Mutually exclusive with inputs: y_range.

  • y_range (a tuple of the form: (a float, a float)) – Min and max y axis values. Maps to a command-line argument: %s. Mutually exclusive with inputs: y_min, y_max.

Outputs:

out_file (a pathlike object or string representing an existing file) – Image to write.

PowerSpectrum

Link to code

Bases: FSLCommand

Wrapped executable: fslpspec.

Use FSL PowerSpectrum command for power spectrum estimation.

Examples

>>> from nipype.interfaces import fsl
>>> pspec = fsl.PowerSpectrum()
>>> pspec.inputs.in_file = 'functional.nii'
>>> res = pspec.run() 
Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – Input 4D file to estimate the power spectrum. Maps to a command-line argument: %s (position: 0).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • out_file (a pathlike object or string representing a file) – Name of output 4D file for power spectrum. Maps to a command-line argument: %s (position: 1).

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

Outputs:

out_file (a pathlike object or string representing an existing file) – Path/name of the output 4D power spectrum file.

Reorient2Std

Link to code

Bases: FSLCommand

Wrapped executable: fslreorient2std.

fslreorient2std is a tool for reorienting the image to match the approximate orientation of the standard template images (MNI152).

Examples

>>> reorient = Reorient2Std()
>>> reorient.inputs.in_file = "functional.nii"
>>> res = reorient.run() 
Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – Maps to a command-line argument: %s.

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • out_file (a pathlike object or string representing a file) – Maps to a command-line argument: %s.

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

Outputs:

out_file (a pathlike object or string representing an existing file)

RobustFOV

Link to code

Bases: FSLCommand

Wrapped executable: robustfov.

Automatically crops an image removing lower head and neck.

Interface is stable 5.0.0 to 5.0.9, but default brainsize changed from 150mm to 170mm.

Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – Input filename. Maps to a command-line argument: -i %s (position: 0).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • brainsize (an integer) – Size of brain in z-dimension (default 170mm/150mm). Maps to a command-line argument: -b %d.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • out_roi (a pathlike object or string representing a file) – ROI volume output name. Maps to a command-line argument: -r %s.

  • out_transform (a pathlike object or string representing a file) – Transformation matrix in_file to out_roi output name. Maps to a command-line argument: -m %s.

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

Outputs:
  • out_roi (a pathlike object or string representing an existing file) – ROI volume output name.

  • out_transform (a pathlike object or string representing an existing file) – Transformation matrix in_file to out_roi output name.

SigLoss

Link to code

Bases: FSLCommand

Wrapped executable: sigloss.

Estimates signal loss from a field map (in rad/s)

Examples

>>> sigloss = SigLoss()
>>> sigloss.inputs.in_file = "phase.nii"
>>> sigloss.inputs.echo_time = 0.03
>>> res = sigloss.run() 
Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – B0 fieldmap file. Maps to a command-line argument: -i %s.

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • echo_time (a float) – Echo time in seconds. Maps to a command-line argument: --te=%f.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • mask_file (a pathlike object or string representing an existing file) – Brain mask file. Maps to a command-line argument: -m %s.

  • out_file (a pathlike object or string representing a file) – Output signal loss estimate file. Maps to a command-line argument: -s %s.

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

  • slice_direction (‘x’ or ‘y’ or ‘z’) – Slicing direction. Maps to a command-line argument: -d %s.

Outputs:

out_file (a pathlike object or string representing an existing file) – Signal loss estimate file.

Slice

Link to code

Bases: FSLCommand

Wrapped executable: fslslice.

Use fslslice to split a 3D file into lots of 2D files (along z-axis).

Examples

>>> from nipype.interfaces.fsl import Slice
>>> slice = Slice()
>>> slice.inputs.in_file = 'functional.nii'
>>> slice.inputs.out_base_name = 'sl'
>>> slice.cmdline
'fslslice functional.nii sl'
Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – Input filename. Maps to a command-line argument: %s (position: 0).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • out_base_name (a string) – Outputs prefix. Maps to a command-line argument: %s (position: 1).

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

Outputs:

out_files (a list of items which are a pathlike object or string representing an existing file)

Slicer

Link to code

Bases: FSLCommand

Wrapped executable: slicer.

Use FSL’s slicer command to output a png image from a volume.

Examples

>>> from nipype.interfaces import fsl
>>> from nipype.testing import example_data
>>> slice = fsl.Slicer()
>>> slice.inputs.in_file = example_data('functional.nii')
>>> slice.inputs.all_axial = True
>>> slice.inputs.image_width = 750
>>> res = slice.run() 
Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – Input volume. Maps to a command-line argument: %s (position: 1).

Optional Inputs:
  • all_axial (a boolean) – Output all axial slices into one picture. Maps to a command-line argument: -A (position: 10). Mutually exclusive with inputs: single_slice, middle_slices, all_axial, sample_axial. Requires inputs: image_width.

  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • colour_map (a pathlike object or string representing an existing file) – Use different colour map from that stored in nifti header. Maps to a command-line argument: -l %s (position: 4).

  • dither_edges (a boolean) – Produce semi-transparent (dithered) edges. Maps to a command-line argument: -t (position: 7).

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • image_edges (a pathlike object or string representing an existing file) – Volume to display edge overlay for (useful for checking registration. Maps to a command-line argument: %s (position: 2).

  • image_width (an integer) – Max picture width. Maps to a command-line argument: %d (position: -2).

  • intensity_range (a tuple of the form: (a float, a float)) – Min and max intensities to display. Maps to a command-line argument: -i %.3f %.3f (position: 5).

  • label_slices (a boolean) – Display slice number. Maps to a command-line argument: -L (position: 3). (Nipype default value: True)

  • middle_slices (a boolean) – Output picture of mid-sagittal, axial, and coronal slices. Maps to a command-line argument: -a (position: 10). Mutually exclusive with inputs: single_slice, middle_slices, all_axial, sample_axial.

  • nearest_neighbour (a boolean) – Use nearest neighbor interpolation for output. Maps to a command-line argument: -n (position: 8).

  • out_file (a pathlike object or string representing a file) – Picture to write. Maps to a command-line argument: %s (position: -1).

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

  • sample_axial (an integer) – Output every n axial slices into one picture. Maps to a command-line argument: -S %d (position: 10). Mutually exclusive with inputs: single_slice, middle_slices, all_axial, sample_axial. Requires inputs: image_width.

  • scaling (a float) – Image scale. Maps to a command-line argument: -s %f (position: 0).

  • show_orientation (a boolean) – Label left-right orientation. Maps to a command-line argument: %s (position: 9). (Nipype default value: True)

  • single_slice (‘x’ or ‘y’ or ‘z’) – Output picture of single slice in the x, y, or z plane. Maps to a command-line argument: -%s (position: 10). Mutually exclusive with inputs: single_slice, middle_slices, all_axial, sample_axial. Requires inputs: slice_number.

  • slice_number (an integer) – Slice number to save in picture. Maps to a command-line argument: -%d (position: 11).

  • threshold_edges (a float) – Use threshold for edges. Maps to a command-line argument: -e %.3f (position: 6).

Outputs:

out_file (a pathlike object or string representing an existing file) – Picture to write.

Smooth

Link to code

Bases: FSLCommand

Wrapped executable: fslmaths.

Use fslmaths to smooth the image

Examples

Setting the kernel width using sigma:

>>> sm = Smooth()
>>> sm.inputs.output_type = 'NIFTI_GZ'
>>> sm.inputs.in_file = 'functional2.nii'
>>> sm.inputs.sigma = 8.0
>>> sm.cmdline 
'fslmaths functional2.nii -kernel gauss 8.000 -fmean functional2_smooth.nii.gz'

Setting the kernel width using fwhm:

>>> sm = Smooth()
>>> sm.inputs.output_type = 'NIFTI_GZ'
>>> sm.inputs.in_file = 'functional2.nii'
>>> sm.inputs.fwhm = 8.0
>>> sm.cmdline 
'fslmaths functional2.nii -kernel gauss 3.397 -fmean functional2_smooth.nii.gz'

One of sigma or fwhm must be set:

>>> from nipype.interfaces.fsl import Smooth
>>> sm = Smooth()
>>> sm.inputs.output_type = 'NIFTI_GZ'
>>> sm.inputs.in_file = 'functional2.nii'
>>> sm.cmdline 
Traceback (most recent call last):
 ...
ValueError: Smooth requires a value for one of the inputs ...
Mandatory Inputs:
  • fwhm (a float) – Gaussian kernel fwhm, will be converted to sigma in mm (not voxels). Maps to a command-line argument: -kernel gauss %.03f -fmean (position: 1). Mutually exclusive with inputs: sigma.

  • in_file (a pathlike object or string representing an existing file) – Maps to a command-line argument: %s (position: 0).

  • sigma (a float) – Gaussian kernel sigma in mm (not voxels). Maps to a command-line argument: -kernel gauss %.03f -fmean (position: 1). Mutually exclusive with inputs: fwhm.

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

  • smoothed_file (a pathlike object or string representing a file) – Maps to a command-line argument: %s (position: 2).

Outputs:

smoothed_file (a pathlike object or string representing an existing file)

Split

Link to code

Bases: FSLCommand

Wrapped executable: fslsplit.

Uses FSL Fslsplit command to separate a volume into images in time, x, y or z dimension.

Mandatory Inputs:
  • dimension (‘t’ or ‘x’ or ‘y’ or ‘z’) – Dimension along which the file will be split. Maps to a command-line argument: -%s (position: 2).

  • in_file (a pathlike object or string representing an existing file) – Input filename. Maps to a command-line argument: %s (position: 0).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • out_base_name (a string) – Outputs prefix. Maps to a command-line argument: %s (position: 1).

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

Outputs:

out_files (a list of items which are a pathlike object or string representing an existing file)

SwapDimensions

Link to code

Bases: FSLCommand

Wrapped executable: fslswapdim.

Use fslswapdim to alter the orientation of an image.

This interface accepts a three-tuple corresponding to the new orientation. You may either provide dimension ids in the form of (-)x, (-)y, or (-z), or nifti-syle dimension codes (RL, LR, AP, PA, IS, SI).

Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Input image. Maps to a command-line argument: %s (position: 1).

  • new_dims (a tuple of the form: (‘x’ or ‘-x’ or ‘y’ or ‘-y’ or ‘z’ or ‘-z’ or ‘RL’ or ‘LR’ or ‘AP’ or ‘PA’ or ‘IS’ or ‘SI’, ‘x’ or ‘-x’ or ‘y’ or ‘-y’ or ‘z’ or ‘-z’ or ‘RL’ or ‘LR’ or ‘AP’ or ‘PA’ or ‘IS’ or ‘SI’, ‘x’ or ‘-x’ or ‘y’ or ‘-y’ or ‘z’ or ‘-z’ or ‘RL’ or ‘LR’ or ‘AP’ or ‘PA’ or ‘IS’ or ‘SI’)) – 3-tuple of new dimension order. Maps to a command-line argument: %s %s %s.

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • out_file (a pathlike object or string representing a file) – Image to write. Maps to a command-line argument: %s.

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

Outputs:

out_file (a pathlike object or string representing an existing file) – Image with new dimensions.

Text2Vest

Link to code

Bases: FSLCommand

Wrapped executable: Text2Vest.

Use FSL Text2Vest`https://web.mit.edu/fsl_v5.0.10/fsl/doc/wiki/GLM(2f)CreatingDesignMatricesByHand.html`_ to convert your plain text design matrix data into the format used by the FSL tools.

Examples

>>> from nipype.interfaces.fsl import Text2Vest
>>> t2v = Text2Vest()
>>> t2v.inputs.in_file = "design.txt"
>>> t2v.inputs.out_file = "design.mat"
>>> t2v.cmdline
'Text2Vest design.txt design.mat'
>>> res = t2v.run() 
Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Plain text file representing your design, contrast, or f-test matrix. Maps to a command-line argument: %s (position: 0).

  • out_file (a pathlike object or string representing a file) – File name to store matrix data in the format used by FSL tools (e.g., design.mat, design.con design.fts). Maps to a command-line argument: %s (position: 1).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

Outputs:

out_file (a pathlike object or string representing a file) – Matrix data in the format used by FSL tools.

Vest2Text

Link to code

Bases: FSLCommand

Wrapped executable: Vest2Text.

Use FSL Vest2Text`https://web.mit.edu/fsl_v5.0.10/fsl/doc/wiki/GLM(2f)CreatingDesignMatricesByHand.html`_ to convert your design.mat design.con and design.fts files into plain text.

Examples

>>> from nipype.interfaces.fsl import Vest2Text
>>> v2t = Vest2Text()
>>> v2t.inputs.in_file = "design.mat"
>>> v2t.cmdline
'Vest2Text design.mat design.txt'
>>> res = v2t.run() 
Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – Matrix data stored in the format used by FSL tools. Maps to a command-line argument: %s (position: 0).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • out_file (a pathlike object or string representing a file) – File name to store text output from matrix. Maps to a command-line argument: %s (position: 1). (Nipype default value: design.txt)

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

Outputs:

out_file (a pathlike object or string representing a file) – Plain text representation of FSL matrix.

WarpPoints

Link to code

Bases: CommandLine

Wrapped executable: img2imgcoord.

Use FSL img2imgcoord to transform point sets. Accepts plain text files and vtk files.

Note

transformation of TrackVis trk files is not yet implemented

Examples

>>> from nipype.interfaces.fsl import WarpPoints
>>> warppoints = WarpPoints()
>>> warppoints.inputs.in_coords = 'surf.txt'
>>> warppoints.inputs.src_file = 'epi.nii'
>>> warppoints.inputs.dest_file = 'T1.nii'
>>> warppoints.inputs.warp_file = 'warpfield.nii'
>>> warppoints.inputs.coord_mm = True
>>> warppoints.cmdline 
'img2imgcoord -mm -dest T1.nii -src epi.nii -warp warpfield.nii surf.txt'
>>> res = warppoints.run() 
Mandatory Inputs:
  • dest_file (a pathlike object or string representing an existing file) – Filename of destination image. Maps to a command-line argument: -dest %s.

  • in_coords (a pathlike object or string representing an existing file) – Filename of file containing coordinates. Maps to a command-line argument: %s (position: -1).

  • src_file (a pathlike object or string representing an existing file) – Filename of source image. Maps to a command-line argument: -src %s.

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • coord_mm (a boolean) – All coordinates in mm. Maps to a command-line argument: -mm. Mutually exclusive with inputs: coord_vox.

  • coord_vox (a boolean) – All coordinates in voxels - default. Maps to a command-line argument: -vox. Mutually exclusive with inputs: coord_mm.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • out_file (a pathlike object or string representing a file) – Output file name.

  • warp_file (a pathlike object or string representing an existing file) – Filename of warpfield (e.g. intermediate2dest_warp.nii.gz). Maps to a command-line argument: -warp %s. Mutually exclusive with inputs: xfm_file.

  • xfm_file (a pathlike object or string representing an existing file) – Filename of affine transform (e.g. source2dest.mat). Maps to a command-line argument: -xfm %s. Mutually exclusive with inputs: warp_file.

Outputs:

out_file (a pathlike object or string representing an existing file) – Name of output file, containing the warp as field or coefficients.

WarpPointsFromStd

Link to code

Bases: CommandLine

Wrapped executable: std2imgcoord.

Use FSL std2imgcoord to transform point sets to standard space coordinates. Accepts plain text coordinates files.

Examples

>>> from nipype.interfaces.fsl import WarpPointsFromStd
>>> warppoints = WarpPointsFromStd()
>>> warppoints.inputs.in_coords = 'surf.txt'
>>> warppoints.inputs.img_file = 'T1.nii'
>>> warppoints.inputs.std_file = 'mni.nii'
>>> warppoints.inputs.warp_file = 'warpfield.nii'
>>> warppoints.inputs.coord_mm = True
>>> warppoints.cmdline 
'std2imgcoord -mm -img T1.nii -std mni.nii -warp warpfield.nii surf.txt'
>>> res = warppoints.run() 
Mandatory Inputs:
  • img_file (a pathlike object or string representing an existing file) – Filename of a destination image. Maps to a command-line argument: -img %s.

  • in_coords (a pathlike object or string representing an existing file) – Filename of file containing coordinates. Maps to a command-line argument: %s (position: -2).

  • std_file (a pathlike object or string representing an existing file) – Filename of the image in standard space. Maps to a command-line argument: -std %s.

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • coord_mm (a boolean) – All coordinates in mm. Maps to a command-line argument: -mm. Mutually exclusive with inputs: coord_vox.

  • coord_vox (a boolean) – All coordinates in voxels - default. Maps to a command-line argument: -vox. Mutually exclusive with inputs: coord_mm.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • warp_file (a pathlike object or string representing an existing file) – Filename of warpfield (e.g. intermediate2dest_warp.nii.gz). Maps to a command-line argument: -warp %s. Mutually exclusive with inputs: xfm_file.

  • xfm_file (a pathlike object or string representing an existing file) – Filename of affine transform (e.g. source2dest.mat). Maps to a command-line argument: -xfm %s. Mutually exclusive with inputs: warp_file.

Outputs:

out_file (a pathlike object or string representing an existing file) – Name of output file, containing the warp as field or coefficients.

WarpPointsToStd

Link to code

Bases: WarpPoints

Wrapped executable: img2stdcoord.

Use FSL img2stdcoord to transform point sets to standard space coordinates. Accepts plain text files and vtk files.

Note

transformation of TrackVis trk files is not yet implemented

Examples

>>> from nipype.interfaces.fsl import WarpPointsToStd
>>> warppoints = WarpPointsToStd()
>>> warppoints.inputs.in_coords = 'surf.txt'
>>> warppoints.inputs.img_file = 'T1.nii'
>>> warppoints.inputs.std_file = 'mni.nii'
>>> warppoints.inputs.warp_file = 'warpfield.nii'
>>> warppoints.inputs.coord_mm = True
>>> warppoints.cmdline 
'img2stdcoord -mm -img T1.nii -std mni.nii -warp warpfield.nii surf.txt'
>>> res = warppoints.run() 
Mandatory Inputs:
  • img_file (a pathlike object or string representing an existing file) – Filename of input image. Maps to a command-line argument: -img %s.

  • in_coords (a pathlike object or string representing an existing file) – Filename of file containing coordinates. Maps to a command-line argument: %s (position: -1).

  • std_file (a pathlike object or string representing an existing file) – Filename of destination image. Maps to a command-line argument: -std %s.

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • coord_mm (a boolean) – All coordinates in mm. Maps to a command-line argument: -mm. Mutually exclusive with inputs: coord_vox.

  • coord_vox (a boolean) – All coordinates in voxels - default. Maps to a command-line argument: -vox. Mutually exclusive with inputs: coord_mm.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • out_file (a pathlike object or string representing a file) – Output file name.

  • premat_file (a pathlike object or string representing an existing file) – Filename of pre-warp affine transform (e.g. example_func2highres.mat). Maps to a command-line argument: -premat %s.

  • warp_file (a pathlike object or string representing an existing file) – Filename of warpfield (e.g. intermediate2dest_warp.nii.gz). Maps to a command-line argument: -warp %s. Mutually exclusive with inputs: xfm_file.

  • xfm_file (a pathlike object or string representing an existing file) – Filename of affine transform (e.g. source2dest.mat). Maps to a command-line argument: -xfm %s. Mutually exclusive with inputs: warp_file.

Outputs:

out_file (a pathlike object or string representing an existing file) – Name of output file, containing the warp as field or coefficients.

WarpUtils

Link to code

Bases: FSLCommand

Wrapped executable: fnirtfileutils.

Use FSL fnirtfileutils to convert field->coefficients, coefficients->field, coefficients->other_coefficients etc

Examples

>>> from nipype.interfaces.fsl import WarpUtils
>>> warputils = WarpUtils()
>>> warputils.inputs.in_file = "warpfield.nii"
>>> warputils.inputs.reference = "T1.nii"
>>> warputils.inputs.out_format = 'spline'
>>> warputils.inputs.warp_resolution = (10,10,10)
>>> warputils.inputs.output_type = "NIFTI_GZ"
>>> warputils.cmdline 
'fnirtfileutils --in=warpfield.nii --outformat=spline --ref=T1.nii --warpres=10.0000,10.0000,10.0000 --out=warpfield_coeffs.nii.gz'
>>> res = invwarp.run() 
Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Name of file containing warp-coefficients/fields. This would typically be the output from the –cout switch of fnirt (but can also use fields, like the output from –fout). Maps to a command-line argument: --in=%s.

  • reference (a pathlike object or string representing an existing file) – Name of a file in target space. Note that the target space is now different from the target space that was used to create the –warp file. It would typically be the file that was specified with the –in argument when running fnirt. Maps to a command-line argument: --ref=%s.

  • write_jacobian (a boolean) – Switch on –jac flag with automatically generated filename. (Nipype default value: False)

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • knot_space (a tuple of the form: (an integer, an integer, an integer)) – Alternative (to –warpres) specification of the resolution of the output spline-field. Maps to a command-line argument: --knotspace=%d,%d,%d.

  • out_file (a pathlike object or string representing a file) – Name of output file. The format of the output depends on what other parameters are set. The default format is a (4D) field-file. If the –outformat is set to spline the format will be a (4D) file of spline coefficients. Maps to a command-line argument: --out=%s (position: -1).

  • out_format (‘spline’ or ‘field’) – Specifies the output format. If set to field (default) the output will be a (4D) field-file. If set to spline the format will be a (4D) file of spline coefficients. Maps to a command-line argument: --outformat=%s.

  • out_jacobian (a pathlike object or string representing a file) – Specifies that a (3D) file of Jacobian determinants corresponding to –in should be produced and written to filename. Maps to a command-line argument: --jac=%s.

  • output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.

  • warp_resolution (a tuple of the form: (a float, a float, a float)) – Specifies the resolution/knot-spacing of the splines pertaining to the coefficients in the –out file. This parameter is only relevant if –outformat is set to spline. It should be noted that if the –in file has a higher resolution, the resulting coefficients will pertain to the closest (in a least-squares sense) file in the space of fields with the –warpres resolution. It should also be noted that the resolution will always be an integer multiple of the voxel size. Maps to a command-line argument: --warpres=%0.4f,%0.4f,%0.4f.

  • with_affine (a boolean) – Specifies that the affine transform (i.e. that which was specified for the –aff parameter in fnirt) should be included as displacements in the –out file. That can be useful for interfacing with software that cannot decode FSL/fnirt coefficient-files (where the affine transform is stored separately from the displacements). Maps to a command-line argument: --withaff.

Outputs:
  • out_file (a pathlike object or string representing a file) – Name of output file, containing the warp as field or coefficients.

  • out_jacobian (a pathlike object or string representing a file) – Name of output file, containing the map of the determinant of the Jacobian.