nipype.interfaces.freesurfer.preprocess module

Provides interfaces to various commands provided by FreeSurfer

ApplyVolTransform

Link to code

Bases: FSCommand

Wrapped executable: mri_vol2vol.

Use FreeSurfer mri_vol2vol to apply a transform.

Examples

>>> from nipype.interfaces.freesurfer import ApplyVolTransform
>>> applyreg = ApplyVolTransform()
>>> applyreg.inputs.source_file = 'structural.nii'
>>> applyreg.inputs.reg_file = 'register.dat'
>>> applyreg.inputs.transformed_file = 'struct_warped.nii'
>>> applyreg.inputs.fs_target = True
>>> applyreg.cmdline
'mri_vol2vol --fstarg --reg register.dat --mov structural.nii --o struct_warped.nii'
Mandatory Inputs:
  • fs_target (a boolean) – Use orig.mgz from subject in regfile as target. Maps to a command-line argument: --fstarg. Mutually exclusive with inputs: target_file, tal, fs_target. Requires inputs: reg_file.

  • fsl_reg_file (a pathlike object or string representing an existing file) – FslRAS-to-fslRAS matrix (FSL format). Maps to a command-line argument: --fsl %s. Mutually exclusive with inputs: reg_file, lta_file, lta_inv_file, fsl_reg_file, xfm_reg_file, reg_header, mni_152_reg, subject.

  • lta_file (a pathlike object or string representing an existing file) – Linear Transform Array file. Maps to a command-line argument: --lta %s. Mutually exclusive with inputs: reg_file, lta_file, lta_inv_file, fsl_reg_file, xfm_reg_file, reg_header, mni_152_reg, subject.

  • lta_inv_file (a pathlike object or string representing an existing file) – LTA, invert. Maps to a command-line argument: --lta-inv %s. Mutually exclusive with inputs: reg_file, lta_file, lta_inv_file, fsl_reg_file, xfm_reg_file, reg_header, mni_152_reg, subject.

  • mni_152_reg (a boolean) – Target MNI152 space. Maps to a command-line argument: --regheader. Mutually exclusive with inputs: reg_file, lta_file, lta_inv_file, fsl_reg_file, xfm_reg_file, reg_header, mni_152_reg, subject.

  • reg_file (a pathlike object or string representing an existing file) – TkRAS-to-tkRAS matrix (tkregister2 format). Maps to a command-line argument: --reg %s. Mutually exclusive with inputs: reg_file, lta_file, lta_inv_file, fsl_reg_file, xfm_reg_file, reg_header, mni_152_reg, subject.

  • reg_header (a boolean) – ScannerRAS-to-ScannerRAS matrix = identity. Maps to a command-line argument: --regheader. Mutually exclusive with inputs: reg_file, lta_file, lta_inv_file, fsl_reg_file, xfm_reg_file, reg_header, mni_152_reg, subject.

  • source_file (a pathlike object or string representing an existing file) – Input volume you wish to transform. Maps to a command-line argument: --mov %s.

  • subject (a string) – Set matrix = identity and use subject for any templates. Maps to a command-line argument: --s %s. Mutually exclusive with inputs: reg_file, lta_file, lta_inv_file, fsl_reg_file, xfm_reg_file, reg_header, mni_152_reg, subject.

  • tal (a boolean) – Map to a sub FOV of MNI305 (with –reg only). Maps to a command-line argument: --tal. Mutually exclusive with inputs: target_file, tal, fs_target.

  • target_file (a pathlike object or string representing an existing file) – Output template volume. Maps to a command-line argument: --targ %s. Mutually exclusive with inputs: target_file, tal, fs_target.

  • xfm_reg_file (a pathlike object or string representing an existing file) – ScannerRAS-to-ScannerRAS matrix (MNI format). Maps to a command-line argument: --xfm %s. Mutually exclusive with inputs: reg_file, lta_file, lta_inv_file, fsl_reg_file, xfm_reg_file, reg_header, mni_152_reg, subject.

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

  • interp (‘trilin’ or ‘nearest’ or ‘cubic’) – Interpolation method (<trilin> or nearest). Maps to a command-line argument: --interp %s.

  • inverse (a boolean) – Sample from target to source. Maps to a command-line argument: --inv.

  • invert_morph (a boolean) – Compute and use the inverse of the non-linear morph to resample the input volume. To be used by –m3z. Maps to a command-line argument: --inv-morph. Requires inputs: m3z_file.

  • m3z_file (a pathlike object or string representing a file) – This is the morph to be applied to the volume. Unless the morph is in mri/transforms (eg.: for talairach.m3z computed by reconall), you will need to specify the full path to this morph and use the –noDefM3zPath flag. Maps to a command-line argument: --m3z %s.

  • no_ded_m3z_path (a boolean) – To be used with the m3z flag. Instructs the code not to look for them3z morph in the default location (SUBJECTS_DIR/subj/mri/transforms), but instead just use the path indicated in –m3z. Maps to a command-line argument: --noDefM3zPath. Requires inputs: m3z_file.

  • no_resample (a boolean) – Do not resample; just change vox2ras matrix. Maps to a command-line argument: --no-resample.

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

  • tal_resolution (a float) – Resolution to sample when using tal. Maps to a command-line argument: --talres %.10f.

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

Outputs:

transformed_file (a pathlike object or string representing an existing file) – Path to output file if used normally.

BBRegister

Link to code

Bases: FSCommand

Wrapped executable: bbregister.

Use FreeSurfer bbregister to register a volume to the Freesurfer anatomical.

This program performs within-subject, cross-modal registration using a boundary-based cost function. It is required that you have an anatomical scan of the subject that has already been recon-all-ed using freesurfer.

Examples

>>> from nipype.interfaces.freesurfer import BBRegister
>>> bbreg = BBRegister(subject_id='me', source_file='structural.nii', init='header', contrast_type='t2')
>>> bbreg.cmdline
'bbregister --t2 --init-header --reg structural_bbreg_me.dat --mov structural.nii --s me'
Mandatory Inputs:
  • contrast_type (‘t1’ or ‘t2’ or ‘bold’ or ‘dti’) – Contrast type of image. Maps to a command-line argument: --%s.

  • source_file (a pathlike object or string representing a file) – Source file to be registered. Maps to a command-line argument: --mov %s.

  • subject_id (a string) – Freesurfer subject id. Maps to a command-line argument: --s %s.

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

  • dof (6 or 9 or 12) – Number of transform degrees of freedom. Maps to a command-line argument: --%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: {})

  • epi_mask (a boolean) – Mask out B0 regions in stages 1 and 2. Maps to a command-line argument: --epi-mask.

  • fsldof (an integer) – Degrees of freedom for initial registration (FSL). Maps to a command-line argument: --fsl-dof %d.

  • init (‘coreg’ or ‘rr’ or ‘spm’ or ‘fsl’ or ‘header’ or ‘best’) – Initialize registration with mri_coreg, spm, fsl, or header. Maps to a command-line argument: --init-%s. Mutually exclusive with inputs: init_reg_file.

  • init_cost_file (a boolean or a pathlike object or string representing a file) – Output initial registration cost file. Maps to a command-line argument: --initcost %s.

  • init_reg_file (a pathlike object or string representing an existing file) – Existing registration file. Maps to a command-line argument: --init-reg %s. Mutually exclusive with inputs: init.

  • intermediate_file (a pathlike object or string representing an existing file) – Intermediate image, e.g. in case of partial FOV. Maps to a command-line argument: --int %s.

  • out_fsl_file (a boolean or a pathlike object or string representing a file) – Write the transformation matrix in FSL FLIRT format. Maps to a command-line argument: --fslmat %s.

  • out_lta_file (a boolean or a pathlike object or string representing a file) – Write the transformation matrix in LTA format. Maps to a command-line argument: --lta %s.

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

  • reg_frame (an integer) – 0-based frame index for 4D source file. Maps to a command-line argument: --frame %d. Mutually exclusive with inputs: reg_middle_frame.

  • reg_middle_frame (a boolean) – Register middle frame of 4D source file. Maps to a command-line argument: --mid-frame. Mutually exclusive with inputs: reg_frame.

  • registered_file (a boolean or a pathlike object or string representing a file) – Output warped sourcefile either True or filename. Maps to a command-line argument: --o %s.

  • spm_nifti (a boolean) – Force use of nifti rather than analyze with SPM. Maps to a command-line argument: --spm-nii.

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

Outputs:
  • init_cost_file (a pathlike object or string representing an existing file) – Output initial registration cost file.

  • min_cost_file (a pathlike object or string representing an existing file) – Output registration minimum cost file.

  • out_fsl_file (a pathlike object or string representing an existing file) – Output FLIRT-style registration file.

  • out_lta_file (a pathlike object or string representing an existing file) – Output LTA-style registration file.

  • out_reg_file (a pathlike object or string representing an existing file) – Output registration file.

  • registered_file (a pathlike object or string representing an existing file) – Registered and resampled source file.

CALabel

Link to code

Bases: FSCommandOpenMP

Wrapped executable: mri_ca_label.

Label subcortical structures based in GCA model.

See also

For complete details, see the FS Documentation

Examples

>>> from nipype.interfaces import freesurfer
>>> ca_label = freesurfer.CALabel()
>>> ca_label.inputs.in_file = "norm.mgz"
>>> ca_label.inputs.out_file = "out.mgz"
>>> ca_label.inputs.transform = "trans.mat"
>>> ca_label.inputs.template = "Template_6.nii" # in practice use .gcs extension
>>> ca_label.cmdline
'mri_ca_label norm.mgz trans.mat Template_6.nii out.mgz'
Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Input volume for CALabel. Maps to a command-line argument: %s (position: -4).

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

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

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

Optional Inputs:
  • align (a boolean) – Align CALabel. Maps to a command-line argument: -align.

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

  • aseg (a pathlike object or string representing an existing file) – Undocumented flag. Autorecon3 uses ../mri/aseg.presurf.mgz as input file. Maps to a command-line argument: -aseg %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_vol (a pathlike object or string representing an existing file) – Set input volume. Maps to a command-line argument: -r %s.

  • intensities (a pathlike object or string representing an existing file) – Input label intensities file(used in longitudinal processing). Maps to a command-line argument: -r %s.

  • label (a pathlike object or string representing an existing file) – Undocumented flag. Autorecon3 uses ../label/{hemisphere}.cortex.label as input file. Maps to a command-line argument: -l %s.

  • no_big_ventricles (a boolean) – No big ventricles. Maps to a command-line argument: -nobigventricles.

  • num_threads (an integer) – Allows for specifying more threads.

  • prior (a float) – Prior for CALabel. Maps to a command-line argument: -prior %.1f.

  • relabel_unlikely (a tuple of the form: (an integer, a float)) – Reclassify voxels at least some std devs from the mean using some size Gaussian window. Maps to a command-line argument: -relabel_unlikely %d %.1f.

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

Outputs:

out_file (a pathlike object or string representing a file) – Output volume from CALabel.

CANormalize

Link to code

Bases: FSCommand

Wrapped executable: mri_ca_normalize.

This program creates a normalized volume using the brain volume and an input gca file.

See also

For complete details, see the FS Documentation.

Examples

>>> from nipype.interfaces import freesurfer
>>> ca_normalize = freesurfer.CANormalize()
>>> ca_normalize.inputs.in_file = "T1.mgz"
>>> ca_normalize.inputs.atlas = "atlas.nii.gz" # in practice use .gca atlases
>>> ca_normalize.inputs.transform = "trans.mat" # in practice use .lta transforms
>>> ca_normalize.cmdline
'mri_ca_normalize T1.mgz atlas.nii.gz trans.mat T1_norm.mgz'
Mandatory Inputs:
  • atlas (a pathlike object or string representing an existing file) – The atlas file in gca format. Maps to a command-line argument: %s (position: -3).

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

  • transform (a pathlike object or string representing an existing file) – The transform file in lta format. 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.

  • control_points (a pathlike object or string representing a file) – File name for the output control points. Maps to a command-line argument: -c %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: {})

  • long_file (a pathlike object or string representing a file) – Undocumented flag used in longitudinal processing. Maps to a command-line argument: -long %s.

  • mask (a pathlike object or string representing an existing file) – Specifies volume to use as mask. Maps to a command-line argument: -mask %s.

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

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

Outputs:
  • control_points (a pathlike object or string representing a file) – The output control points for Normalize.

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

CARegister

Link to code

Bases: FSCommandOpenMP

Wrapped executable: mri_ca_register.

Generates a multi-dimensional talairach transform from a gca file and talairach.lta file

See also

For complete details, see the FS Documentation

Examples

>>> from nipype.interfaces import freesurfer
>>> ca_register = freesurfer.CARegister()
>>> ca_register.inputs.in_file = "norm.mgz"
>>> ca_register.inputs.out_file = "talairach.m3z"
>>> ca_register.cmdline
'mri_ca_register norm.mgz talairach.m3z'
Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – The input volume for CARegister. Maps to a command-line argument: %s (position: -3).

Optional Inputs:
  • A (an integer) – Undocumented flag used in longitudinal processing. Maps to a command-line argument: -A %d.

  • align (a string) – Specifies when to perform alignment. Maps to a command-line argument: -align-%s.

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

  • invert_and_save (a boolean) – Invert and save the .m3z multi-dimensional talaraich transform to x, y, and z .mgz files. Maps to a command-line argument: -invert-and-save (position: -4).

  • l_files (a list of items which are a pathlike object or string representing a file) – Undocumented flag used in longitudinal processing. Maps to a command-line argument: -l %s.

  • levels (an integer) – Defines how many surrounding voxels will be used in interpolations, default is 6. Maps to a command-line argument: -levels %d.

  • mask (a pathlike object or string representing an existing file) – Specifies volume to use as mask. Maps to a command-line argument: -mask %s.

  • no_big_ventricles (a boolean) – No big ventricles. Maps to a command-line argument: -nobigventricles.

  • num_threads (an integer) – Allows for specifying more threads.

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

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

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

  • transform (a pathlike object or string representing an existing file) – Specifies transform in lta format. Maps to a command-line argument: -T %s.

Outputs:

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

ConcatenateLTA

Link to code

Bases: FSCommand

Wrapped executable: mri_concatenate_lta.

Concatenates two consecutive LTA transformations into one overall transformation

Out = LTA2*LTA1

Examples

>>> from nipype.interfaces.freesurfer import ConcatenateLTA
>>> conc_lta = ConcatenateLTA()
>>> conc_lta.inputs.in_lta1 = 'lta1.lta'
>>> conc_lta.inputs.in_lta2 = 'lta2.lta'
>>> conc_lta.cmdline
'mri_concatenate_lta lta1.lta lta2.lta lta1_concat.lta'

You can use ‘identity.nofile’ as the filename for in_lta2, e.g.:

>>> conc_lta.inputs.in_lta2 = 'identity.nofile'
>>> conc_lta.inputs.invert_1 = True
>>> conc_lta.inputs.out_file = 'inv1.lta'
>>> conc_lta.cmdline
'mri_concatenate_lta -invert1 lta1.lta identity.nofile inv1.lta'

To create a RAS2RAS transform:

>>> conc_lta.inputs.out_type = 'RAS2RAS'
>>> conc_lta.cmdline
'mri_concatenate_lta -invert1 -out_type 1 lta1.lta identity.nofile inv1.lta'
Mandatory Inputs:
  • in_lta1 (a pathlike object or string representing an existing file) – Maps some src1 to dst1. Maps to a command-line argument: %s (position: -3).

  • in_lta2 (a pathlike object or string representing an existing file or ‘identity.nofile’) – Maps dst1(src2) to dst2. 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: {})

  • invert_1 (a boolean) – Invert in_lta1 before applying it. Maps to a command-line argument: -invert1.

  • invert_2 (a boolean) – Invert in_lta2 before applying it. Maps to a command-line argument: -invert2.

  • invert_out (a boolean) – Invert output LTA. Maps to a command-line argument: -invertout.

  • out_file (a pathlike object or string representing a file) – The combined LTA maps: src1 to dst2 = LTA2*LTA1. Maps to a command-line argument: %s (position: -1).

  • out_type (‘VOX2VOX’ or ‘RAS2RAS’) – Set final LTA type. Maps to a command-line argument: -out_type %d.

  • subject (a string) – Set subject in output LTA. Maps to a command-line argument: -subject %s.

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

  • tal_source_file (a pathlike object or string representing an existing file) – If in_lta2 is talairach.xfm, specify source for talairach. Maps to a command-line argument: -tal %s (position: -5). Requires inputs: tal_template_file.

  • tal_template_file (a pathlike object or string representing an existing file) – If in_lta2 is talairach.xfm, specify template for talairach. Maps to a command-line argument: %s (position: -4). Requires inputs: tal_source_file.

Outputs:

out_file (a pathlike object or string representing a file) – The combined LTA maps: src1 to dst2 = LTA2*LTA1.

DICOMConvert

Link to code

Bases: FSCommand

Wrapped executable: mri_convert.

use fs mri_convert to convert dicom files

Examples

>>> from nipype.interfaces.freesurfer import DICOMConvert
>>> cvt = DICOMConvert()
>>> cvt.inputs.dicom_dir = 'dicomdir'
>>> cvt.inputs.file_mapping = [('nifti', '*.nii'), ('info', 'dicom*.txt'), ('dti', '*dti.bv*')]
Mandatory Inputs:
  • base_output_dir (a pathlike object or string representing a directory) – Directory in which subject directories are created.

  • dicom_dir (a pathlike object or string representing an existing directory) – Dicom directory from which to convert dicom files.

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

  • dicom_info (a pathlike object or string representing an existing file) – File containing summary information from mri_parse_sdcmdir.

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

  • file_mapping (a list of items which are a tuple of the form: (a string, a string)) – Defines the output fields of interface.

  • ignore_single_slice (a boolean) – Ignore volumes containing a single slice. Requires inputs: dicom_info.

  • out_type (‘cor’ or ‘mgh’ or ‘mgz’ or ‘minc’ or ‘analyze’ or ‘analyze4d’ or ‘spm’ or ‘afni’ or ‘brik’ or ‘bshort’ or ‘bfloat’ or ‘sdt’ or ‘outline’ or ‘otl’ or ‘gdf’ or ‘nifti1’ or ‘nii’ or ‘niigz’) – Defines the type of output file produced. (Nipype default value: niigz)

  • seq_list (a list of items which are a string) – List of pulse sequence names to be converted. Requires inputs: dicom_info.

  • subject_dir_template (a string) – Template for subject directory name. (Nipype default value: S.%04d)

  • subject_id (any value) – Subject identifier to insert into template.

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

property DICOMConvert.cmdline

command plus any arguments (args) validates arguments and generates command line

EditWMwithAseg

Link to code

Bases: FSCommand

Wrapped executable: mri_edit_wm_with_aseg.

Edits a wm file using a segmentation

Examples

>>> from nipype.interfaces.freesurfer import EditWMwithAseg
>>> editwm = EditWMwithAseg()
>>> editwm.inputs.in_file = "T1.mgz"
>>> editwm.inputs.brain_file = "norm.mgz"
>>> editwm.inputs.seg_file = "aseg.mgz"
>>> editwm.inputs.out_file = "wm.asegedit.mgz"
>>> editwm.inputs.keep_in = True
>>> editwm.cmdline
'mri_edit_wm_with_aseg -keep-in T1.mgz norm.mgz aseg.mgz wm.asegedit.mgz'
Mandatory Inputs:
  • brain_file (a pathlike object or string representing an existing file) – Input brain/T1 file. Maps to a command-line argument: %s (position: -3).

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

  • out_file (a pathlike object or string representing a file) – File to be written as output. Maps to a command-line argument: %s (position: -1).

  • seg_file (a pathlike object or string representing an existing file) – Input presurf segmentation 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: {})

  • keep_in (a boolean) – Keep edits as found in input volume. Maps to a command-line argument: -keep-in.

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

Outputs:

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

FitMSParams

Link to code

Bases: FSCommand

Wrapped executable: mri_ms_fitparms.

Estimate tissue parameters from a set of FLASH images.

Examples

>>> from nipype.interfaces.freesurfer import FitMSParams
>>> msfit = FitMSParams()
>>> msfit.inputs.in_files = ['flash_05.mgz', 'flash_30.mgz']
>>> msfit.inputs.out_dir = 'flash_parameters'
>>> msfit.cmdline
'mri_ms_fitparms  flash_05.mgz flash_30.mgz flash_parameters'
Mandatory Inputs:

in_files (a list of items which are a pathlike object or string representing an existing file) – List of FLASH images (must be in mgh format). 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: {})

  • flip_list (a list of items which are an integer) – List of flip angles of the input files.

  • out_dir (a pathlike object or string representing a directory) – Directory to store output in. Maps to a command-line argument: %s (position: -1).

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

  • te_list (a list of items which are a float) – List of TEs of the input files (in msec).

  • tr_list (a list of items which are an integer) – List of TRs of the input files (in msec).

  • xfm_list (a list of items which are a pathlike object or string representing an existing file) – List of transform files to apply to each FLASH image.

Outputs:
  • pd_image (a pathlike object or string representing an existing file) – Image of estimated proton density values.

  • t1_image (a pathlike object or string representing an existing file) – Image of estimated T1 relaxation values.

  • t2star_image (a pathlike object or string representing an existing file) – Image of estimated T2* values.

MNIBiasCorrection

Link to code

Bases: FSCommand

Wrapped executable: mri_nu_correct.mni.

Wrapper for nu_correct, a program from the Montreal Neurological Institute (MNI) used for correcting intensity non-uniformity (ie, bias fields). You must have the MNI software installed on your system to run this. See [www.bic.mni.mcgill.ca/software/N3] for more info.

mri_nu_correct.mni uses float internally instead of uchar. It also rescales the output so that the global mean is the same as that of the input. These two changes are linked and can be turned off with –no-float

Examples

>>> from nipype.interfaces.freesurfer import MNIBiasCorrection
>>> correct = MNIBiasCorrection()
>>> correct.inputs.in_file = "norm.mgz"
>>> correct.inputs.iterations = 6
>>> correct.inputs.protocol_iterations = 1000
>>> correct.inputs.distance = 50
>>> correct.cmdline
'mri_nu_correct.mni --distance 50 --i norm.mgz --n 6 --o norm_output.mgz --proto-iters 1000'

References

[http://freesurfer.net/fswiki/mri_nu_correct.mni] [http://www.bic.mni.mcgill.ca/software/N3] [https://github.com/BIC-MNI/N3]

Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – Input volume. Input can be any format accepted by mri_convert. 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.

  • distance (an integer) – N3 -distance option. Maps to a command-line argument: --distance %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: {})

  • iterations (an integer) – Number of iterations to run nu_correct. Default is 4. This is the number of times that nu_correct is repeated (ie, using the output from the previous run as the input for the next). This is different than the -iterations option to nu_correct. Maps to a command-line argument: --n %d. (Nipype default value: 4)

  • mask (a pathlike object or string representing an existing file) – Brainmask volume. Input can be any format accepted by mri_convert. Maps to a command-line argument: --mask %s.

  • no_rescale (a boolean) – Do not rescale so that global mean of output == input global mean. Maps to a command-line argument: --no-rescale.

  • out_file (a pathlike object or string representing a file) – Output volume. Output can be any format accepted by mri_convert. If the output format is COR, then the directory must exist. Maps to a command-line argument: --o %s.

  • protocol_iterations (an integer) – Passes Np as argument of the -iterations flag of nu_correct. This is different than the –n flag above. Default is not to pass nu_correct the -iterations flag. Maps to a command-line argument: --proto-iters %d.

  • shrink (an integer) – Shrink parameter for finer sampling (default is 4). Maps to a command-line argument: --shrink %d.

  • stop (a float) – Convergence threshold below which iteration stops (suggest 0.01 to 0.0001). Maps to a command-line argument: --stop %f.

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

  • transform (a pathlike object or string representing an existing file) – Tal.xfm. Use mri_make_uchar instead of conforming. Maps to a command-line argument: --uchar %s.

Outputs:

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

MRIConvert

Link to code

Bases: FSCommand

Wrapped executable: mri_convert.

use fs mri_convert to manipulate files

Note

Adds niigz as an output type option

Examples

>>> mc = MRIConvert()
>>> mc.inputs.in_file = 'structural.nii'
>>> mc.inputs.out_file = 'outfile.mgz'
>>> mc.inputs.out_type = 'mgz'
>>> mc.cmdline
'mri_convert --out_type mgz --input_volume structural.nii --output_volume outfile.mgz'
Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – File to read/convert. Maps to a command-line argument: --input_volume %s (position: -2).

Optional Inputs:
  • apply_inv_transform (a pathlike object or string representing an existing file) – Apply inverse transformation xfm file. Maps to a command-line argument: --apply_inverse_transform %s.

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

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

  • ascii (a boolean) – Save output as ascii col>row>slice>frame. Maps to a command-line argument: --ascii.

  • autoalign_matrix (a pathlike object or string representing an existing file) – Text file with autoalign matrix. Maps to a command-line argument: --autoalign %s.

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

  • conform (a boolean) – Conform to 1mm voxel size in coronal slice direction with 256^3 or more. Maps to a command-line argument: --conform.

  • conform_min (a boolean) – Conform to smallest size. Maps to a command-line argument: --conform_min.

  • conform_size (a float) – Conform to size_in_mm. Maps to a command-line argument: --conform_size %s.

  • crop_center (a tuple of the form: (an integer, an integer, an integer)) – <x> <y> <z> crop to 256 around center (x, y, z). Maps to a command-line argument: --crop %d %d %d.

  • crop_gdf (a boolean) – Apply GDF cropping. Maps to a command-line argument: --crop_gdf.

  • crop_size (a tuple of the form: (an integer, an integer, an integer)) – <dx> <dy> <dz> crop to size <dx, dy, dz>. Maps to a command-line argument: --cropsize %d %d %d.

  • cut_ends (an integer) – Remove ncut slices from the ends. Maps to a command-line argument: --cutends %d.

  • cw256 (a boolean) – Confrom to dimensions of 256^3. Maps to a command-line argument: --cw256.

  • devolve_transform (a string) – Subject id. Maps to a command-line argument: --devolvexfm %s.

  • drop_n (an integer) – Drop the last n frames. Maps to a command-line argument: --ndrop %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: {})

  • fill_parcellation (a boolean) – Fill parcellation. Maps to a command-line argument: --fill_parcellation.

  • force_ras (a boolean) – Use default when orientation info absent. Maps to a command-line argument: --force_ras_good.

  • frame (an integer) – Keep only 0-based frame number. Maps to a command-line argument: --frame %d.

  • frame_subsample (a tuple of the form: (an integer, an integer, an integer)) – Start delta end : frame subsampling (end = -1 for end). Maps to a command-line argument: --fsubsample %d %d %d.

  • fwhm (a float) – Smooth input volume by fwhm mm. Maps to a command-line argument: --fwhm %f.

  • in_center (a list of at most 3 items which are a float) – <R coordinate> <A coordinate> <S coordinate>. Maps to a command-line argument: --in_center %s.

  • in_i_dir (a tuple of the form: (a float, a float, a float)) – <R direction> <A direction> <S direction>. Maps to a command-line argument: --in_i_direction %f %f %f.

  • in_i_size (an integer) – Input i size. Maps to a command-line argument: --in_i_size %d.

  • in_info (a boolean) – Display input info. Maps to a command-line argument: --in_info.

  • in_j_dir (a tuple of the form: (a float, a float, a float)) – <R direction> <A direction> <S direction>. Maps to a command-line argument: --in_j_direction %f %f %f.

  • in_j_size (an integer) – Input j size. Maps to a command-line argument: --in_j_size %d.

  • in_k_dir (a tuple of the form: (a float, a float, a float)) – <R direction> <A direction> <S direction>. Maps to a command-line argument: --in_k_direction %f %f %f.

  • in_k_size (an integer) – Input k size. Maps to a command-line argument: --in_k_size %d.

  • in_like (a pathlike object or string representing an existing file) – Input looks like. Maps to a command-line argument: --in_like %s.

  • in_matrix (a boolean) – Display input matrix. Maps to a command-line argument: --in_matrix.

  • in_orientation (‘LAI’ or ‘LIA’ or ‘ALI’ or ‘AIL’ or ‘ILA’ or ‘IAL’ or ‘LAS’ or ‘LSA’ or ‘ALS’ or ‘ASL’ or ‘SLA’ or ‘SAL’ or ‘LPI’ or ‘LIP’ or ‘PLI’ or ‘PIL’ or ‘ILP’ or ‘IPL’ or ‘LPS’ or ‘LSP’ or ‘PLS’ or ‘PSL’ or ‘SLP’ or ‘SPL’ or ‘RAI’ or ‘RIA’ or ‘ARI’ or ‘AIR’ or ‘IRA’ or ‘IAR’ or ‘RAS’ or ‘RSA’ or ‘ARS’ or ‘ASR’ or ‘SRA’ or ‘SAR’ or ‘RPI’ or ‘RIP’ or ‘PRI’ or ‘PIR’ or ‘IRP’ or ‘IPR’ or ‘RPS’ or ‘RSP’ or ‘PRS’ or ‘PSR’ or ‘SRP’ or ‘SPR’) – Specify the input orientation. Maps to a command-line argument: --in_orientation %s.

  • in_scale (a float) – Input intensity scale factor. Maps to a command-line argument: --scale %f.

  • in_stats (a boolean) – Display input stats. Maps to a command-line argument: --in_stats.

  • in_type (‘cor’ or ‘mgh’ or ‘mgz’ or ‘minc’ or ‘analyze’ or ‘analyze4d’ or ‘spm’ or ‘afni’ or ‘brik’ or ‘bshort’ or ‘bfloat’ or ‘sdt’ or ‘outline’ or ‘otl’ or ‘gdf’ or ‘nifti1’ or ‘nii’ or ‘niigz’ or ‘ge’ or ‘gelx’ or ‘lx’ or ‘ximg’ or ‘siemens’ or ‘dicom’ or ‘siemens_dicom’) – Input file type. Maps to a command-line argument: --in_type %s.

  • invert_contrast (a float) – Threshold for inversting contrast. Maps to a command-line argument: --invert_contrast %f.

  • midframe (a boolean) – Keep only the middle frame. Maps to a command-line argument: --mid-frame.

  • no_change (a boolean) – Don’t change type of input to that of template. Maps to a command-line argument: --nochange.

  • no_scale (a boolean) – Dont rescale values for COR. Maps to a command-line argument: --no_scale 1.

  • no_translate (a boolean) – ???. Maps to a command-line argument: --no_translate.

  • no_write (a boolean) – Do not write output. Maps to a command-line argument: --no_write.

  • out_center (a tuple of the form: (a float, a float, a float)) – <R coordinate> <A coordinate> <S coordinate>. Maps to a command-line argument: --out_center %f %f %f.

  • out_datatype (‘uchar’ or ‘short’ or ‘int’ or ‘float’) – Output data type <uchar|short|int|float>. Maps to a command-line argument: --out_data_type %s.

  • out_file (a pathlike object or string representing a file) – Output filename or True to generate one. Maps to a command-line argument: --output_volume %s (position: -1).

  • out_i_count (an integer) – Some count ?? in i direction. Maps to a command-line argument: --out_i_count %d.

  • out_i_dir (a tuple of the form: (a float, a float, a float)) – <R direction> <A direction> <S direction>. Maps to a command-line argument: --out_i_direction %f %f %f.

  • out_i_size (an integer) – Output i size. Maps to a command-line argument: --out_i_size %d.

  • out_info (a boolean) – Display output info. Maps to a command-line argument: --out_info.

  • out_j_count (an integer) – Some count ?? in j direction. Maps to a command-line argument: --out_j_count %d.

  • out_j_dir (a tuple of the form: (a float, a float, a float)) – <R direction> <A direction> <S direction>. Maps to a command-line argument: --out_j_direction %f %f %f.

  • out_j_size (an integer) – Output j size. Maps to a command-line argument: --out_j_size %d.

  • out_k_count (an integer) – Some count ?? in k direction. Maps to a command-line argument: --out_k_count %d.

  • out_k_dir (a tuple of the form: (a float, a float, a float)) – <R direction> <A direction> <S direction>. Maps to a command-line argument: --out_k_direction %f %f %f.

  • out_k_size (an integer) – Output k size. Maps to a command-line argument: --out_k_size %d.

  • out_matrix (a boolean) – Display output matrix. Maps to a command-line argument: --out_matrix.

  • out_orientation (‘LAI’ or ‘LIA’ or ‘ALI’ or ‘AIL’ or ‘ILA’ or ‘IAL’ or ‘LAS’ or ‘LSA’ or ‘ALS’ or ‘ASL’ or ‘SLA’ or ‘SAL’ or ‘LPI’ or ‘LIP’ or ‘PLI’ or ‘PIL’ or ‘ILP’ or ‘IPL’ or ‘LPS’ or ‘LSP’ or ‘PLS’ or ‘PSL’ or ‘SLP’ or ‘SPL’ or ‘RAI’ or ‘RIA’ or ‘ARI’ or ‘AIR’ or ‘IRA’ or ‘IAR’ or ‘RAS’ or ‘RSA’ or ‘ARS’ or ‘ASR’ or ‘SRA’ or ‘SAR’ or ‘RPI’ or ‘RIP’ or ‘PRI’ or ‘PIR’ or ‘IRP’ or ‘IPR’ or ‘RPS’ or ‘RSP’ or ‘PRS’ or ‘PSR’ or ‘SRP’ or ‘SPR’) – Specify the output orientation. Maps to a command-line argument: --out_orientation %s.

  • out_scale (a float) – Output intensity scale factor. Maps to a command-line argument: --out-scale %d.

  • out_stats (a boolean) – Display output stats. Maps to a command-line argument: --out_stats.

  • out_type (‘cor’ or ‘mgh’ or ‘mgz’ or ‘minc’ or ‘analyze’ or ‘analyze4d’ or ‘spm’ or ‘afni’ or ‘brik’ or ‘bshort’ or ‘bfloat’ or ‘sdt’ or ‘outline’ or ‘otl’ or ‘gdf’ or ‘nifti1’ or ‘nii’ or ‘niigz’) – Output file type. Maps to a command-line argument: --out_type %s.

  • parse_only (a boolean) – Parse input only. Maps to a command-line argument: --parse_only.

  • read_only (a boolean) – Read the input volume. Maps to a command-line argument: --read_only.

  • reorder (a tuple of the form: (an integer, an integer, an integer)) – Olddim1 olddim2 olddim3. Maps to a command-line argument: --reorder %d %d %d.

  • resample_type (‘interpolate’ or ‘weighted’ or ‘nearest’ or ‘sinc’ or ‘cubic’) – <interpolate|weighted|nearest|sinc|cubic> (default is interpolate). Maps to a command-line argument: --resample_type %s.

  • reslice_like (a pathlike object or string representing an existing file) – Reslice output to match file. Maps to a command-line argument: --reslice_like %s.

  • sdcm_list (a pathlike object or string representing an existing file) – List of DICOM files for conversion. Maps to a command-line argument: --sdcmlist %s.

  • skip_n (an integer) – Skip the first n frames. Maps to a command-line argument: --nskip %d.

  • slice_bias (a float) – Apply half-cosine bias field. Maps to a command-line argument: --slice-bias %f.

  • slice_crop (a tuple of the form: (an integer, an integer)) – S_start s_end : keep slices s_start to s_end. Maps to a command-line argument: --slice-crop %d %d.

  • slice_reverse (a boolean) – Reverse order of slices, update vox2ras. Maps to a command-line argument: --slice-reverse.

  • smooth_parcellation (a boolean) – Smooth parcellation. Maps to a command-line argument: --smooth_parcellation.

  • sphinx (a boolean) – Change orientation info to sphinx. Maps to a command-line argument: --sphinx.

  • split (a boolean) – Split output frames into separate output files. Maps to a command-line argument: --split.

  • status_file (a pathlike object or string representing a file) – Status file for DICOM conversion. Maps to a command-line argument: --status %s.

  • subject_name (a string) – Subject name ???. Maps to a command-line argument: --subject_name %s.

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

  • te (an integer) – TE in msec. Maps to a command-line argument: -te %d.

  • template_info (a boolean) – Dump info about template. Maps to a command-line argument: --template_info.

  • template_type (‘cor’ or ‘mgh’ or ‘mgz’ or ‘minc’ or ‘analyze’ or ‘analyze4d’ or ‘spm’ or ‘afni’ or ‘brik’ or ‘bshort’ or ‘bfloat’ or ‘sdt’ or ‘outline’ or ‘otl’ or ‘gdf’ or ‘nifti1’ or ‘nii’ or ‘niigz’ or ‘ge’ or ‘gelx’ or ‘lx’ or ‘ximg’ or ‘siemens’ or ‘dicom’ or ‘siemens_dicom’) – Template file type. Maps to a command-line argument: --template_type %s.

  • ti (an integer) – TI in msec (note upper case flag). Maps to a command-line argument: -ti %d.

  • tr (an integer) – TR in msec. Maps to a command-line argument: -tr %d.

  • unwarp_gradient (a boolean) – Unwarp gradient nonlinearity. Maps to a command-line argument: --unwarp_gradient_nonlinearity.

  • vox_size (a tuple of the form: (a float, a float, a float)) – <size_x> <size_y> <size_z> specify the size (mm) - useful for upsampling or downsampling. Maps to a command-line argument: -voxsize %f %f %f.

  • zero_ge_z_offset (a boolean) – Zero ge z offset ???. Maps to a command-line argument: --zero_ge_z_offset.

  • zero_outlines (a boolean) – Zero outlines. Maps to a command-line argument: --zero_outlines.

Outputs:

out_file (a list of items which are a pathlike object or string representing an existing file) – Converted output file.

MRIConvert.filemap = {'afni': 'brik', 'analyze': 'img', 'analyze4d': 'img', 'bfloat': 'bfloat', 'brik': 'brik', 'bshort': 'bshort', 'cor': 'cor', 'mgh': 'mgh', 'mgz': 'mgz', 'minc': 'mnc', 'nifti1': 'img', 'nii': 'nii', 'niigz': 'nii.gz', 'spm': 'img'}

MRIsCALabel

Link to code

Bases: FSCommandOpenMP

Wrapped executable: mris_ca_label.

For a single subject, produces an annotation file, in which each cortical surface vertex is assigned a neuroanatomical label.This automatic procedure employs data from a previously-prepared atlas file. An atlas file is created from a training set, capturing region data manually drawn by neuroanatomists combined with statistics on variability correlated to geometric information derived from the cortical model (sulcus and curvature). Besides the atlases provided with FreeSurfer, new ones can be prepared using mris_ca_train).

Examples

>>> from nipype.interfaces import freesurfer
>>> ca_label = freesurfer.MRIsCALabel()
>>> ca_label.inputs.subject_id = "test"
>>> ca_label.inputs.hemisphere = "lh"
>>> ca_label.inputs.canonsurf = "lh.pial"
>>> ca_label.inputs.curv = "lh.pial"
>>> ca_label.inputs.sulc = "lh.pial"
>>> ca_label.inputs.classifier = "im1.nii" # in pracice, use .gcs extension
>>> ca_label.inputs.smoothwm = "lh.pial"
>>> ca_label.cmdline
'mris_ca_label test lh lh.pial im1.nii lh.aparc.annot'
Mandatory Inputs:
  • canonsurf (a pathlike object or string representing an existing file) – Input canonical surface file. Maps to a command-line argument: %s (position: -3).

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

  • curv (a pathlike object or string representing an existing file) – Implicit input {hemisphere}.curv.

  • hemisphere (‘lh’ or ‘rh’) – Hemisphere (‘lh’ or ‘rh’). Maps to a command-line argument: %s (position: -4).

  • smoothwm (a pathlike object or string representing an existing file) – Implicit input {hemisphere}.smoothwm.

  • subject_id (a string) – Subject name or ID. Maps to a command-line argument: %s (position: -5). (Nipype default value: subject_id)

  • sulc (a pathlike object or string representing an existing file) – Implicit input {hemisphere}.sulc.

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

  • aseg (a pathlike object or string representing an existing file) – Undocumented flag. Autorecon3 uses ../mri/aseg.presurf.mgz as input file. Maps to a command-line argument: -aseg %s.

  • copy_inputs (a boolean) – Copies implicit inputs to node directory and creates a temp subjects_directory. Use this when running as a node.

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

  • label (a pathlike object or string representing an existing file) – Undocumented flag. Autorecon3 uses ../label/{hemisphere}.cortex.label as input file. Maps to a command-line argument: -l %s.

  • num_threads (an integer) – Allows for specifying more threads.

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

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

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

Outputs:

out_file (a pathlike object or string representing a file) – Output volume from MRIsCALabel.

MRIsCALabel.run(**inputs)

Execute this interface.

This interface will not raise an exception if runtime.returncode is non-zero.

Parameters:
  • cwd (specify a folder where the interface should be run)

  • inputs (allows the interface settings to be updated)

Returns:

results – A copy of the instance that was executed, provenance information and, if successful, results

Return type:

nipype.interfaces.base.support.InterfaceResult

Normalize

Link to code

Bases: FSCommand

Wrapped executable: mri_normalize.

Normalize the white-matter, optionally based on control points. The input volume is converted into a new volume where white matter image values all range around 110.

Examples

>>> from nipype.interfaces import freesurfer
>>> normalize = freesurfer.Normalize()
>>> normalize.inputs.in_file = "T1.mgz"
>>> normalize.inputs.gradient = 1
>>> normalize.cmdline
'mri_normalize -g 1 T1.mgz T1_norm.mgz'
Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – The input file for Normalize. 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: {})

  • gradient (an integer) – Use max intensity/mm gradient g (default=1). Maps to a command-line argument: -g %d.

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

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

  • segmentation (a pathlike object or string representing an existing file) – The input segmentation for Normalize. Maps to a command-line argument: -aseg %s.

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

  • transform (a pathlike object or string representing an existing file) – Transform file from the header of the input file.

Outputs:

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

ParseDICOMDir

Link to code

Bases: FSCommand

Wrapped executable: mri_parse_sdcmdir.

Uses mri_parse_sdcmdir to get information from dicom directories

Examples

>>> from nipype.interfaces.freesurfer import ParseDICOMDir
>>> dcminfo = ParseDICOMDir()
>>> dcminfo.inputs.dicom_dir = '.'
>>> dcminfo.inputs.sortbyrun = True
>>> dcminfo.inputs.summarize = True
>>> dcminfo.cmdline
'mri_parse_sdcmdir --d . --o dicominfo.txt --sortbyrun --summarize'
Mandatory Inputs:

dicom_dir (a pathlike object or string representing an existing directory) – Path to siemens dicom directory. Maps to a command-line argument: --d %s.

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

  • dicom_info_file (a pathlike object or string representing a file) – File to which results are written. Maps to a command-line argument: --o %s. (Nipype default value: dicominfo.txt)

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

  • sortbyrun (a boolean) – Assign run numbers. Maps to a command-line argument: --sortbyrun.

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

  • summarize (a boolean) – Only print out info for run leaders. Maps to a command-line argument: --summarize.

Outputs:

dicom_info_file (a pathlike object or string representing an existing file) – Text file containing dicom information.

ReconAll

Link to code

Bases: CommandLine

Wrapped executable: recon-all.

Uses recon-all to generate surfaces and parcellations of structural data from anatomical images of a subject.

Examples

>>> from nipype.interfaces.freesurfer import ReconAll
>>> reconall = ReconAll()
>>> reconall.inputs.subject_id = 'foo'
>>> reconall.inputs.directive = 'all'
>>> reconall.inputs.subjects_dir = '.'
>>> reconall.inputs.T1_files = ['structural.nii']
>>> reconall.cmdline
'recon-all -all -i structural.nii -subjid foo -sd .'
>>> reconall.inputs.flags = "-qcache"
>>> reconall.cmdline
'recon-all -all -i structural.nii -qcache -subjid foo -sd .'
>>> reconall.inputs.flags = ["-cw256", "-qcache"]
>>> reconall.cmdline
'recon-all -all -i structural.nii -cw256 -qcache -subjid foo -sd .'

Hemisphere may be specified regardless of directive:

>>> reconall.inputs.flags = []
>>> reconall.inputs.hemi = 'lh'
>>> reconall.cmdline
'recon-all -all -i structural.nii -hemi lh -subjid foo -sd .'

-autorecon-hemi uses the -hemi input to specify the hemisphere to operate upon:

>>> reconall.inputs.directive = 'autorecon-hemi'
>>> reconall.cmdline
'recon-all -autorecon-hemi lh -i structural.nii -subjid foo -sd .'

Hippocampal subfields can accept T1 and T2 images:

>>> reconall_subfields = ReconAll()
>>> reconall_subfields.inputs.subject_id = 'foo'
>>> reconall_subfields.inputs.directive = 'all'
>>> reconall_subfields.inputs.subjects_dir = '.'
>>> reconall_subfields.inputs.T1_files = ['structural.nii']
>>> reconall_subfields.inputs.hippocampal_subfields_T1 = True
>>> reconall_subfields.cmdline
'recon-all -all -i structural.nii -hippocampal-subfields-T1 -subjid foo -sd .'
>>> reconall_subfields.inputs.hippocampal_subfields_T2 = (
... 'structural.nii', 'test')
>>> reconall_subfields.cmdline
'recon-all -all -i structural.nii -hippocampal-subfields-T1T2 structural.nii test -subjid foo -sd .'
>>> reconall_subfields.inputs.hippocampal_subfields_T1 = False
>>> reconall_subfields.cmdline
'recon-all -all -i structural.nii -hippocampal-subfields-T2 structural.nii test -subjid foo -sd .'

Base template creation for longitudinal pipeline: >>> baserecon = ReconAll() >>> baserecon.inputs.base_template_id = ‘sub-template’ >>> baserecon.inputs.base_timepoint_ids = [‘ses-1’,’ses-2’] >>> baserecon.inputs.directive = ‘all’ >>> baserecon.inputs.subjects_dir = ‘.’ >>> baserecon.cmdline ‘recon-all -all -base sub-template -base-tp ses-1 -base-tp ses-2 -sd .’

Longitudinal timepoint run: >>> longrecon = ReconAll() >>> longrecon.inputs.longitudinal_timepoint_id = ‘ses-1’ >>> longrecon.inputs.longitudinal_template_id = ‘sub-template’ >>> longrecon.inputs.directive = ‘all’ >>> longrecon.inputs.subjects_dir = ‘.’ >>> longrecon.cmdline ‘recon-all -all -long ses-1 sub-template -sd .’

Optional Inputs:
  • FLAIR_file (a pathlike object or string representing an existing file) – Convert FLAIR image to orig directory. Maps to a command-line argument: -FLAIR %s. Requires inputs: subject_id.

  • T1_files (a list of items which are a pathlike object or string representing an existing file) – Name of T1 file to process. Maps to a command-line argument: -i %s.... Requires inputs: subject_id.

  • T2_file (a pathlike object or string representing an existing file) – Convert T2 image to orig directory. Maps to a command-line argument: -T2 %s. Requires inputs: subject_id.

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

  • base_template_id (a string) – Base template id. Maps to a command-line argument: -base %s. Mutually exclusive with inputs: subject_id, longitudinal_timepoint_id. Requires inputs: base_timepoint_ids.

  • base_timepoint_ids (a list of items which are a string) – Processed timepoint to use in template. Maps to a command-line argument: -base-tp %s....

  • big_ventricles (a boolean) – For use in subjects with enlarged ventricles. Maps to a command-line argument: -bigventricles.

  • brainstem (a boolean) – Segment brainstem structures. Maps to a command-line argument: -brainstem-structures. Requires inputs: subject_id.

  • directive (‘all’ or ‘autorecon1’ or ‘autorecon2’ or ‘autorecon2-volonly’ or ‘autorecon2-perhemi’ or ‘autorecon2-inflate1’ or ‘autorecon2-cp’ or ‘autorecon2-wm’ or ‘autorecon3’ or ‘autorecon3-T2pial’ or ‘autorecon-pial’ or ‘autorecon-hemi’ or ‘localGI’ or ‘qcache’) – Process directive. Maps to a command-line argument: -%s (position: 0). (Nipype default value: all)

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

  • expert (a pathlike object or string representing an existing file) – Set parameters using expert file. Maps to a command-line argument: -expert %s.

  • flags (a list of items which are a string) – Additional parameters. Maps to a command-line argument: %s.

  • hemi (‘lh’ or ‘rh’) – Hemisphere to process. Maps to a command-line argument: -hemi %s. Requires inputs: subject_id.

  • hippocampal_subfields_T1 (a boolean) – Segment hippocampal subfields using input T1 scan. Maps to a command-line argument: -hippocampal-subfields-T1. Requires inputs: subject_id.

  • hippocampal_subfields_T2 (a tuple of the form: (a pathlike object or string representing an existing file, a string)) – Segment hippocampal subfields using T2 scan, identified by ID (may be combined with hippocampal_subfields_T1). Maps to a command-line argument: -hippocampal-subfields-T2 %s %s. Requires inputs: subject_id.

  • hires (a boolean) – Conform to minimum voxel size (for voxels < 1mm). Maps to a command-line argument: -hires.

  • longitudinal_template_id (a string) – Longitudinal base template id. Maps to a command-line argument: %s (position: 2).

  • longitudinal_timepoint_id (a string) – Longitudinal session/timepoint id. Maps to a command-line argument: -long %s (position: 1). Mutually exclusive with inputs: subject_id, base_template_id. Requires inputs: longitudinal_template_id.

  • mprage (a boolean) – Assume scan parameters are MGH MP-RAGE protocol, which produces darker gray matter. Maps to a command-line argument: -mprage. Requires inputs: subject_id.

  • mri_aparc2aseg (a string) – Flags to pass to mri_aparc2aseg commands. Mutually exclusive with inputs: expert.

  • mri_ca_label (a string) – Flags to pass to mri_ca_label commands. Mutually exclusive with inputs: expert.

  • mri_ca_normalize (a string) – Flags to pass to mri_ca_normalize commands. Mutually exclusive with inputs: expert.

  • mri_ca_register (a string) – Flags to pass to mri_ca_register commands. Mutually exclusive with inputs: expert.

  • mri_edit_wm_with_aseg (a string) – Flags to pass to mri_edit_wm_with_aseg commands. Mutually exclusive with inputs: expert.

  • mri_em_register (a string) – Flags to pass to mri_em_register commands. Mutually exclusive with inputs: expert.

  • mri_fill (a string) – Flags to pass to mri_fill commands. Mutually exclusive with inputs: expert.

  • mri_mask (a string) – Flags to pass to mri_mask commands. Mutually exclusive with inputs: expert.

  • mri_normalize (a string) – Flags to pass to mri_normalize commands. Mutually exclusive with inputs: expert.

  • mri_pretess (a string) – Flags to pass to mri_pretess commands. Mutually exclusive with inputs: expert.

  • mri_remove_neck (a string) – Flags to pass to mri_remove_neck commands. Mutually exclusive with inputs: expert.

  • mri_segment (a string) – Flags to pass to mri_segment commands. Mutually exclusive with inputs: expert.

  • mri_segstats (a string) – Flags to pass to mri_segstats commands. Mutually exclusive with inputs: expert.

  • mri_tessellate (a string) – Flags to pass to mri_tessellate commands. Mutually exclusive with inputs: expert.

  • mri_watershed (a string) – Flags to pass to mri_watershed commands. Mutually exclusive with inputs: expert.

  • mris_anatomical_stats (a string) – Flags to pass to mris_anatomical_stats commands. Mutually exclusive with inputs: expert.

  • mris_ca_label (a string) – Flags to pass to mris_ca_label commands. Mutually exclusive with inputs: expert.

  • mris_fix_topology (a string) – Flags to pass to mris_fix_topology commands. Mutually exclusive with inputs: expert.

  • mris_inflate (a string) – Flags to pass to mri_inflate commands. Mutually exclusive with inputs: expert.

  • mris_make_surfaces (a string) – Flags to pass to mris_make_surfaces commands. Mutually exclusive with inputs: expert.

  • mris_register (a string) – Flags to pass to mris_register commands. Mutually exclusive with inputs: expert.

  • mris_smooth (a string) – Flags to pass to mri_smooth commands. Mutually exclusive with inputs: expert.

  • mris_sphere (a string) – Flags to pass to mris_sphere commands. Mutually exclusive with inputs: expert.

  • mris_surf2vol (a string) – Flags to pass to mris_surf2vol commands. Mutually exclusive with inputs: expert.

  • mrisp_paint (a string) – Flags to pass to mrisp_paint commands. Mutually exclusive with inputs: expert.

  • openmp (an integer) – Number of processors to use in parallel. Maps to a command-line argument: -openmp %d.

  • parallel (a boolean) – Enable parallel execution. Maps to a command-line argument: -parallel.

  • subject_id (a string) – Subject name. Maps to a command-line argument: -subjid %s. Mutually exclusive with inputs: base_template_id, longitudinal_timepoint_id.

  • subjects_dir (a pathlike object or string representing an existing directory) – Path to subjects directory. Maps to a command-line argument: -sd %s.

  • talairach (a string) – Flags to pass to talairach commands. Mutually exclusive with inputs: expert.

  • use_FLAIR (a boolean) – Use FLAIR image to refine the pial surface. Maps to a command-line argument: -FLAIRpial. Mutually exclusive with inputs: use_T2.

  • use_T2 (a boolean) – Use T2 image to refine the pial surface. Maps to a command-line argument: -T2pial. Mutually exclusive with inputs: use_FLAIR.

  • xopts (‘use’ or ‘clean’ or ‘overwrite’) – Use, delete or overwrite existing expert options file. Maps to a command-line argument: -xopts-%s.

Outputs:
  • BA_stats (a list of items which are a pathlike object or string representing an existing file) – Brodmann Area statistics files.

  • T1 (a pathlike object or string representing an existing file) – Intensity normalized whole-head volume.

  • annot (a list of items which are a pathlike object or string representing an existing file) – Surface annotation files.

  • aparc_a2009s_stats (a list of items which are a pathlike object or string representing an existing file) – Aparc a2009s parcellation statistics files.

  • aparc_aseg (a list of items which are a pathlike object or string representing an existing file) – Aparc parcellation projected into aseg volume.

  • aparc_stats (a list of items which are a pathlike object or string representing an existing file) – Aparc parcellation statistics files.

  • area_pial (a list of items which are a pathlike object or string representing an existing file) – Mean area of triangles each vertex on the pial surface is associated with.

  • aseg (a pathlike object or string representing an existing file) – Volumetric map of regions from automatic segmentation.

  • aseg_stats (a list of items which are a pathlike object or string representing an existing file) – Automated segmentation statistics file.

  • avg_curv (a list of items which are a pathlike object or string representing an existing file) – Average atlas curvature, sampled to subject.

  • brain (a pathlike object or string representing an existing file) – Intensity normalized brain-only volume.

  • brainmask (a pathlike object or string representing an existing file) – Skull-stripped (brain-only) volume.

  • curv (a list of items which are a pathlike object or string representing an existing file) – Maps of surface curvature.

  • curv_pial (a list of items which are a pathlike object or string representing an existing file) – Curvature of pial surface.

  • curv_stats (a list of items which are a pathlike object or string representing an existing file) – Curvature statistics files.

  • entorhinal_exvivo_stats (a list of items which are a pathlike object or string representing an existing file) – Entorhinal exvivo statistics files.

  • filled (a pathlike object or string representing an existing file) – Subcortical mass volume.

  • graymid (a list of items which are a pathlike object or string representing an existing file) – Graymid/midthickness surface meshes.

  • inflated (a list of items which are a pathlike object or string representing an existing file) – Inflated surface meshes.

  • jacobian_white (a list of items which are a pathlike object or string representing an existing file) – Distortion required to register to spherical atlas.

  • label (a list of items which are a pathlike object or string representing an existing file) – Volume and surface label files.

  • norm (a pathlike object or string representing an existing file) – Normalized skull-stripped volume.

  • nu (a pathlike object or string representing an existing file) – Non-uniformity corrected whole-head volume.

  • orig (a pathlike object or string representing an existing file) – Base image conformed to Freesurfer space.

  • pial (a list of items which are a pathlike object or string representing an existing file) – Gray matter/pia matter surface meshes.

  • rawavg (a pathlike object or string representing an existing file) – Volume formed by averaging input images.

  • ribbon (a list of items which are a pathlike object or string representing an existing file) – Volumetric maps of cortical ribbons.

  • smoothwm (a list of items which are a pathlike object or string representing an existing file) – Smoothed original surface meshes.

  • sphere (a list of items which are a pathlike object or string representing an existing file) – Spherical surface meshes.

  • sphere_reg (a list of items which are a pathlike object or string representing an existing file) – Spherical registration file.

  • subject_id (a string) – Subject name for whom to retrieve data.

  • subjects_dir (a pathlike object or string representing an existing directory) – Freesurfer subjects directory.

  • sulc (a list of items which are a pathlike object or string representing an existing file) – Surface maps of sulcal depth.

  • thickness (a list of items which are a pathlike object or string representing an existing file) – Surface maps of cortical thickness.

  • volume (a list of items which are a pathlike object or string representing an existing file) – Surface maps of cortical volume.

  • white (a list of items which are a pathlike object or string representing an existing file) – White/gray matter surface meshes.

  • wm (a pathlike object or string representing an existing file) – Segmented white-matter volume.

  • wmparc (a pathlike object or string representing an existing file) – Aparc parcellation projected into subcortical white matter.

  • wmparc_stats (a list of items which are a pathlike object or string representing an existing file) – White matter parcellation statistics file.

property ReconAll.cmdline

command plus any arguments (args) validates arguments and generates command line

ReconAll.force_run = False
property ReconAll.version

interfaces should implement a version property

Resample

Link to code

Bases: FSCommand

Wrapped executable: mri_convert.

Use FreeSurfer mri_convert to up or down-sample image files

Examples

>>> from nipype.interfaces import freesurfer
>>> resampler = freesurfer.Resample()
>>> resampler.inputs.in_file = 'structural.nii'
>>> resampler.inputs.resampled_file = 'resampled.nii'
>>> resampler.inputs.voxel_size = (2.1, 2.1, 2.1)
>>> resampler.cmdline
'mri_convert -vs 2.10 2.10 2.10 -i structural.nii -o resampled.nii'
Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – File to resample. Maps to a command-line argument: -i %s (position: -2).

  • voxel_size (a tuple of the form: (a float, a float, a float)) – Triplet of output voxel sizes. Maps to a command-line argument: -vs %.2f %.2f %.2f.

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

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

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

Outputs:

resampled_file (a pathlike object or string representing an existing file) – Output filename.

RobustRegister

Link to code

Bases: FSCommand

Wrapped executable: mri_robust_register.

Perform intramodal linear registration (translation and rotation) using robust statistics.

Examples

>>> from nipype.interfaces.freesurfer import RobustRegister
>>> reg = RobustRegister()
>>> reg.inputs.source_file = 'structural.nii'
>>> reg.inputs.target_file = 'T1.nii'
>>> reg.inputs.auto_sens = True
>>> reg.inputs.init_orient = True
>>> reg.cmdline 
'mri_robust_register --satit --initorient --lta .../structural_robustreg.lta --mov structural.nii --dst T1.nii'

References

Reuter, M, Rosas, HD, and Fischl, B, (2010). Highly Accurate Inverse

Consistent Registration: A Robust Approach. Neuroimage 53(4) 1181-96.

Mandatory Inputs:
  • auto_sens (a boolean) – Auto-detect good sensitivity. Maps to a command-line argument: --satit. Mutually exclusive with inputs: outlier_sens.

  • outlier_sens (a float) – Set outlier sensitivity explicitly. Maps to a command-line argument: --sat %.4f. Mutually exclusive with inputs: auto_sens.

  • source_file (a pathlike object or string representing an existing file) – Volume to be registered. Maps to a command-line argument: --mov %s.

  • target_file (a pathlike object or string representing an existing file) – Target volume for the registration. Maps to a command-line argument: --dst %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: {})

  • est_int_scale (a boolean) – Estimate intensity scale (recommended for unnormalized images). Maps to a command-line argument: --iscale.

  • force_double (a boolean) – Use double-precision intensities. Maps to a command-line argument: --doubleprec.

  • force_float (a boolean) – Use float intensities. Maps to a command-line argument: --floattype.

  • half_source (a boolean or a pathlike object or string representing a file) – Write source volume mapped to halfway space. Maps to a command-line argument: --halfmov %s.

  • half_source_xfm (a boolean or a pathlike object or string representing a file) – Write transform from source to halfway space. Maps to a command-line argument: --halfmovlta %s.

  • half_targ (a boolean or a pathlike object or string representing a file) – Write target volume mapped to halfway space. Maps to a command-line argument: --halfdst %s.

  • half_targ_xfm (a boolean or a pathlike object or string representing a file) – Write transform from target to halfway space. Maps to a command-line argument: --halfdstlta %s.

  • half_weights (a boolean or a pathlike object or string representing a file) – Write weights volume mapped to halfway space. Maps to a command-line argument: --halfweights %s.

  • high_iterations (an integer) – Max # of times on highest resolution. Maps to a command-line argument: --highit %d.

  • in_xfm_file (a pathlike object or string representing an existing file) – Use initial transform on source. Maps to a command-line argument: --transform.

  • init_orient (a boolean) – Use moments for initial orient (recommended for stripped brains). Maps to a command-line argument: --initorient.

  • iteration_thresh (a float) – Stop iterations when below threshold. Maps to a command-line argument: --epsit %.3f.

  • least_squares (a boolean) – Use least squares instead of robust estimator. Maps to a command-line argument: --leastsquares.

  • mask_source (a pathlike object or string representing an existing file) – Image to mask source volume with. Maps to a command-line argument: --maskmov %s.

  • mask_target (a pathlike object or string representing an existing file) – Image to mask target volume with. Maps to a command-line argument: --maskdst %s.

  • max_iterations (an integer) – Maximum # of times on each resolution. Maps to a command-line argument: --maxit %d.

  • no_init (a boolean) – Skip transform init. Maps to a command-line argument: --noinit.

  • no_multi (a boolean) – Work on highest resolution. Maps to a command-line argument: --nomulti.

  • out_reg_file (a bool or None or a pathlike object or string representing a file) – Registration file; either True or filename. Maps to a command-line argument: --lta %s. (Nipype default value: True)

  • outlier_limit (a float) – Set maximal outlier limit in satit. Maps to a command-line argument: --wlimit %.3f.

  • registered_file (a boolean or a pathlike object or string representing a file) – Registered image; either True or filename. Maps to a command-line argument: --warp %s.

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

  • subsample_thresh (an integer) – Subsample if dimension is above threshold size. Maps to a command-line argument: --subsample %d.

  • trans_only (a boolean) – Find 3 parameter translation only. Maps to a command-line argument: --transonly.

  • weights_file (a boolean or a pathlike object or string representing a file) – Weights image to write; either True or filename. Maps to a command-line argument: --weights %s.

  • write_vo2vox (a boolean) – Output vox2vox matrix (default is RAS2RAS). Maps to a command-line argument: --vox2vox.

Outputs:
  • half_source (a pathlike object or string representing an existing file) – Source image mapped to halfway space.

  • half_source_xfm (a pathlike object or string representing an existing file) – Transform file to map source image to halfway space.

  • half_targ (a pathlike object or string representing an existing file) – Target image mapped to halfway space.

  • half_targ_xfm (a pathlike object or string representing an existing file) – Transform file to map target image to halfway space.

  • half_weights (a pathlike object or string representing an existing file) – Weights image mapped to halfway space.

  • out_reg_file (a pathlike object or string representing an existing file) – Output registration file.

  • registered_file (a pathlike object or string representing an existing file) – Output image with registration applied.

  • weights_file (a pathlike object or string representing an existing file) – Image of weights used.

SegmentCC

Link to code

Bases: FSCommand

Wrapped executable: mri_cc.

This program segments the corpus callosum into five separate labels in the subcortical segmentation volume ‘aseg.mgz’. The divisions of the cc are equally spaced in terms of distance along the primary eigendirection (pretty much the long axis) of the cc. The lateral extent can be changed with the -T <thickness> parameter, where <thickness> is the distance off the midline (so -T 1 would result in the who CC being 3mm thick). The default is 2 so it’s 5mm thick. The aseg.stats values should be volume.

Examples

>>> from nipype.interfaces import freesurfer
>>> SegmentCC_node = freesurfer.SegmentCC()
>>> SegmentCC_node.inputs.in_file = "aseg.mgz"
>>> SegmentCC_node.inputs.in_norm = "norm.mgz"
>>> SegmentCC_node.inputs.out_rotation = "cc.lta"
>>> SegmentCC_node.inputs.subject_id = "test"
>>> SegmentCC_node.cmdline
'mri_cc -aseg aseg.mgz -o aseg.auto.mgz -lta cc.lta test'
Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Input aseg file to read from subjects directory. Maps to a command-line argument: -aseg %s.

  • in_norm (a pathlike object or string representing an existing file) – Required undocumented input {subject}/mri/norm.mgz.

  • out_rotation (a pathlike object or string representing a file) – Global filepath for writing rotation lta. Maps to a command-line argument: -lta %s.

  • subject_id (a string) – Subject name. Maps to a command-line argument: %s (position: -1). (Nipype default value: subject_id)

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

  • copy_inputs (a boolean) – If running as a node, set this to True.This will copy the input files to the node directory.

  • 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) – Filename to write aseg including CC. Maps to a command-line argument: -o %s.

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

Outputs:
  • out_file (a pathlike object or string representing a file) – Output segmentation including corpus collosum.

  • out_rotation (a pathlike object or string representing a file) – Output lta rotation file.

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

Collate expected outputs and apply output traits validation.

SegmentCC.run(**inputs)

Execute this interface.

This interface will not raise an exception if runtime.returncode is non-zero.

Parameters:
  • cwd (specify a folder where the interface should be run)

  • inputs (allows the interface settings to be updated)

Returns:

results – A copy of the instance that was executed, provenance information and, if successful, results

Return type:

nipype.interfaces.base.support.InterfaceResult

SegmentWM

Link to code

Bases: FSCommand

Wrapped executable: mri_segment.

This program segments white matter from the input volume. The input volume should be normalized such that white matter voxels are ~110-valued, and the volume is conformed to 256^3.

Examples

>>> from nipype.interfaces import freesurfer
>>> SegmentWM_node = freesurfer.SegmentWM()
>>> SegmentWM_node.inputs.in_file = "norm.mgz"
>>> SegmentWM_node.inputs.out_file = "wm.seg.mgz"
>>> SegmentWM_node.cmdline
'mri_segment norm.mgz wm.seg.mgz'
Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Input file for SegmentWM. Maps to a command-line argument: %s (position: -2).

  • out_file (a pathlike object or string representing a file) – File to be written as output for SegmentWM. 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: {})

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

Outputs:

out_file (a pathlike object or string representing a file) – Output white matter segmentation.

Smooth

Link to code

Bases: FSCommand

Wrapped executable: mris_volsmooth.

Use FreeSurfer mris_volsmooth to smooth a volume

This function smoothes cortical regions on a surface and non-cortical regions in volume.

Note

Cortical voxels are mapped to the surface (3D->2D) and then the smoothed values from the surface are put back into the volume to fill the cortical ribbon. If data is smoothed with this algorithm, one has to be careful about how further processing is interpreted.

Examples

>>> from nipype.interfaces.freesurfer import Smooth
>>> smoothvol = Smooth(in_file='functional.nii', smoothed_file = 'foo_out.nii', reg_file='register.dat', surface_fwhm=10, vol_fwhm=6)
>>> smoothvol.cmdline
'mris_volsmooth --i functional.nii --reg register.dat --o foo_out.nii --fwhm 10.000000 --vol-fwhm 6.000000'
Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Source volume. Maps to a command-line argument: --i %s.

  • num_iters (an integer >= 1) – Number of iterations instead of fwhm. Maps to a command-line argument: --niters %d. Mutually exclusive with inputs: surface_fwhm.

  • reg_file (a pathlike object or string representing an existing file) – Registers volume to surface anatomical . Maps to a command-line argument: --reg %s.

  • surface_fwhm (a floating point number >= 0.0) – Surface FWHM in mm. Maps to a command-line argument: --fwhm %f. Mutually exclusive with inputs: num_iters. Requires inputs: reg_file.

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

  • proj_frac (a float) – Project frac of thickness a long surface normal. Maps to a command-line argument: --projfrac %s. Mutually exclusive with inputs: proj_frac_avg.

  • proj_frac_avg (a tuple of the form: (a float, a float, a float)) – Average a long normal min max delta. Maps to a command-line argument: --projfrac-avg %.2f %.2f %.2f. Mutually exclusive with inputs: proj_frac.

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

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

  • vol_fwhm (a floating point number >= 0.0) – Volume smoothing outside of surface. Maps to a command-line argument: --vol-fwhm %f.

Outputs:

smoothed_file (a pathlike object or string representing an existing file) – Smoothed input volume.

SynthesizeFLASH

Link to code

Bases: FSCommand

Wrapped executable: mri_synthesize.

Synthesize a FLASH acquisition from T1 and proton density maps.

Examples

>>> from nipype.interfaces.freesurfer import SynthesizeFLASH
>>> syn = SynthesizeFLASH(tr=20, te=3, flip_angle=30)
>>> syn.inputs.t1_image = 'T1.mgz'
>>> syn.inputs.pd_image = 'PD.mgz'
>>> syn.inputs.out_file = 'flash_30syn.mgz'
>>> syn.cmdline
'mri_synthesize 20.00 30.00 3.000 T1.mgz PD.mgz flash_30syn.mgz'
Mandatory Inputs:
  • flip_angle (a float) – Flip angle (in degrees). Maps to a command-line argument: %.2f (position: 3).

  • pd_image (a pathlike object or string representing an existing file) – Image of proton density values. Maps to a command-line argument: %s (position: 6).

  • t1_image (a pathlike object or string representing an existing file) – Image of T1 values. Maps to a command-line argument: %s (position: 5).

  • te (a float) – Echo time (in msec). Maps to a command-line argument: %.3f (position: 4).

  • tr (a float) – Repetition time (in msec). Maps to a command-line argument: %.2f (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: {})

  • fixed_weighting (a boolean) – Use a fixed weighting to generate optimal gray/white contrast. Maps to a command-line argument: -w (position: 1).

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

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

Outputs:

out_file (a pathlike object or string representing an existing file) – Synthesized FLASH acquisition.

UnpackSDICOMDir

Link to code

Bases: FSCommand

Wrapped executable: unpacksdcmdir.

Use unpacksdcmdir to convert dicom files

Call unpacksdcmdir -help from the command line to see more information on using this command.

Examples

>>> from nipype.interfaces.freesurfer import UnpackSDICOMDir
>>> unpack = UnpackSDICOMDir()
>>> unpack.inputs.source_dir = '.'
>>> unpack.inputs.output_dir = '.'
>>> unpack.inputs.run_info = (5, 'mprage', 'nii', 'struct')
>>> unpack.inputs.dir_structure = 'generic'
>>> unpack.cmdline
'unpacksdcmdir -generic -targ . -run 5 mprage nii struct -src .'
Mandatory Inputs:
  • config (a pathlike object or string representing an existing file) – Specify unpacking rules in file. Maps to a command-line argument: -cfg %s. Mutually exclusive with inputs: run_info, config, seq_config.

  • run_info (a tuple of the form: (an integer, a string, a string, a string)) – Runno subdir format name : spec unpacking rules on cmdline. Maps to a command-line argument: -run %d %s %s %s. Mutually exclusive with inputs: run_info, config, seq_config.

  • seq_config (a pathlike object or string representing an existing file) – Specify unpacking rules based on sequence. Maps to a command-line argument: -seqcfg %s. Mutually exclusive with inputs: run_info, config, seq_config.

  • source_dir (a pathlike object or string representing an existing directory) – Directory with the DICOM files. 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.

  • dir_structure (‘fsfast’ or ‘generic’) – Unpack to specified directory structures. 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: {})

  • log_file (a pathlike object or string representing an existing file) – Explicitly set log file. Maps to a command-line argument: -log %s.

  • no_info_dump (a boolean) – Do not create infodump file. Maps to a command-line argument: -noinfodump.

  • no_unpack_err (a boolean) – Do not try to unpack runs with errors. Maps to a command-line argument: -no-unpackerr.

  • output_dir (a pathlike object or string representing a directory) – Top directory into which the files will be unpacked. Maps to a command-line argument: -targ %s.

  • scan_only (a pathlike object or string representing an existing file) – Only scan the directory and put result in file. Maps to a command-line argument: -scanonly %s.

  • spm_zeropad (an integer) – Set frame number zero padding width for SPM. Maps to a command-line argument: -nspmzeropad %d.

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

WatershedSkullStrip

Link to code

Bases: FSCommand

Wrapped executable: mri_watershed.

This program strips skull and other outer non-brain tissue and produces the brain volume from T1 volume or the scanned volume.

The “watershed” segmentation algorithm was used to determine the intensity values for white matter, grey matter, and CSF. A force field was then used to fit a spherical surface to the brain. The shape of the surface fit was then evaluated against a previously derived template.

The default parameters are: -w 0.82 -b 0.32 -h 10 -seedpt -ta -wta

(Segonne 2004)

Examples

>>> from nipype.interfaces.freesurfer import WatershedSkullStrip
>>> skullstrip = WatershedSkullStrip()
>>> skullstrip.inputs.in_file = "T1.mgz"
>>> skullstrip.inputs.t1 = True
>>> skullstrip.inputs.transform = "transforms/talairach_with_skull.lta"
>>> skullstrip.inputs.out_file = "brainmask.auto.mgz"
>>> skullstrip.cmdline
'mri_watershed -T1 transforms/talairach_with_skull.lta T1.mgz brainmask.auto.mgz'
Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Input volume. Maps to a command-line argument: %s (position: -2).

  • out_file (a pathlike object or string representing a file) – Output volume. Maps to a command-line argument: %s (position: -1). (Nipype default value: brainmask.auto.mgz)

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

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

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

  • subjects_dir (a pathlike object or string representing an existing directory) – Subjects directory.

  • t1 (a boolean) – Specify T1 input volume (T1 grey value = 110). Maps to a command-line argument: -T1.

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

Outputs:

out_file (a pathlike object or string representing a file) – Skull stripped brain volume.