nipype.interfaces.niftyreg.regutils module

The regutils module provides classes for interfacing with the niftyreg utility command line tools.

The interfaces were written to work with niftyreg version 1.5.10

class nipype.interfaces.niftyreg.regutils.RegAverage(required_version=None, **inputs)

Bases: NiftyRegCommand

Wrapped executable: reg_average.

Interface for executable reg_average from NiftyReg platform.

Compute average matrix or image from a list of matrices or image. The tool can be use to resample images given input transformation parametrisation as well as to demean transformations in Euclidean or log-Euclidean space.

This interface is different than the others in the way that the options will be written in a command file that is given as a parameter.

Source code

Examples

>>> from nipype.interfaces import niftyreg
>>> node = niftyreg.RegAverage()
>>> one_file = 'im1.nii'
>>> two_file = 'im2.nii'
>>> three_file = 'im3.nii'
>>> node.inputs.avg_files = [one_file, two_file, three_file]
>>> node.cmdline
'reg_average --cmd_file .../reg_average_cmd'
Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • avg_files (a list of items which are a pathlike object or string representing a file) – Averaging of images/affine transformations. Maps to a command-line argument: -avg %s (position: 1). Mutually exclusive with inputs: avg_lts_files, avg_ref_file, demean1_ref_file, demean2_ref_file, demean3_ref_file, warp_files.

  • avg_lts_files (a list of items which are a pathlike object or string representing a file) – Robust average of affine transformations. Maps to a command-line argument: -avg_lts %s (position: 1). Mutually exclusive with inputs: avg_files, avg_ref_file, demean1_ref_file, demean2_ref_file, demean3_ref_file, warp_files.

  • avg_ref_file (a pathlike object or string representing a file) – All input images are resampled into the space of <reference image> and averaged. A cubic spline interpolation scheme is used for resampling. Maps to a command-line argument: -avg_tran %s (position: 1). Mutually exclusive with inputs: avg_files, avg_lts_files, demean1_ref_file, demean2_ref_file, demean3_ref_file. Requires inputs: warp_files.

  • demean1_ref_file (a pathlike object or string representing a file) – Average images and demean average image that have affine transformations to a common space. Maps to a command-line argument: -demean1 %s (position: 1). Mutually exclusive with inputs: avg_files, avg_lts_files, avg_ref_file, demean2_ref_file, demean3_ref_file. Requires inputs: warp_files.

  • demean2_ref_file (a pathlike object or string representing a file) – Average images and demean average image that have non-rigid transformations to a common space. Maps to a command-line argument: -demean2 %s (position: 1). Mutually exclusive with inputs: avg_files, avg_lts_files, avg_ref_file, demean1_ref_file, demean3_ref_file. Requires inputs: warp_files.

  • demean3_ref_file (a pathlike object or string representing a file) – Average images and demean average image that have linear and non-rigid transformations to a common space. Maps to a command-line argument: -demean3 %s (position: 1). Mutually exclusive with inputs: avg_files, avg_lts_files, avg_ref_file, demean1_ref_file, demean2_ref_file. Requires inputs: warp_files.

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

  • omp_core_val (an integer) – Number of openmp thread to use. Maps to a command-line argument: -omp %i. (Nipype default value: 1)

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

  • warp_files (a list of items which are a pathlike object or string representing a file) – Transformation files and floating image pairs/triplets to the reference space. Maps to a command-line argument: %s (position: -1). Mutually exclusive with inputs: avg_files, avg_lts_files.

Outputs:

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

property cmdline

Rewrite the cmdline to write options in text_file.

class nipype.interfaces.niftyreg.regutils.RegJacobian(required_version=None, **inputs)

Bases: NiftyRegCommand

Wrapped executable: reg_jacobian.

Interface for executable reg_resample from NiftyReg platform.

Tool to generate Jacobian determinant maps from transformation parametrisation generated by reg_f3d

Source code

Examples

>>> from nipype.interfaces import niftyreg
>>> node = niftyreg.RegJacobian()
>>> node.inputs.ref_file = 'im1.nii'
>>> node.inputs.trans_file = 'warpfield.nii'
>>> node.inputs.omp_core_val = 4
>>> node.cmdline
'reg_jacobian -omp 4 -ref im1.nii -trans warpfield.nii -jac warpfield_jac.nii.gz'
Mandatory Inputs:

trans_file (a pathlike object or string representing an existing file) – The input non-rigid transformation. Maps to a command-line argument: -trans %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: {})

  • omp_core_val (an integer) – Number of openmp thread to use. Maps to a command-line argument: -omp %i. (Nipype default value: 1)

  • out_file (a pathlike object or string representing a file) – The output jacobian determinant file name. Maps to a command-line argument: %s (position: -1).

  • ref_file (a pathlike object or string representing an existing file) – Reference/target file (required if specifying CPP transformations. Maps to a command-line argument: -ref %s.

  • type (‘jac’ or ‘jacL’ or ‘jacM’) – Type of jacobian outcome. Maps to a command-line argument: -%s (position: -2). (Nipype default value: jac)

Outputs:

out_file (a pathlike object or string representing a file) – The output file.

class nipype.interfaces.niftyreg.regutils.RegMeasure(required_version=None, **inputs)

Bases: NiftyRegCommand

Wrapped executable: reg_measure.

Interface for executable reg_measure from NiftyReg platform.

Given two input images, compute the specified measure(s) of similarity

Source code

Examples

>>> from nipype.interfaces import niftyreg
>>> node = niftyreg.RegMeasure()
>>> node.inputs.ref_file = 'im1.nii'
>>> node.inputs.flo_file = 'im2.nii'
>>> node.inputs.measure_type = 'lncc'
>>> node.inputs.omp_core_val = 4
>>> node.cmdline
'reg_measure -flo im2.nii -lncc -omp 4 -out im2_lncc.txt -ref im1.nii'
Mandatory Inputs:
  • flo_file (a pathlike object or string representing an existing file) – The input floating/source image. Maps to a command-line argument: -flo %s.

  • measure_type (‘ncc’ or ‘lncc’ or ‘nmi’ or ‘ssd’) – Measure of similarity to compute. Maps to a command-line argument: -%s.

  • ref_file (a pathlike object or string representing an existing file) – The input reference/target image. Maps to a command-line argument: -ref %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: {})

  • omp_core_val (an integer) – Number of openmp thread to use. Maps to a command-line argument: -omp %i. (Nipype default value: 1)

  • out_file (a pathlike object or string representing a file) – The output text file containing the measure. Maps to a command-line argument: -out %s.

Outputs:

out_file (a pathlike object or string representing a file) – The output text file containing the measure.

class nipype.interfaces.niftyreg.regutils.RegResample(required_version=None, **inputs)

Bases: NiftyRegCommand

Wrapped executable: reg_resample.

Interface for executable reg_resample from NiftyReg platform.

Tool to resample floating image in the space of a defined reference image given a transformation parametrisation generated by reg_aladin, reg_f3d or reg_transform

Source code

Examples

>>> from nipype.interfaces import niftyreg
>>> node = niftyreg.RegResample()
>>> node.inputs.ref_file = 'im1.nii'
>>> node.inputs.flo_file = 'im2.nii'
>>> node.inputs.trans_file = 'warpfield.nii'
>>> node.inputs.inter_val = 'LIN'
>>> node.inputs.omp_core_val = 4
>>> node.cmdline
'reg_resample -flo im2.nii -inter 1 -omp 4 -ref im1.nii -trans warpfield.nii -res im2_res.nii.gz'
Mandatory Inputs:
  • flo_file (a pathlike object or string representing an existing file) – The input floating/source image. Maps to a command-line argument: -flo %s.

  • ref_file (a pathlike object or string representing an existing file) – The input reference/target image. Maps to a command-line argument: -ref %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: {})

  • inter_val (‘NN’ or ‘LIN’ or ‘CUB’ or ‘SINC’) – Interpolation type. Maps to a command-line argument: -inter %d.

  • omp_core_val (an integer) – Number of openmp thread to use. Maps to a command-line argument: -omp %i. (Nipype default value: 1)

  • out_file (a pathlike object or string representing a file) – The output filename of the transformed image. Maps to a command-line argument: %s (position: -1).

  • pad_val (a float) – Padding value. Maps to a command-line argument: -pad %f.

  • psf_alg (0 or 1) – Minimise the matrix metric (0) or the determinant (1) when estimating the PSF [0]. Maps to a command-line argument: -psf_alg %d.

  • psf_flag (a boolean) – Perform the resampling in two steps to resample an image to a lower resolution. Maps to a command-line argument: -psf.

  • tensor_flag (a boolean) – Resample Tensor Map. Maps to a command-line argument: -tensor.

  • trans_file (a pathlike object or string representing an existing file) – The input transformation file. Maps to a command-line argument: -trans %s.

  • type (‘res’ or ‘blank’) – Type of output. Maps to a command-line argument: -%s (position: -2). (Nipype default value: res)

  • verbosity_off_flag (a boolean) – Turn off verbose output. Maps to a command-line argument: -voff.

Outputs:

out_file (a pathlike object or string representing a file) – The output filename of the transformed image.

class nipype.interfaces.niftyreg.regutils.RegTools(required_version=None, **inputs)

Bases: NiftyRegCommand

Wrapped executable: reg_tools.

Interface for executable reg_tools from NiftyReg platform.

Tool delivering various actions related to registration such as resampling the input image to a chosen resolution or remove the nan and inf in the input image by a specified value.

Source code

Examples

>>> from nipype.interfaces import niftyreg
>>> node = niftyreg.RegTools()
>>> node.inputs.in_file = 'im1.nii'
>>> node.inputs.mul_val = 4
>>> node.inputs.omp_core_val = 4
>>> node.cmdline
'reg_tools -in im1.nii -mul 4.0 -omp 4 -out im1_tools.nii.gz'
Mandatory Inputs:

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

Optional Inputs:
  • add_val (a float or a pathlike object or string representing an existing file) – Add to the input image or value. Maps to a command-line argument: -add %s.

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

  • bin_flag (a boolean) – Binarise the input image. Maps to a command-line argument: -bin.

  • chg_res_val (a tuple of the form: (a float, a float, a float)) – Change the resolution of the input image. Maps to a command-line argument: -chgres %f %f %f.

  • div_val (a float or a pathlike object or string representing an existing file) – Divide the input by image or value. Maps to a command-line argument: -div %s.

  • down_flag (a boolean) – Downsample the image by a factor of 2. Maps to a command-line argument: -down.

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

  • inter_val (‘NN’ or ‘LIN’ or ‘CUB’ or ‘SINC’) – Interpolation order to use to warp the floating image. Maps to a command-line argument: -interp %d.

  • iso_flag (a boolean) – Make output image isotropic. Maps to a command-line argument: -iso.

  • mask_file (a pathlike object or string representing an existing file) – Values outside the mask are set to NaN. Maps to a command-line argument: -nan %s.

  • mul_val (a float or a pathlike object or string representing an existing file) – Multiply the input by image or value. Maps to a command-line argument: -mul %s.

  • noscl_flag (a boolean) – Set scale, slope to 0 and 1. Maps to a command-line argument: -noscl.

  • omp_core_val (an integer) – Number of openmp thread to use. Maps to a command-line argument: -omp %i. (Nipype default value: 1)

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

  • rms_val (a pathlike object or string representing an existing file) – Compute the mean RMS between the images. Maps to a command-line argument: -rms %s.

  • smo_g_val (a tuple of the form: (a float, a float, a float)) – Smooth the input image using a Gaussian kernel. Maps to a command-line argument: -smoG %f %f %f.

  • smo_s_val (a tuple of the form: (a float, a float, a float)) – Smooth the input image using a cubic spline kernel. Maps to a command-line argument: -smoS %f %f %f.

  • sub_val (a float or a pathlike object or string representing an existing file) – Add to the input image or value. Maps to a command-line argument: -sub %s.

  • thr_val (a float) – Binarise the input image with the given threshold. Maps to a command-line argument: -thr %f.

Outputs:

out_file (a pathlike object or string representing an existing file) – The output file.

class nipype.interfaces.niftyreg.regutils.RegTransform(required_version=None, **inputs)

Bases: NiftyRegCommand

Wrapped executable: reg_transform.

Interface for executable reg_transform from NiftyReg platform.

Tools to convert transformation parametrisation from one type to another as well as to compose, inverse or half transformations.

Source code

Examples

>>> from nipype.interfaces import niftyreg
>>> node = niftyreg.RegTransform()
>>> node.inputs.def_input = 'warpfield.nii'
>>> node.inputs.omp_core_val = 4
>>> node.cmdline
"reg_transform -omp 4 -def warpfield.nii '.../warpfield_trans.nii.gz'"
Optional Inputs:
  • aff_2_rig_input (a pathlike object or string representing an existing file) – Extract the rigid component from affine transformation. Maps to a command-line argument: -aff2rig %s (position: -2). Mutually exclusive with inputs: def_input, disp_input, flow_input, comp_input, upd_s_form_input, inv_aff_input, inv_nrr_input, half_input, make_aff_input, flirt_2_nr_input.

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

  • comp_input (a pathlike object or string representing an existing file) – Compose two transformations. Maps to a command-line argument: -comp %s (position: -3). Mutually exclusive with inputs: def_input, disp_input, flow_input, upd_s_form_input, inv_aff_input, inv_nrr_input, half_input, make_aff_input, aff_2_rig_input, flirt_2_nr_input. Requires inputs: comp_input2.

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

  • def_input (a pathlike object or string representing an existing file) – Compute deformation field from transformation. Maps to a command-line argument: -def %s (position: -2). Mutually exclusive with inputs: disp_input, flow_input, comp_input, upd_s_form_input, inv_aff_input, inv_nrr_input, half_input, make_aff_input, aff_2_rig_input, flirt_2_nr_input.

  • disp_input (a pathlike object or string representing an existing file) – Compute displacement field from transformation. Maps to a command-line argument: -disp %s (position: -2). Mutually exclusive with inputs: def_input, flow_input, comp_input, upd_s_form_input, inv_aff_input, inv_nrr_input, half_input, make_aff_input, aff_2_rig_input, flirt_2_nr_input.

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

  • flirt_2_nr_input (a tuple of the form: (a pathlike object or string representing an existing file, a pathlike object or string representing an existing file, a pathlike object or string representing an existing file)) – Convert a FLIRT affine transformation to niftyreg affine transformation. Maps to a command-line argument: -flirtAff2NR %s %s %s (position: -2). Mutually exclusive with inputs: def_input, disp_input, flow_input, comp_input, upd_s_form_input, inv_aff_input, inv_nrr_input, half_input, make_aff_input, aff_2_rig_input.

  • flow_input (a pathlike object or string representing an existing file) – Compute flow field from spline SVF. Maps to a command-line argument: -flow %s (position: -2). Mutually exclusive with inputs: def_input, disp_input, comp_input, upd_s_form_input, inv_aff_input, inv_nrr_input, half_input, make_aff_input, aff_2_rig_input, flirt_2_nr_input.

  • half_input (a pathlike object or string representing an existing file) – Half way to the input transformation. Maps to a command-line argument: -half %s (position: -2). Mutually exclusive with inputs: def_input, disp_input, flow_input, comp_input, upd_s_form_input, inv_aff_input, inv_nrr_input, make_aff_input, aff_2_rig_input, flirt_2_nr_input.

  • inv_aff_input (a pathlike object or string representing an existing file) – Invert an affine transformation. Maps to a command-line argument: -invAff %s (position: -2). Mutually exclusive with inputs: def_input, disp_input, flow_input, comp_input, upd_s_form_input, inv_nrr_input, half_input, make_aff_input, aff_2_rig_input, flirt_2_nr_input.

  • inv_nrr_input (a tuple of the form: (a pathlike object or string representing an existing file, a pathlike object or string representing an existing file)) – Invert a non-linear transformation. Maps to a command-line argument: -invNrr %s %s (position: -2). Mutually exclusive with inputs: def_input, disp_input, flow_input, comp_input, upd_s_form_input, inv_aff_input, half_input, make_aff_input, aff_2_rig_input, flirt_2_nr_input.

  • make_aff_input (a tuple of the form: (a float, a float, a float, a float, a float, a float, a float, a float, a float, a float, a float, a float)) – Make an affine transformation matrix. Maps to a command-line argument: -makeAff %f %f %f %f %f %f %f %f %f %f %f %f (position: -2). Mutually exclusive with inputs: def_input, disp_input, flow_input, comp_input, upd_s_form_input, inv_aff_input, inv_nrr_input, half_input, aff_2_rig_input, flirt_2_nr_input.

  • omp_core_val (an integer) – Number of openmp thread to use. Maps to a command-line argument: -omp %i. (Nipype default value: 1)

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

  • ref1_file (a pathlike object or string representing an existing file) – The input reference/target image. Maps to a command-line argument: -ref %s (position: 0).

  • ref2_file (a pathlike object or string representing an existing file) – The input second reference/target image. Maps to a command-line argument: -ref2 %s (position: 1). Requires inputs: ref1_file.

  • upd_s_form_input (a pathlike object or string representing an existing file) – Update s-form using the affine transformation. Maps to a command-line argument: -updSform %s (position: -3). Mutually exclusive with inputs: def_input, disp_input, flow_input, comp_input, inv_aff_input, inv_nrr_input, half_input, make_aff_input, aff_2_rig_input, flirt_2_nr_input. Requires inputs: upd_s_form_input2.

  • upd_s_form_input2 (a pathlike object or string representing an existing file) – Update s-form using the affine transformation. Maps to a command-line argument: %s (position: -2). Requires inputs: upd_s_form_input.

Outputs:

out_file (a pathlike object or string representing a file) – Output File (transformation in any format).