cmtklib.interfaces.mrtrix3 module

The MRTrix3 module provides Nipype interfaces for MRTrix3 tools missing in Nipype or modified.

ApplymultipleMRConvert

Link to code

Bases: nipype.interfaces.base.core.BaseInterface

Apply mrconvert tool to multiple images.

Example

>>> import cmtklib.interfaces.mrtrix3 as mrt
>>> mrconvert = mrt.ApplymultipleMRConvert()
>>> mrconvert.inputs.in_files = ['dwi_FA.mif','dwi_MD.mif']
>>> mrconvert.inputs.extension = 'nii'
>>> mrconvert.run()  
extension‘mif’ or ‘nii’ or ‘float’ or ‘char’ or ‘short’ or ‘int’ or ‘long’ or ‘double’

“i.e. Bfloat”. Can be “char”, “short”, “int”, “long”, “float” or “double”. (Nipype default value: mif)

in_filesa list of items which are a pathlike object or string representing an existing file

Files to be registered.

output_datatype‘float32’ or ‘float32le’ or ‘float32be’ or ‘float64’ or ‘float64le’ or ‘float64be’ or ‘int64’ or ‘uint64’ or ‘int64le’ or ‘uint64le’ or ‘int64be’ or ‘uint64be’ or ‘int32’ or ‘uint32’ or ‘int32le’ or ‘uint32le’ or ‘int32be’ or ‘uint32be’ or ‘int16’ or ‘uint16’ or ‘int16le’ or ‘uint16le’ or ‘int16be’ or ‘uint16be’ or ‘cfloat32’ or ‘cfloat32le’ or ‘cfloat32be’ or ‘cfloat64’ or ‘cfloat64le’ or ‘cfloat64be’ or ‘int8’ or ‘uint8’ or ‘bit’

Specify output image data type. Valid choices are: float32, float32le, float32be, float64, float64le, float64be, int64, uint64, int64le, uint64le, int64be, uint64be, int32, uint32, int32le, uint32le, int32be, uint32be, int16, uint16, int16le, uint16le, int16be, uint16be, cfloat32, cfloat32le, cfloat32be, cfloat64, cfloat64le, cfloat64be, int8, uint8, bit. Maps to a command-line argument: -datatype %s (position: 2).

stridea list of from 3 to 4 items which are an integer

Three to four comma-separated numbers specifying the strides of the output data in memory. The actual strides produced will depend on whether the output image format can support it.. Maps to a command-line argument: -stride %s (position: 3).

converted_filesa list of items which are a pathlike object or string representing a file

Output files.

ApplymultipleMRCrop

Link to code

Bases: nipype.interfaces.base.core.BaseInterface

Apply MRCrop to a list of images.

Example

>>> from cmtklib.interfaces.mrtrix3 import ApplymultipleMRCrop
>>> multi_crop = ApplymultipleMRCrop()
>>> multi_crop.inputs.in_files = ['/sub-01_atlas-L2018_desc-scale1_dseg.nii.gz',
>>>                               'sub-01_atlas-L2018_desc-scale2_dseg.nii.gz',
>>>                               'sub-01_atlas-L2018_desc-scale3_dseg.nii.gz',
>>>                               'sub-01_atlas-L2018_desc-scale4_dseg.nii.gz',
>>>                               'sub-01_atlas-L2018_desc-scale5_dseg.nii.gz']
>>> multi_crop.inputs.template_image = 'sub-01_T1w.nii.gz'
>>> multi_crop.run()  

See also

cmtklib.interfaces.mrtrix3.MRCrop

template_imagea pathlike object or string representing an existing file

Template image.

in_filesa list of items which are a pathlike object or string representing an existing file

Files to be cropped.

out_filesa list of items which are a pathlike object or string representing a file

Cropped files.

ApplymultipleMRTransforms

Link to code

Bases: nipype.interfaces.base.core.BaseInterface

Apply MRTransform to a list of images.

Example

>>> from cmtklib.interfaces.mrtrix3 import ApplymultipleMRTransforms
>>> multi_transform = ApplymultipleMRTransforms()
>>> multi_transform.inputs.in_files = ['/sub-01_atlas-L2018_desc-scale1_dseg.nii.gz',
>>>                                    'sub-01_atlas-L2018_desc-scale2_dseg.nii.gz',
>>>                                    'sub-01_atlas-L2018_desc-scale3_dseg.nii.gz',
>>>                                    'sub-01_atlas-L2018_desc-scale4_dseg.nii.gz',
>>>                                    'sub-01_atlas-L2018_desc-scale5_dseg.nii.gz']
>>> multi_transform.inputs.template_image = 'sub-01_T1w.nii.gz'
>>> multi_transform.run()  

See also

cmtklib.interfaces.mrtrix3.MRTransform

template_imagea pathlike object or string representing an existing file

Template image.

in_filesa list of items which are a pathlike object or string representing an existing file

Files to be transformed.

out_filesa list of items which are a pathlike object or string representing a file

Transformed files.

ConstrainedSphericalDeconvolution

Link to code

Bases: nipype.interfaces.base.core.CommandLine

Wrapped executable: dwi2fod.

Perform non-negativity constrained spherical deconvolution using dwi2fod.

Note that this program makes use of implied symmetries in the diffusion profile. First, the fact the signal attenuation profile is real implies that it has conjugate symmetry, i.e. Y(l,-m) = Y(l,m)* (where * denotes the complex conjugate). Second, the diffusion profile should be antipodally symmetric (i.e. S(x) = S(-x)), implying that all odd l components should be zero. Therefore, this program only computes the even elements. Note that the spherical harmonics equations used here differ slightly from those conventionally used, in that the (-1)^m factor has been omitted. This should be taken into account in all subsequent calculations. Each volume in the output image corresponds to a different spherical harmonic component, according to the following convention:

  • [0] Y(0,0)

  • [1] Im {Y(2,2)}

  • [2] Im {Y(2,1)}

  • [3] Y(2,0)

  • [4] Re {Y(2,1)}

  • [5] Re {Y(2,2)}

  • [6] Im {Y(4,4)}

  • [7] Im {Y(4,3)}

Example

>>> import cmtklib.interfaces.mrtrix3 as mrt
>>> csdeconv = mrt.ConstrainedSphericalDeconvolution()
>>> csdeconv.inputs.in_file = 'dwi.mif'
>>> csdeconv.inputs.encoding_file = 'encoding.txt'
>>> csdeconv.run()                                          
algorithm‘csd’

Use CSD algorithm for FOD estimation. Maps to a command-line argument: %s (position: -4).

in_filea pathlike object or string representing an existing file

Diffusion-weighted image. Maps to a command-line argument: %s (position: -3).

response_filea pathlike object or string representing an existing file

The diffusion-weighted signal response function for a single fibre population (see EstimateResponse). Maps to a command-line argument: %s (position: -2).

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

directions_filea pathlike object or string representing an existing file

A text file containing the [ el az ] pairs for the directions: Specify the directions over which to apply the non-negativity constraint (by default, the built-in 300 direction set is used). Maps to a command-line argument: -directions %s (position: -2).

encoding_filea pathlike object or string representing an existing file

Gradient encoding, supplied as a 4xN text file with each line is in the format [ X Y Z b ], where [ X Y Z ] describe the direction of the applied gradient, and b gives the b-value in units (1000 s/mm^2). See FSL2MRTrix. Maps to a command-line argument: -grad %s (position: 1).

environa 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: {})

filter_filea pathlike object or string representing an existing file

A text file containing the filtering coefficients for each even harmonic order.the linear frequency filtering parameters used for the initial linear spherical deconvolution step (default = [ 1 1 1 0 0 ]). Maps to a command-line argument: -filter %s (position: -2).

iterationsan integer

The maximum number of iterations to perform for each voxel (default = 50). Maps to a command-line argument: -niter %s.

lambda_valuea float

The regularisation parameter lambda that controls the strength of the constraint (default = 1.0). Maps to a command-line argument: -norm_lambda %s.

mask_imagea pathlike object or string representing an existing file

Only perform computation within the specified binary brain mask image. Maps to a command-line argument: -mask %s (position: 2).

maximum_harmonic_orderan integer

Set the maximum harmonic order for the output series. By default, the program will use the highest possible lmax given the number of diffusion-weighted images. Maps to a command-line argument: -lmax %s.

out_filenamea pathlike object or string representing a file

Output filename. Maps to a command-line argument: %s (position: -1).

threshold_valuea float

The threshold below which the amplitude of the FOD is assumed to be zero, expressed as a fraction of the mean value of the initial FOD (default = 0.1). Maps to a command-line argument: -threshold %s.

spherical_harmonics_imagea pathlike object or string representing an existing file

Spherical harmonics image.

DWI2Tensor

Link to code

Bases: nipype.interfaces.base.core.CommandLine

Wrapped executable: dwi2tensor.

Converts diffusion-weighted images to tensor images using dwi2tensor.

Example

>>> import cmtklib.interfaces.mrtrix3 as mrt
>>> dwi2tensor = mrt.DWI2Tensor()
>>> dwi2tensor.inputs.in_file = 'dwi.mif'
>>> dwi2tensor.inputs.encoding_file = 'encoding.txt'
>>> dwi2tensor.run()  
in_filea list of items which are any value

Diffusion-weighted images. Maps to a command-line argument: %s (position: -2).

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

debuga boolean

Display debugging messages. Maps to a command-line argument: -debug (position: 1).

encoding_filea pathlike object or string representing a file

Encoding file, , supplied as a 4xN text file with each line is in the format [ X Y Z b ], where [ X Y Z ] describe the direction of the applied gradient, and b gives the b-value in units (1000 s/mm^2). See FSL2MRTrix(). Maps to a command-line argument: -grad %s (position: 2).

environa 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_slice_by_volumea list of from 2 to 2 items which are an integer

Requires two values (i.e. [34 1] for [Slice Volume] Ignores the image slices specified when computing the tensor. Slice here means the z coordinate of the slice to be ignored. Maps to a command-line argument: -ignoreslices %s (position: 2).

ignore_volumesa list of at least 1 items which are an integer

Requires two values (i.e. [2 5 6] for [Volumes] Ignores the image volumes specified when computing the tensor. Maps to a command-line argument: -ignorevolumes %s (position: 2).

in_mask_filea pathlike object or string representing an existing file

Input DWI mask. Maps to a command-line argument: -mask %s (position: -3).

out_filenamea pathlike object or string representing a file

Output tensor filename. Maps to a command-line argument: %s (position: -1).

quieta boolean

Do not display information messages or progress status. Maps to a command-line argument: -quiet (position: 1).

tensora pathlike object or string representing an existing file

Path/name of output diffusion tensor image.

DWIBiasCorrect

Link to code

Bases: nipype.interfaces.base.core.CommandLine

Wrapped executable: dwibiascorrect.

Correct for bias field in diffusion MRI data using the dwibiascorrect tool.

Example

>>> from cmtklib.interfaces.mrtrix3 import DWIBiasCorrect
>>> dwi_biascorr = DWIBiasCorrect()
>>> dwi_biascorr.inputs.in_file = 'sub-01_dwi.nii.gz'
>>> dwi_biascorr.inputs.use_ants = True
>>> dwi_biascorr.run() 
in_filea pathlike object or string representing an existing file

The input image series to be corrected. Maps to a command-line argument: %s (position: -2).

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

debuga boolean

Display debugging messages. Maps to a command-line argument: -debug (position: 5).

environa 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: {})

force_writinga boolean

Force file overwriting. Maps to a command-line argument: -force (position: 4).

maska pathlike object or string representing a file

Manually provide a mask image for bias field estimation (optional). Maps to a command-line argument: -mask %s (position: 2).

out_biasa pathlike object or string representing a file

Output the estimated bias field. Maps to a command-line argument: -bias %s (position: 3).

out_filea pathlike object or string representing a file

The output corrected image series. Maps to a command-line argument: %s (position: -1).

use_antsa boolean

Use ANTS N4 to estimate the inhomogeneity field. Maps to a command-line argument: ants (position: 1). Mutually exclusive with inputs: use_ants, use_fsl.

use_fsla boolean

Use FSL FAST to estimate the inhomogeneity field. Maps to a command-line argument: fsl (position: 1). Mutually exclusive with inputs: use_ants, use_fsl.

out_biasa pathlike object or string representing an existing file

Output estimated bias field.

out_filea pathlike object or string representing an existing file

Output corrected DWI image.

DWIDenoise

Link to code

Bases: nipype.interfaces.base.core.CommandLine

Wrapped executable: dwidenoise.

Denoise diffusion MRI data using the dwidenoise tool.

Example

>>> from cmtklib.interfaces.mrtrix3 import DWIDenoise
>>> dwi_denoise = DWIDenoise()
>>> dwi_denoise.inputs.in_file = 'sub-01_dwi.nii.gz'
>>> dwi_denoise.inputs.out_file = 'sub-01_desc-denoised_dwi.nii.gz'
>>> dwi_denoise.inputs.out_noisemap = 'sub-01_mod-dwi_noisemap.nii.gz'
>>> dwi_denoise.run()  
in_filea pathlike object or string representing an existing file

Input diffusion-weighted image filename. Maps to a command-line argument: %s (position: -2).

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

debuga boolean

Display debugging messages. Maps to a command-line argument: -debug (position: 5).

environa 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: {})

extent_windowa list of from 3 to 3 items which are a float

Three comma-separated numbers giving the window size of the denoising filter. Maps to a command-line argument: -extent %s (position: 2).

force_writinga boolean

Force file overwriting. Maps to a command-line argument: -force (position: 4).

maska pathlike object or string representing a file

Only perform computation within the specified binary brain mask image. (optional). Maps to a command-line argument: -mask %s (position: 1).

out_filea pathlike object or string representing a file

Output denoised DWI image filename. Maps to a command-line argument: %s (position: -1).

out_noisemapa pathlike object or string representing a file

Output noise map filename. Maps to a command-line argument: -noise %s (position: 3).

out_filea pathlike object or string representing an existing file

Output denoised DWI image.

out_noisemapa pathlike object or string representing an existing file

Output noise map (if generated).

Erode

Link to code

Bases: nipype.interfaces.base.core.CommandLine

Wrapped executable: maskfilter.

Erode (or dilates) a mask (i.e. binary) image using the maskfilter tool.

Example

>>> import cmtklib.interfaces.mrtrix3 as mrt
>>> erode = mrt.Erode()
>>> erode.inputs.in_file = 'mask.mif'
>>> erode.run()  
in_filea pathlike object or string representing an existing file

Input mask image to be eroded. Maps to a command-line argument: %s (position: -3).

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

debuga boolean

Display debugging messages. Maps to a command-line argument: -debug (position: 1).

dilatea boolean

Perform dilation rather than erosion. Maps to a command-line argument: -dilate (position: 1).

environa 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: {})

filtertype‘clean’ or ‘connect’ or ‘dilate’ or ‘erode’ or ‘median’

The type of filter to be applied (clean, connect, dilate, erode, median). Maps to a command-line argument: %s (position: -2).

number_of_passesan integer

The number of passes (default: 1). Maps to a command-line argument: -npass %s.

out_filenamea pathlike object or string representing a file

Output image filename. Maps to a command-line argument: %s (position: -1).

quieta boolean

Do not display information messages or progress status. Maps to a command-line argument: -quiet (position: 1).

out_filea pathlike object or string representing an existing file

The output image.

EstimateResponseForSH

Link to code

Bases: nipype.interfaces.base.core.CommandLine

Wrapped executable: dwi2response.

Estimates the fibre response function for use in spherical deconvolution using dwi2response.

Example

>>> import cmtklib.interfaces.mrtrix3 as mrt
>>> estresp = mrt.EstimateResponseForSH()
>>> estresp.inputs.in_file = 'dwi.mif'
>>> estresp.inputs.mask_image = 'dwi_WMProb.mif'
>>> estresp.inputs.encoding_file = 'encoding.txt'
>>> estresp.run()  
encoding_filea pathlike object or string representing an existing file

Gradient encoding, supplied as a 4xN text file with each line is in the format [ X Y Z b ], where [ X Y Z ] describe the direction of the applied gradient, and b gives the b-value in units (1000 s/mm^2). See FSL2MRTrix. Maps to a command-line argument: -grad %s (position: -2).

in_filea pathlike object or string representing an existing file

Diffusion-weighted images. Maps to a command-line argument: %s (position: 2).

mask_imagea pathlike object or string representing an existing file

Only perform computation within the specified binary brain mask image. Maps to a command-line argument: -mask %s (position: -1).

algorithm‘dhollander’ or ‘fa’ or ‘manual’ or ‘msmt_5tt’ or ‘tax’ or ‘tournier’

Select the algorithm to be used to derive the response function; additional details and options become available once an algorithm is nominated. Options are: dhollander, fa, manual, msmt_5tt, tax, tournier. Maps to a command-line argument: %s (position: 1).

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

debuga boolean

Display debugging messages. Maps to a command-line argument: -debug.

environa 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: {})

maximum_harmonic_orderan integer

Set the maximum harmonic order for the output series. By default, the program will use the highest possible lmax given the number of diffusion-weighted images. Maps to a command-line argument: -lmax %s (position: -3).

out_filenamea pathlike object or string representing a file

Output filename. Maps to a command-line argument: %s (position: 3).

quieta boolean

Do not display information messages or progress status. Maps to a command-line argument: -quiet.

responsea pathlike object or string representing an existing file

Spherical harmonics image.

ExtractFSLGrad

Link to code

Bases: nipype.interfaces.base.core.CommandLine

Wrapped executable: mrinfo.

Use mrinfo to extract FSL gradient.

Example

>>> import cmtklib.interfaces.mrtrix3 as mrt
>>> fsl_grad = mrt.ExtractFSLGrad()
>>> fsl_grad.inputs.in_file = 'sub-01_dwi.mif'
>>> fsl_grad.inputs.out_grad_fsl = ['sub-01_dwi.bvecs', 'sub-01_dwi.bvals']
>>> fsl_grad.run()  
in_filea pathlike object or string representing an existing file

Input images to be read. Maps to a command-line argument: %s (position: -2).

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

environa 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_grad_fsla tuple of the form: (a pathlike object or string representing a file, a pathlike object or string representing a file)

Export the DWI gradient table to files in FSL (bvecs / bvals) format. Maps to a command-line argument: -export_grad_fsl %s %s.

out_grad_fsla tuple of the form: (a pathlike object or string representing an existing file, a pathlike object or string representing an existing file)

Outputs [bvecs, bvals] DW gradient scheme (FSL format) if set.

ExtractMRTrixGrad

Link to code

Bases: nipype.interfaces.base.core.CommandLine

Wrapped executable: mrinfo.

Use mrinfo to extract mrtrix gradient text file.

Example

>>> import cmtklib.interfaces.mrtrix3 as mrt
>>> mrtrix_grad = mrt.ExtractMRTrixGrad()
>>> mrtrix_grad.inputs.in_file = 'sub-01_dwi.mif'
>>> mrtrix_grad.inputs.out_grad_mrtrix = 'sub-01_gradient.txt'
>>> mrtrix_grad.run()  
in_filea pathlike object or string representing an existing file

Input images to be read. Maps to a command-line argument: %s (position: -2).

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

environa 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_grad_mrtrixa pathlike object or string representing a file

Export the DWI gradient table to file in MRtrix format. Maps to a command-line argument: -export_grad_mrtrix %s.

out_grad_mrtrixa pathlike object or string representing a file

Output MRtrix gradient text file if set.

FilterTractogram

Link to code

Bases: MRTrix3Base

Wrapped executable: tcksift.

Spherical-deconvolution informed filtering of tractograms using tcksift [Smith2013SIFT].

References

Smith2013SIFT

R.E. Smith et al., NeuroImage 67 (2013), pp. 298–312, <https://www.ncbi.nlm.nih.gov/pubmed/23238430>.

Example

>>> import cmtklib.interfaces.mrtrix3 as cmp_mrt
>>> mrtrix_sift = cmp_mrt.FilterTractogram()
>>> mrtrix_sift.inputs.in_tracks = 'tractogram.tck'
>>> mrtrix_sift.inputs.in_fod = 'spherical_harmonics_image.nii.gz'
>>> mrtrix_sift.inputs.out_file = 'sift_tractogram.tck'
>>> mrtrix_sift.run()   
in_foda pathlike object or string representing an existing file

Input image containing the spherical harmonics of the fibre orientation distributions. Maps to a command-line argument: %s (position: -2).

in_tracksa pathlike object or string representing an existing file

Input track file in TCK format. Maps to a command-line argument: %s (position: -3).

act_filea pathlike object or string representing an existing file

ACT 5TT image file. Maps to a command-line argument: -act %s (position: -4).

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

environa 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_filea pathlike object or string representing a file

Output filtered tractogram. Maps to a command-line argument: %s (position: -1).

out_tracksa pathlike object or string representing an existing file

Output filtered tractogram.

Generate5tt

Link to code

Bases: nipype.interfaces.base.core.CommandLine

Wrapped executable: 5ttgen.

Generate a 5TT image suitable for ACT using the selected algorithm using 5ttgen.

Example

>>> import cmtklib.interfaces.mrtrix3 as mrt
>>> gen5tt = mrt.Generate5tt()
>>> gen5tt.inputs.in_file = 'T1.nii.gz'
>>> gen5tt.inputs.algorithm = 'fsl'
>>> gen5tt.inputs.out_file = '5tt.mif'
>>> gen5tt.cmdline                             
'5ttgen fsl T1.nii.gz 5tt.mif'
>>> gen5tt.run()                               
algorithm‘fsl’ or ‘gif’ or ‘freesurfer’ or ‘hsvs’

Tissue segmentation algorithm. Maps to a command-line argument: %s (position: -3).

in_filea pathlike object or string representing an existing file

Input image. Maps to a command-line argument: -nocrop -sgm_amyg_hipp %s (position: -2).

out_filea pathlike object or string representing a file

Output image. Maps to a command-line argument: %s (position: -1).

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

environa 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_filea pathlike object or string representing an existing file

Output image.

GenerateGMWMInterface

Link to code

Bases: nipype.interfaces.base.core.CommandLine

Wrapped executable: 5tt2gmwmi.

Generate a grey matter-white matter interface mask from the 5TT image using 5tt2gmwmi.

Example

>>> import cmtklib.interfaces.mrtrix3 as cmp_mrt
>>> genWMGMI = cmp_mrt.Generate5tt()
>>> genWMGMI.inputs.in_file = '5tt.mif'
>>> genWMGMI.inputs.out_file = 'gmwmi.mif'
>>> genGMWMI.run()  
in_filea pathlike object or string representing an existing file

Input 5TT image. Maps to a command-line argument: %s (position: -2).

out_filea pathlike object or string representing a file

Output GW/WM interface image. Maps to a command-line argument: %s (position: -1).

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

environa 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_filea pathlike object or string representing an existing file

Output image.

MRConvert

Link to code

Bases: nipype.interfaces.base.core.CommandLine

Wrapped executable: mrconvert.

Perform conversion with mrconvert between different file types and optionally extract a subset of the input image.

If used correctly, this program can be a very useful workhorse. In addition to converting images between different formats, it can be used to extract specific studies from a data set, extract a specific region of interest, flip the images, or to scale the intensity of the images.

Example

>>> import cmtklib.interfaces.mrtrix3 as mrt
>>> mrconvert = mrt.MRConvert()
>>> mrconvert.inputs.in_file = 'dwi_FA.mif'
>>> mrconvert.inputs.out_filename = 'dwi_FA.nii'
>>> mrconvert.run()  
in_dira pathlike object or string representing an existing directory

Directory containing DICOM files. Maps to a command-line argument: %s (position: -2). Mutually exclusive with inputs: in_file, in_dir.

in_filea pathlike object or string representing an existing file

Voxel-order data filename. Maps to a command-line argument: %s (position: -2). Mutually exclusive with inputs: in_file, in_dir.

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

environa 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: {})

extension‘mif’ or ‘nii’ or ‘float’ or ‘char’ or ‘short’ or ‘int’ or ‘long’ or ‘double’

“i.e. Bfloat”. Can be “char”, “short”, “int”, “long”, “float” or “double”. (Nipype default value: mif)

extract_at_axis1 or 2 or 3

Extract data only at the coordinates specified.This option specifies the Axis. Must be used in conjunction with extract_at_coordinate. . Maps to a command-line argument: -coord %s (position: 1).

extract_at_coordinatea list of from 1 to 3 items which are an integer

Extract data only at the coordinates specified. This option specifies the coordinates. Must be used in conjunction with extract_at_axis. Three comma-separated numbers giving the size of each voxel in mm. Maps to a command-line argument: %s (position: 2).

force_writinga boolean

Force file overwriting. Maps to a command-line argument: -force.

grada pathlike object or string representing an existing file

Gradient encoding, supplied as a 4xN text file with each line is in the format [ X Y Z b ], where [ X Y Z ] describe the direction of the applied gradient, and b gives the b-value in units (1000 s/mm^2). See FSL2MRTrix. Maps to a command-line argument: -grad %s (position: 9).

grad_fsla tuple of the form: (a pathlike object or string representing an existing file, a pathlike object or string representing an existing file)

[bvecs, bvals] DW gradient scheme (FSL format). Maps to a command-line argument: -fslgrad %s %s.

layout‘nii’ or ‘float’ or ‘char’ or ‘short’ or ‘int’ or ‘long’ or ‘double’

Specify the layout of the data in memory. The actual layout produced will depend on whether the output image format can support it. Maps to a command-line argument: -output %s (position: 5).

offset_biasa float

Apply offset to the intensity values. Maps to a command-line argument: -scale %d (position: 7).

out_filenamea pathlike object or string representing a file

Output filename. Maps to a command-line argument: %s (position: -1).

output_datatype‘float32’ or ‘float32le’ or ‘float32be’ or ‘float64’ or ‘float64le’ or ‘float64be’ or ‘int64’ or ‘uint64’ or ‘int64le’ or ‘uint64le’ or ‘int64be’ or ‘uint64be’ or ‘int32’ or ‘uint32’ or ‘int32le’ or ‘uint32le’ or ‘int32be’ or ‘uint32be’ or ‘int16’ or ‘uint16’ or ‘int16le’ or ‘uint16le’ or ‘int16be’ or ‘uint16be’ or ‘cfloat32’ or ‘cfloat32le’ or ‘cfloat32be’ or ‘cfloat64’ or ‘cfloat64le’ or ‘cfloat64be’ or ‘int8’ or ‘uint8’ or ‘bit’

Specify output image data type. Valid choices are: float32, float32le, float32be, float64, float64le, float64be, int64, uint64, int64le, uint64le, int64be, uint64be, int32, uint32, int32le, uint32le, int32be, uint32be, int16, uint16, int16le, uint16le, int16be, uint16be, cfloat32, cfloat32le, cfloat32be, cfloat64, cfloat64le, cfloat64be, int8, uint8, bit.”. Maps to a command-line argument: -datatype %s (position: 2).

prsa boolean

Assume that the DW gradients are specified in the PRS frame (Siemens DICOM only). Maps to a command-line argument: -prs (position: 3).

quieta boolean

Do not display information messages or progress status. Maps to a command-line argument: -quiet.

replace_nan_with_zeroa boolean

Replace all NaN values with zero. Maps to a command-line argument: -zero (position: 8).

resamplea float

Apply scaling to the intensity values. Maps to a command-line argument: -scale %d (position: 6).

stridea list of from 3 to 4 items which are an integer

Three to four comma-separated numbers specifying the strides of the output data in memory. The actual strides produced will depend on whether the output image format can support it.. Maps to a command-line argument: -stride %s (position: 3).

voxel_dimsa list of from 3 to 3 items which are a float

Three comma-separated numbers giving the size of each voxel in mm. Maps to a command-line argument: -vox %s (position: 3).

converteda pathlike object or string representing an existing file

Path/name of 4D volume in voxel order.

MRCrop

Link to code

Bases: nipype.interfaces.base.core.CommandLine

Wrapped executable: mrcrop.

Crops a NIFTI image using the mrcrop tool.

Example

>>> import cmtklib.interfaces.mrtrix3 as mrt
>>> mrcrop = mrt.MRCrop()
>>> mrcrop.inputs.in_file = 'sub-01_dwi.nii.gz'
>>> mrcrop.inputs.in_mask_file = 'sub-01_mod-dwi_desc-brain_mask.nii.gz'
>>> mrcrop.inputs.out_filename = 'sub-01_desc-cropped_dwi.nii.gz'
>>> mrcrop.run()  
in_filea pathlike object or string representing an existing file

Input image. Maps to a command-line argument: %s (position: -2).

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

debuga boolean

Display debugging messages. Maps to a command-line argument: -debug (position: 1).

environa 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_mask_filea pathlike object or string representing an existing file

Input mask. Maps to a command-line argument: -mask %s (position: -3).

out_filenamea pathlike object or string representing a file

Output cropped image. Maps to a command-line argument: %s (position: -1).

quieta boolean

Do not display information messages or progress status. Maps to a command-line argument: -quiet (position: 1).

croppeda pathlike object or string representing an existing file

The output cropped image.

MRThreshold

Link to code

Bases: nipype.interfaces.base.core.CommandLine

Wrapped executable: mrthreshold.

Threshold an image using the mrthreshold tool.

Example

>>> import cmtklib.interfaces.mrtrix3 as mrt
>>> mrthresh = mrt.MRCrop()
>>> mrthresh.inputs.in_file = 'sub-01_dwi.nii.gz'
>>> mrthresh.inputs.out_file = 'sub-01_desc-thresholded_dwi.nii.gz'
>>> mrthresh.run()  
in_filea pathlike object or string representing an existing file

The input image to be thresholded. Maps to a command-line argument: %s (position: -3).

out_filea pathlike object or string representing a file

the output binary image mask.

Maps to a command-line argument: %s (position: -2).

abs_valuea float

Specify threshold value as absolute intensity. Maps to a command-line argument: -abs %s (position: -1).

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

environa 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: {})

force_writinga boolean

Force file overwriting. Maps to a command-line argument: -force.

quieta boolean

Do not display information messages or progress status. Maps to a command-line argument: -quiet.

thresholdeda pathlike object or string representing an existing file

Path/name of the output binary image mask.

MRTransform

Link to code

Bases: nipype.interfaces.base.core.CommandLine

Wrapped executable: mrtransform.

Apply spatial transformations or reslice images using the mrtransform tool.

Example

>>> from cmtklib.interfaces.mrtrix3 import MRTransform
>>> MRxform = MRTransform()
>>> MRxform.inputs.in_files = 'anat_coreg.mif'
>>> MRxform.inputs.interp = 'cubic'
>>> MRxform.run()  
in_filesa list of items which are any value

Input images to be transformed. Maps to a command-line argument: %s (position: -2).

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

debuga boolean

Display debugging messages. Maps to a command-line argument: -debug (position: 1).

environa 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: {})

flip_xa boolean

Assume the transform is supplied assuming a coordinate system with the x-axis reversed relative to the MRtrix convention (i.e. x increases from right to left). This is required to handle transform matrices produced by FSL’s FLIRT command. This is only used in conjunction with the -reference option. Maps to a command-line argument: -flipx (position: 1).

interp‘nearest’ or ‘linear’ or ‘cubic’ or ‘sinc’

Set the interpolation method to use when reslicing (choices: nearest,linear, cubic, sinc. Default: cubic). Maps to a command-line argument: -interp %s.

inverta boolean

Invert the specified transform before using it. Maps to a command-line argument: -inverse (position: 1).

out_filenamea pathlike object or string representing a file

Output image. Maps to a command-line argument: %s (position: -1).

quieta boolean

Do not display information messages or progress status. Maps to a command-line argument: -quiet (position: 1).

reference_imagea pathlike object or string representing an existing file

In case the transform supplied maps from the input image onto a reference image, use this option to specify the reference. Note that this implicitly sets the -replace option. Maps to a command-line argument: -reference %s (position: 1).

replace_transforma boolean

Replace the current transform by that specified, rather than applying it to the current transform. Maps to a command-line argument: -replace (position: 1).

template_imagea pathlike object or string representing an existing file

Reslice the input image to match the specified template image. Maps to a command-line argument: -template %s (position: 1).

transformation_filea pathlike object or string representing an existing file

The transform to apply, in the form of a 4x4 ascii file. Maps to a command-line argument: -transform %s (position: 1).

out_filea pathlike object or string representing an existing file

The output image of the transformation.

MRTrix3Base

Link to code

Bases: nipype.interfaces.base.core.CommandLine

“MRtrix3Base base class inherited by FilterTractogram class.

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

environa 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: {})

MRtrix_mul

Link to code

Bases: nipype.interfaces.base.core.CommandLine

Wrapped executable: mrcalc.

Multiply two images together using mrcalc tool.

Examples

>>> from cmtklib.interfaces.mrtrix3 import MRtrix_mul
>>> multiply = MRtrix_mul()
>>> multiply.inputs.input1  = 'image1.nii.gz'
>>> multiply.inputs.input2  = 'image2.nii.gz'
>>> multiply.inputs.out_filename = 'result.nii.gz'
>>> multiply.run()  
input1a pathlike object or string representing an existing file

Input1 file. Maps to a command-line argument: %s (position: 1).

input2a pathlike object or string representing an existing file

Input2 file. Maps to a command-line argument: %s (position: 2).

out_filenamea string

Out filename. Maps to a command-line argument: -mult %s (position: 3).

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

environa 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_filea pathlike object or string representing a file

Multiplication result file.

SIFT2

Link to code

Bases: MRTrix3Base

Wrapped executable: tcksift2.

Determine an appropriate cross-sectional area multiplier for each streamline using tcksift2 [Smith2015SIFT2].

References

Smith2015SIFT2

Smith RE et al., Neuroimage, 2015, 119:338-51. <https://doi.org/10.1016/j.neuroimage.2015.06.092>.

Example

>>> import cmtklib.interfaces.mrtrix3 as cmp_mrt
>>> mrtrix_sift2 = cmp_mrt.SIFT2()
>>> mrtrix_sift2.inputs.in_tracks = 'tractogram.tck'
>>> mrtrix_sift2.inputs.in_fod = 'spherical_harmonics_image.nii.gz'
>>> mrtrix_sift2.inputs.out_file = 'sift2_fiber_weights.txt'
>>> mrtrix_sift2.run()  
in_foda pathlike object or string representing an existing file

Input image containing the spherical harmonics of the fibre orientation distributions. Maps to a command-line argument: %s (position: -2).

in_tracksa pathlike object or string representing an existing file

Input track file in TCK format. Maps to a command-line argument: %s (position: -3).

act_filea pathlike object or string representing an existing file

ACT 5TT image file. Maps to a command-line argument: -act %s (position: -4).

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

environa 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_filea pathlike object or string representing a file

Output filtered tractogram. Maps to a command-line argument: %s (position: -1).

out_tracksa pathlike object or string representing an existing file

Output filtered tractogram.

StreamlineTrack

Link to code

Bases: nipype.interfaces.base.core.CommandLine

Wrapped executable: tckgen.

Performs tractography using tckgen.

It can use one of the following models:

'dt_prob', 'dt_stream', 'sd_prob', 'sd_stream'

where ‘dt’ stands for diffusion tensor, ‘sd’ stands for spherical deconvolution, and ‘prob’ stands for probabilistic.

Example

>>> import cmtklib.interfaces.mrtrix3 as mrt
>>> strack = mrt.StreamlineTrack()
>>> strack.inputs.inputmodel = 'SD_PROB'
>>> strack.inputs.in_file = 'data.Bfloat'
>>> strack.inputs.seed_file = 'seed_mask.nii'
>>> strack.run()  
in_filea pathlike object or string representing an existing file

The image containing the source data.The type of data required depends on the type of tracking as set in the preceeding argument.For DT methods, the base DWI are needed.For SD methods, the SH harmonic coefficients of the FOD are needed. Maps to a command-line argument: %s (position: 2).

act_filea pathlike object or string representing an existing file

Use the Anatomically-Constrained Tractography framework during tracking; provided image must be in the 5TT (five - tissue - type) format. Maps to a command-line argument: -act %s.

anglea float

Set the maximum angle between successive steps (default is 90deg x stepsize / voxelsize). Maps to a command-line argument: -angle %s.

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

backtracka boolean

Allow tracks to be truncated. Maps to a command-line argument: -backtrack.

crop_at_gmwmia boolean

Crop streamline endpoints more precisely as they cross the GM-WM interface. Maps to a command-line argument: -crop_at_gmwmi.

cutoff_valuea float

Set the FA or FOD amplitude cutoff for terminating tracks (default is 0.5). Maps to a command-line argument: -cutoff %s.

desired_number_of_tracksan integer

Sets the desired number of tracks.The program will continue to generate tracks until this number of tracks have been selectedand written to the output file (default is 100 for *_STREAM methods, 1000 for *_PROB methods). Maps to a command-line argument: -select %d.

do_not_precomputea boolean

Turns off precomputation of the legendre polynomial values.Warning: this will slow down the algorithm by a factor of approximately 4. Maps to a command-line argument: -noprecomputed.

environa 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: {})

gradient_encoding_filea pathlike object or string representing an existing file

Gradient encoding, supplied as a 4xN text file with each line is in the format [ X Y Z b ]where [ X Y Z ] describe the direction of the applied gradient, and b gives the b-valuein units (1000 s/mm^2). See FSL2MRTrix. Maps to a command-line argument: -grad %s.

initial_cutoff_valuea float

Sets the minimum FA or FOD amplitude for initiating tracks (default is twice the normal cutoff). Maps to a command-line argument: -seed_cutoff %s.

initial_directiona list of from 2 to 2 items which are an integer

Specify the initial tracking direction as a vector. Maps to a command-line argument: -seed_direction %s.

inputmodel‘FACT’ or ‘iFOD1’ or ‘iFOD2’ or ‘Nulldist1’ or ‘Nulldist2’ or ‘SD_Stream’ or ‘Seedtest’ or ‘Tensor_Det’ or ‘Tensor_Prob’

Specify the tractography algorithm to use. Valid choices are:FACT, iFOD1, iFOD2, Nulldist1, Nulldist2, SD_Stream, Seedtest, Tensor_Det, Tensor_Prob (default: iFOD2). Maps to a command-line argument: -algorithm %s (position: -3). (Nipype default value: FACT)

mask_filea pathlike object or string representing an existing file

Mask file. Only tracks within mask. Maps to a command-line argument: -mask %s.

maximum_number_of_seedsan integer

Sets the maximum number of tracks to generate.The program will not generate more tracks than this number,even if the desired number of tracks hasn’t yet been reached(default is 1000 x number of streamlines). Maps to a command-line argument: -seeds %d.

maximum_tract_lengtha float

Sets the maximum length of any track in millimeters (default is 500 mm). Maps to a command-line argument: -maxlength %s.

minimum_tract_lengtha float

Sets the minimum length of any track in millimeters (default is 5 mm). Maps to a command-line argument: -minlength %s.

out_filea pathlike object or string representing a file

Output data file. Maps to a command-line argument: %s (position: -1).

rk4a boolean

Use 4th-order Runge-Kutta integration (slower, but eliminates curvature overshoot in 1st-order deterministic methods). Maps to a command-line argument: -rk4.

seed_filea pathlike object or string representing an existing file

Seed file. Maps to a command-line argument: -seed_image %s.

seed_gmwmia pathlike object or string representing an existing file

Seed from the grey matter - white matter interface (only valid if using ACT framework). Maps to a command-line argument: -seed_gmwmi %s. Requires inputs: act_file.

seed_speca list of from 4 to 4 items which are an integer

Seed specification in voxels and radius (x y z r). Maps to a command-line argument: -seed_sphere %s.

step_sizea float

Set the step size of the algorithm in mm (default is 0.5). Maps to a command-line argument: -step %s.

stopa boolean

Stop track as soon as it enters any of the include regions. Maps to a command-line argument: -stop.

unidirectionala boolean

Track from the seed point in one direction only (default is to track in both directions). Maps to a command-line argument: -seed_unidirectional.

trackeda pathlike object or string representing an existing file

Output file containing reconstructed tracts.

Tensor2Vector

Link to code

Bases: nipype.interfaces.base.core.CommandLine

Wrapped executable: tensor2metric.

Generates a map of the major eigenvectors of the tensors in each voxel using tensor2metric.

Example

>>> import cmtklib.interfaces.mrtrix3 as mrt
>>> tensor2vector = mrt.Tensor2Vector()
>>> tensor2vector.inputs.in_file = 'dwi_tensor.mif'
>>> tensor2vector.run()  
in_filea pathlike object or string representing an existing file

Diffusion tensor image. Maps to a command-line argument: %s (position: -2).

argsa string

Additional parameters to the command. Maps to a command-line argument: %s.

debuga boolean

Display debugging messages. Maps to a command-line argument: -debug (position: 1).

environa 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_filenamea pathlike object or string representing a file

Output vector filename. Maps to a command-line argument: -vector %s (position: -1).

quieta boolean

Do not display information messages or progress status. Maps to a command-line argument: -quiet (position: 1).

vectora pathlike object or string representing an existing file

The output image of the major eigenvectors of the diffusion tensor image.