Home · Quickstart · Documentation · Citation · NiPy

# interfaces.mrtrix.tensors

## ConstrainedSphericalDeconvolution

Link to code

Wraps command csdeconv

Perform non-negativity constrained spherical deconvolution.

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 nipype.interfaces.mrtrix as mrt
    >>> csdeconv = mrt.ConstrainedSphericalDeconvolution()
    >>> csdeconv.inputs.in_file = 'dwi.mif'
    >>> csdeconv.inputs.encoding_file = 'encoding.txt'
    >>> csdeconv.run()

Inputs:

    [Mandatory]
    in_file: (an existing file name)
            diffusion-weighted image
    response_file: (an existing file name)
            the diffusion-weighted signal response function for a single fibre
            population (see EstimateResponse)
    terminal_output: ('stream' or 'allatonce' or 'file' or 'none')
            Control terminal output: `stream` - displays to terminal
            immediately, `allatonce` - waits till command is finished to display
            output, `file` - writes output to file, `none` - output is ignored

    [Optional]
    args: (a string)
            Additional parameters to the command
    debug: (a boolean)
            Display debugging messages.
    directions_file: (an existing file name)
            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)
    encoding_file: (an existing file name)
            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
    environ: (a dictionary with keys which are a value of type 'str' and
             with values which are a value of type 'str', nipype default value:
             {})
            Environment variables
    filter_file: (an existing file name)
            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 ]).
    ignore_exception: (a boolean, nipype default value: False)
            Print an error message instead of throwing an exception in case the
            interface fails to run
    in_file: (an existing file name)
            diffusion-weighted image
    iterations: (an integer)
            the maximum number of iterations to perform for each voxel (default
            = 50)
    lambda_value: (a float)
            the regularisation parameter lambda that controls the strength of
            the constraint (default = 1.0).
    mask_image: (an existing file name)
            only perform computation within the specified binary brain mask
            image
    maximum_harmonic_order: (an 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.
    normalise: (a boolean)
            normalise the DW signal to the b=0 image
    out_filename: (a file name)
            Output filename
    response_file: (an existing file name)
            the diffusion-weighted signal response function for a single fibre
            population (see EstimateResponse)
    terminal_output: ('stream' or 'allatonce' or 'file' or 'none')
            Control terminal output: `stream` - displays to terminal
            immediately, `allatonce` - waits till command is finished to display
            output, `file` - writes output to file, `none` - output is ignored
    threshold_value: (a 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)

Outputs:

    spherical_harmonics_image: (an existing file name)
            Spherical harmonics image

## DWI2SphericalHarmonicsImage

Link to code

Wraps command dwi2SH

Convert base diffusion-weighted images to their spherical harmonic representation.

This program outputs the spherical harmonic decomposition for the set measured signal attenuations. The signal attenuations are calculated by identifying the b-zero images from the diffusion encoding supplied (i.e. those with zero as the b-value), and dividing the remaining signals by the mean b-zero signal intensity. The spherical harmonic decomposition is then calculated by least-squares linear fitting. 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 nipype.interfaces.mrtrix as mrt
    >>> dwi2SH = mrt.DWI2SphericalHarmonicsImage()
    >>> dwi2SH.inputs.in_file = 'diffusion.nii'
    >>> dwi2SH.inputs.encoding_file = 'encoding.txt'
    >>> dwi2SH.run()

Inputs:

    [Mandatory]
    encoding_file: (an existing file name)
            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
    in_file: (an existing file name)
            Diffusion-weighted images
    terminal_output: ('stream' or 'allatonce' or 'file' or 'none')
            Control terminal output: `stream` - displays to terminal
            immediately, `allatonce` - waits till command is finished to display
            output, `file` - writes output to file, `none` - output is ignored

    [Optional]
    args: (a string)
            Additional parameters to the command
    encoding_file: (an existing file name)
            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
    environ: (a dictionary with keys which are a value of type 'str' and
             with values which are a value of type 'str', nipype default value:
             {})
            Environment variables
    ignore_exception: (a boolean, nipype default value: False)
            Print an error message instead of throwing an exception in case the
            interface fails to run
    in_file: (an existing file name)
            Diffusion-weighted images
    maximum_harmonic_order: (a float)
            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.
    normalise: (a boolean)
            normalise the DW signal to the b=0 image
    out_filename: (a file name)
            Output filename
    terminal_output: ('stream' or 'allatonce' or 'file' or 'none')
            Control terminal output: `stream` - displays to terminal
            immediately, `allatonce` - waits till command is finished to display
            output, `file` - writes output to file, `none` - output is ignored

Outputs:

    spherical_harmonics_image: (an existing file name)
            Spherical harmonics image

## Directions2Amplitude

Link to code

Wraps command dir2amp

convert directions image to amplitudes

### Example

    >>> import nipype.interfaces.mrtrix as mrt
    >>> amplitudes = mrt.Directions2Amplitude()
    >>> amplitudes.inputs.in_file = 'peak_directions.mif'
    >>> amplitudes.run()

Inputs:

    [Mandatory]
    in_file: (an existing file name)
            the input directions image. Each volume corresponds to the x, y & z
            component of each direction vector in turn.
    terminal_output: ('stream' or 'allatonce' or 'file' or 'none')
            Control terminal output: `stream` - displays to terminal
            immediately, `allatonce` - waits till command is finished to display
            output, `file` - writes output to file, `none` - output is ignored

    [Optional]
    args: (a string)
            Additional parameters to the command
    display_debug: (a boolean)
            Display debugging messages.
    display_info: (a boolean)
            Display information messages.
    environ: (a dictionary with keys which are a value of type 'str' and
             with values which are a value of type 'str', nipype default value:
             {})
            Environment variables
    ignore_exception: (a boolean, nipype default value: False)
            Print an error message instead of throwing an exception in case the
            interface fails to run
    in_file: (an existing file name)
            the input directions image. Each volume corresponds to the x, y & z
            component of each direction vector in turn.
    num_peaks: (an integer)
            the number of peaks to extract (default is 3)
    out_file: (a file name)
            the output amplitudes image
    peak_directions: (a list of from 2 to 2 items which are a float)
            phi theta. the direction of a peak to estimate. The algorithm will
            attempt to find the same number of peaks as have been specified
            using this option phi: the azimuthal angle of the direction (in
            degrees). theta: the elevation angle of the direction (in degrees,
            from the vertical z-axis)
    peaks_image: (an existing file name)
            the program will try to find the peaks that most closely match those
            in the image provided
    quiet_display: (a boolean)
            do not display information messages or progress status.
    terminal_output: ('stream' or 'allatonce' or 'file' or 'none')
            Control terminal output: `stream` - displays to terminal
            immediately, `allatonce` - waits till command is finished to display
            output, `file` - writes output to file, `none` - output is ignored

Outputs:

    out_file: (an existing file name)
            amplitudes image

## EstimateResponseForSH

Link to code

Wraps command estimate_response

Estimates the fibre response function for use in spherical deconvolution.

### Example

    >>> import nipype.interfaces.mrtrix 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()

Inputs:

    [Mandatory]
    encoding_file: (an existing file name)
            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
    in_file: (an existing file name)
            Diffusion-weighted images
    mask_image: (an existing file name)
            only perform computation within the specified binary brain mask
            image
    terminal_output: ('stream' or 'allatonce' or 'file' or 'none')
            Control terminal output: `stream` - displays to terminal
            immediately, `allatonce` - waits till command is finished to display
            output, `file` - writes output to file, `none` - output is ignored

    [Optional]
    args: (a string)
            Additional parameters to the command
    debug: (a boolean)
            Display debugging messages.
    encoding_file: (an existing file name)
            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
    environ: (a dictionary with keys which are a value of type 'str' and
             with values which are a value of type 'str', nipype default value:
             {})
            Environment variables
    ignore_exception: (a boolean, nipype default value: False)
            Print an error message instead of throwing an exception in case the
            interface fails to run
    in_file: (an existing file name)
            Diffusion-weighted images
    mask_image: (an existing file name)
            only perform computation within the specified binary brain mask
            image
    maximum_harmonic_order: (an 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.
    normalise: (a boolean)
            normalise the DW signal to the b=0 image
    out_filename: (a file name)
            Output filename
    quiet: (a boolean)
            Do not display information messages or progress status.
    terminal_output: ('stream' or 'allatonce' or 'file' or 'none')
            Control terminal output: `stream` - displays to terminal
            immediately, `allatonce` - waits till command is finished to display
            output, `file` - writes output to file, `none` - output is ignored

Outputs:

    response: (an existing file name)
            Spherical harmonics image

## FindShPeaks

Link to code

Wraps command find_SH_peaks

identify the orientations of the N largest peaks of a SH profile

### Example

    >>> import nipype.interfaces.mrtrix as mrt
    >>> shpeaks = mrt.FindShPeaks()
    >>> shpeaks.inputs.in_file = 'csd.mif'
    >>> shpeaks.inputs.directions_file = 'dirs.txt'
    >>> shpeaks.inputs.num_peaks = 2
    >>> shpeaks.run()

Inputs:

    [Mandatory]
    directions_file: (an existing file name)
            the set of directions to use as seeds for the peak finding
    in_file: (an existing file name)
            the input image of SH coefficients.
    terminal_output: ('stream' or 'allatonce' or 'file' or 'none')
            Control terminal output: `stream` - displays to terminal
            immediately, `allatonce` - waits till command is finished to display
            output, `file` - writes output to file, `none` - output is ignored

    [Optional]
    args: (a string)
            Additional parameters to the command
    directions_file: (an existing file name)
            the set of directions to use as seeds for the peak finding
    display_debug: (a boolean)
            Display debugging messages.
    display_info: (a boolean)
            Display information messages.
    environ: (a dictionary with keys which are a value of type 'str' and
             with values which are a value of type 'str', nipype default value:
             {})
            Environment variables
    ignore_exception: (a boolean, nipype default value: False)
            Print an error message instead of throwing an exception in case the
            interface fails to run
    in_file: (an existing file name)
            the input image of SH coefficients.
    num_peaks: (an integer)
            the number of peaks to extract (default is 3)
    out_file: (a file name)
            the output image. Each volume corresponds to the x, y & z component
            of each peak direction vector in turn
    peak_directions: (a list of from 2 to 2 items which are a float)
            phi theta. the direction of a peak to estimate. The algorithm will
            attempt to find the same number of peaks as have been specified
            using this option phi: the azimuthal angle of the direction (in
            degrees). theta: the elevation angle of the direction (in degrees,
            from the vertical z-axis)
    peak_threshold: (a float)
            only peak amplitudes greater than the threshold will be considered
    peaks_image: (an existing file name)
            the program will try to find the peaks that most closely match those
            in the image provided
    quiet_display: (a boolean)
            do not display information messages or progress status.
    terminal_output: ('stream' or 'allatonce' or 'file' or 'none')
            Control terminal output: `stream` - displays to terminal
            immediately, `allatonce` - waits till command is finished to display
            output, `file` - writes output to file, `none` - output is ignored

Outputs:

    out_file: (an existing file name)
            Peak directions image

## GenerateDirections

Link to code

Wraps command gendir

generate a set of directions evenly distributed over a hemisphere.

### Example

    >>> import nipype.interfaces.mrtrix as mrt
    >>> gendir = mrt.GenerateDirections()
    >>> gendir.inputs.num_dirs = 300
    >>> gendir.run()

Inputs:

    [Mandatory]
    num_dirs: (an integer)
            the number of directions to generate.
    terminal_output: ('stream' or 'allatonce' or 'file' or 'none')
            Control terminal output: `stream` - displays to terminal
            immediately, `allatonce` - waits till command is finished to display
            output, `file` - writes output to file, `none` - output is ignored

    [Optional]
    args: (a string)
            Additional parameters to the command
    display_debug: (a boolean)
            Display debugging messages.
    display_info: (a boolean)
            Display information messages.
    environ: (a dictionary with keys which are a value of type 'str' and
             with values which are a value of type 'str', nipype default value:
             {})
            Environment variables
    ignore_exception: (a boolean, nipype default value: False)
            Print an error message instead of throwing an exception in case the
            interface fails to run
    niter: (an integer)
            specify the maximum number of iterations to perform.
    num_dirs: (an integer)
            the number of directions to generate.
    out_file: (a file name, nipype default value: directions.txt)
            the text file to write the directions to, as [ az el ] pairs.
    power: (a float)
            specify exponent to use for repulsion power law.
    quiet_display: (a boolean)
            do not display information messages or progress status.
    terminal_output: ('stream' or 'allatonce' or 'file' or 'none')
            Control terminal output: `stream` - displays to terminal
            immediately, `allatonce` - waits till command is finished to display
            output, `file` - writes output to file, `none` - output is ignored

Outputs:

    out_file: (an existing file name)
            directions file

## `concat_files()`

Link to code