interfaces.freesurfer.utils

AddXFormToHeader

Link to code

Wraps the executable command mri_add_xform_to_header.

Just adds specified xform to the volume header

(!) WARNING: transform input MUST be an absolute path to a DataSink’ed transform or the output will reference a transform in the workflow cache directory!

>>> from nipype.interfaces.freesurfer import AddXFormToHeader
>>> adder = AddXFormToHeader()
>>> adder.inputs.in_file = 'norm.mgz'
>>> adder.inputs.transform = 'trans.mat'
>>> adder.cmdline
'mri_add_xform_to_header trans.mat norm.mgz output.mgz'
>>> adder.inputs.copy_name = True
>>> adder.cmdline
'mri_add_xform_to_header -c trans.mat norm.mgz output.mgz'
>>> adder.run()   

References:

[https://surfer.nmr.mgh.harvard.edu/fswiki/mri_add_xform_to_header]

Inputs:

[Mandatory]
in_file: (an existing file name)
        input volume
        argument: ``%s``, position: -2
transform: (a file name)
        xfm file
        argument: ``%s``, position: -3

[Optional]
out_file: (a file name, nipype default value: output.mgz)
        output volume
        argument: ``%s``, position: -1
copy_name: (a boolean)
        do not try to load the xfmfile, just copy name
        argument: ``-c``
verbose: (a boolean)
        be verbose
        argument: ``-v``
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (an existing file name)
        output volume

Aparc2Aseg

Link to code

Wraps the executable command mri_aparc2aseg.

Maps the cortical labels from the automatic cortical parcellation (aparc) to the automatic segmentation volume (aseg). The result can be used as the aseg would. The algorithm is to find each aseg voxel labeled as cortex (3 and 42) and assign it the label of the closest cortical vertex. If the voxel is not in the ribbon (as defined by mri/ lh.ribbon and rh.ribbon), then the voxel is marked as unknown (0). This can be turned off with –noribbon. The cortical parcellation is obtained from subject/label/hemi.aparc.annot which should be based on the curvature.buckner40.filled.desikan_killiany.gcs atlas. The aseg is obtained from subject/mri/aseg.mgz and should be based on the RB40_talairach_2005-07-20.gca atlas. If these atlases are used, then the segmentations can be viewed with tkmedit and the FreeSurferColorLUT.txt color table found in $FREESURFER_HOME. These are the default atlases used by recon-all.

Examples

>>> from nipype.interfaces.freesurfer import Aparc2Aseg
>>> aparc2aseg = Aparc2Aseg()
>>> aparc2aseg.inputs.lh_white = 'lh.pial'
>>> aparc2aseg.inputs.rh_white = 'lh.pial'
>>> aparc2aseg.inputs.lh_pial = 'lh.pial'
>>> aparc2aseg.inputs.rh_pial = 'lh.pial'
>>> aparc2aseg.inputs.lh_ribbon = 'label.mgz'
>>> aparc2aseg.inputs.rh_ribbon = 'label.mgz'
>>> aparc2aseg.inputs.ribbon = 'label.mgz'
>>> aparc2aseg.inputs.lh_annotation = 'lh.pial'
>>> aparc2aseg.inputs.rh_annotation = 'lh.pial'
>>> aparc2aseg.inputs.out_file = 'aparc+aseg.mgz'
>>> aparc2aseg.inputs.label_wm = True
>>> aparc2aseg.inputs.rip_unknown = True
>>> aparc2aseg.cmdline 
'mri_aparc2aseg --labelwm  --o aparc+aseg.mgz --rip-unknown --s subject_id'

Inputs:

[Mandatory]
subject_id: (a string, nipype default value: subject_id)
        Subject being processed
        argument: ``--s %s``
out_file: (a file name)
        Full path of file to save the output segmentation in
        argument: ``--o %s``
lh_white: (an existing file name)
        Input file must be <subject_id>/surf/lh.white
rh_white: (an existing file name)
        Input file must be <subject_id>/surf/rh.white
lh_pial: (an existing file name)
        Input file must be <subject_id>/surf/lh.pial
rh_pial: (an existing file name)
        Input file must be <subject_id>/surf/rh.pial
lh_ribbon: (an existing file name)
        Input file must be <subject_id>/mri/lh.ribbon.mgz
rh_ribbon: (an existing file name)
        Input file must be <subject_id>/mri/rh.ribbon.mgz
ribbon: (an existing file name)
        Input file must be <subject_id>/mri/ribbon.mgz
lh_annotation: (an existing file name)
        Input file must be <subject_id>/label/lh.aparc.annot
rh_annotation: (an existing file name)
        Input file must be <subject_id>/label/rh.aparc.annot

[Optional]
filled: (an existing file name)
        Implicit input filled file. Only required with FS v5.3.
aseg: (an existing file name)
        Input aseg file
        argument: ``--aseg %s``
volmask: (a boolean)
        Volume mask flag
        argument: ``--volmask``
ctxseg: (an existing file name)
        argument: ``--ctxseg %s``
label_wm: (a boolean)
         For each voxel labeled as white matter in the aseg, re-assign
         its label to be that of the closest cortical point if its
         distance is less than dmaxctx
        argument: ``--labelwm``
hypo_wm: (a boolean)
        Label hypointensities as WM
        argument: ``--hypo-as-wm``
rip_unknown: (a boolean)
        Do not label WM based on 'unknown' corical label
        argument: ``--rip-unknown``
a2009s: (a boolean)
        Using the a2009s atlas
        argument: ``--a2009s``
copy_inputs: (a boolean)
        If running as a node, set this to True.This will copy the input
        files to the node directory.
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (a file name)
        Output aseg file
        argument: ``%s``

Apas2Aseg

Link to code

Wraps the executable command apas2aseg.

Converts aparc+aseg.mgz into something like aseg.mgz by replacing the cortical segmentations 1000-1035 with 3 and 2000-2035 with 42. The advantage of this output is that the cortical label conforms to the actual surface (this is not the case with aseg.mgz).

Examples

>>> from nipype.interfaces.freesurfer import Apas2Aseg
>>> apas2aseg = Apas2Aseg()
>>> apas2aseg.inputs.in_file = 'aseg.mgz'
>>> apas2aseg.inputs.out_file = 'output.mgz'
>>> apas2aseg.cmdline
'apas2aseg --i aseg.mgz --o output.mgz'

Inputs:

[Mandatory]
in_file: (an existing file name)
        Input aparc+aseg.mgz
        argument: ``--i %s``
out_file: (a file name)
        Output aseg file
        argument: ``--o %s``

[Optional]
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (a file name)
        Output aseg file
        argument: ``%s``

ApplyMask

Link to code

Wraps the executable command mri_mask.

Use Freesurfer’s mri_mask to apply a mask to an image.

The mask file need not be binarized; it can be thresholded above a given value before application. It can also optionally be transformed into input space with an LTA matrix.

Inputs:

[Mandatory]
in_file: (an existing file name)
        input image (will be masked)
        argument: ``%s``, position: -3
mask_file: (an existing file name)
        image defining mask space
        argument: ``%s``, position: -2

[Optional]
out_file: (a file name)
        final image to write
        argument: ``%s``, position: -1
xfm_file: (an existing file name)
        LTA-format transformation matrix to align mask with input
        argument: ``-xform %s``
invert_xfm: (a boolean)
        invert transformation
        argument: ``-invert``
xfm_source: (an existing file name)
        image defining transform source space
        argument: ``-lta_src %s``
xfm_target: (an existing file name)
        image defining transform target space
        argument: ``-lta_dst %s``
use_abs: (a boolean)
        take absolute value of mask before applying
        argument: ``-abs``
mask_thresh: (a float)
        threshold mask before applying
        argument: ``-T %.4f``
keep_mask_deletion_edits: (a boolean)
        transfer voxel-deletion edits (voxels=1) from mask to out vol
        argument: ``-keep_mask_deletion_edits``
transfer: (an integer (int or long))
        transfer only voxel value # from mask to out
        argument: ``-transfer %d``
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (an existing file name)
        masked image

CheckTalairachAlignment

Link to code

Wraps the executable command talairach_afd.

This program detects Talairach alignment failures

Examples

>>> from nipype.interfaces.freesurfer import CheckTalairachAlignment
>>> checker = CheckTalairachAlignment()
>>> checker.inputs.in_file = 'trans.mat'
>>> checker.inputs.threshold = 0.005
>>> checker.cmdline
'talairach_afd -T 0.005 -xfm trans.mat'
>>> checker.run() 

Inputs:

[Mandatory]
in_file: (an existing file name)
        specify the talairach.xfm file to check
        argument: ``-xfm %s``, position: -1
        mutually_exclusive: subject
subject: (a string)
        specify subject's name
        argument: ``-subj %s``, position: -1
        mutually_exclusive: in_file

[Optional]
threshold: (a float, nipype default value: 0.01)
        Talairach transforms for subjects with p-values <= T are considered
        as very unlikely default=0.010
        argument: ``-T %.3f``
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (a file name)
        The input file for CheckTalairachAlignment

Contrast

Link to code

Wraps the executable command pctsurfcon.

Compute surface-wise gray/white contrast

Examples

>>> from nipype.interfaces.freesurfer import Contrast
>>> contrast = Contrast()
>>> contrast.inputs.subject_id = '10335'
>>> contrast.inputs.hemisphere = 'lh'
>>> contrast.inputs.white = 'lh.white' 
>>> contrast.inputs.thickness = 'lh.thickness' 
>>> contrast.inputs.annotation = '../label/lh.aparc.annot' 
>>> contrast.inputs.cortex = '../label/lh.cortex.label' 
>>> contrast.inputs.rawavg = '../mri/rawavg.mgz' 
>>> contrast.inputs.orig = '../mri/orig.mgz' 
>>> contrast.cmdline 
'pctsurfcon --lh-only --s 10335'

Inputs:

[Mandatory]
subject_id: (a string, nipype default value: subject_id)
        Subject being processed
        argument: ``--s %s``
hemisphere: ('lh' or 'rh')
        Hemisphere being processed
        argument: ``--%s-only``
thickness: (an existing file name)
        Input file must be <subject_id>/surf/?h.thickness
white: (an existing file name)
        Input file must be <subject_id>/surf/<hemisphere>.white
annotation: (a file name)
        Input annotation file must be
        <subject_id>/label/<hemisphere>.aparc.annot
cortex: (a file name)
        Input cortex label must be
        <subject_id>/label/<hemisphere>.cortex.label
orig: (an existing file name)
        Implicit input file mri/orig.mgz
rawavg: (an existing file name)
        Implicit input file mri/rawavg.mgz

[Optional]
copy_inputs: (a boolean)
        If running as a node, set this to True.This will copy the input
        files to the node directory.
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_contrast: (a file name)
        Output contrast file from Contrast
out_stats: (a file name)
        Output stats file from Contrast
out_log: (an existing file name)
        Output log from Contrast

Curvature

Link to code

Wraps the executable command mris_curvature.

This program will compute the second fundamental form of a cortical surface. It will create two new files <hemi>.<surface>.H and <hemi>.<surface>.K with the mean and Gaussian curvature respectively.

Examples

>>> from nipype.interfaces.freesurfer import Curvature
>>> curv = Curvature()
>>> curv.inputs.in_file = 'lh.pial'
>>> curv.inputs.save = True
>>> curv.cmdline
'mris_curvature -w lh.pial'

Inputs:

[Mandatory]
in_file: (an existing file name)
        Input file for Curvature
        argument: ``%s``, position: -2

[Optional]
threshold: (a float)
        Undocumented input threshold
        argument: ``-thresh %.3f``
n: (a boolean)
        Undocumented boolean flag
        argument: ``-n``
averages: (an integer (int or long))
        Perform this number iterative averages of curvature measure before
        saving
        argument: ``-a %d``
save: (a boolean)
        Save curvature files (will only generate screen output without this
        option)
        argument: ``-w``
distances: (a tuple of the form: (an integer (int or long), an
          integer (int or long)))
        Undocumented input integer distances
        argument: ``-distances %d %d``
copy_input: (a boolean)
        Copy input file to current directory
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_mean: (a file name)
        Mean curvature output file
out_gauss: (a file name)
        Gaussian curvature output file

CurvatureStats

Link to code

Wraps the executable command mris_curvature_stats.

In its simplest usage, ‘mris_curvature_stats’ will compute a set of statistics on its input <curvFile>. These statistics are the mean and standard deviation of the particular curvature on the surface, as well as the results from several surface-based integrals.

Additionally, ‘mris_curvature_stats’ can report the max/min curvature values, and compute a simple histogram based on all curvature values.

Curvatures can also be normalised and constrained to a given range before computation.

Principal curvature (K, H, k1 and k2) calculations on a surface structure can also be performed, as well as several functions derived from k1 and k2.

Finally, all output to the console, as well as any new curvatures that result from the above calculations can be saved to a series of text and binary-curvature files.

Examples

>>> from nipype.interfaces.freesurfer import CurvatureStats
>>> curvstats = CurvatureStats()
>>> curvstats.inputs.hemisphere = 'lh'
>>> curvstats.inputs.curvfile1 = 'lh.pial'
>>> curvstats.inputs.curvfile2 = 'lh.pial'
>>> curvstats.inputs.surface = 'lh.pial'
>>> curvstats.inputs.out_file = 'lh.curv.stats'
>>> curvstats.inputs.values = True
>>> curvstats.inputs.min_max = True
>>> curvstats.inputs.write = True
>>> curvstats.cmdline
'mris_curvature_stats -m -o lh.curv.stats -F pial -G --writeCurvatureFiles subject_id lh pial pial'

Inputs:

[Mandatory]
curvfile1: (an existing file name)
        Input file for CurvatureStats
        argument: ``%s``, position: -2
curvfile2: (an existing file name)
        Input file for CurvatureStats
        argument: ``%s``, position: -1
hemisphere: ('lh' or 'rh')
        Hemisphere being processed
        argument: ``%s``, position: -3
subject_id: (a string, nipype default value: subject_id)
        Subject being processed
        argument: ``%s``, position: -4

[Optional]
surface: (an existing file name)
        Specify surface file for CurvatureStats
        argument: ``-F %s``
out_file: (a file name)
        Output curvature stats file
        argument: ``-o %s``
min_max: (a boolean)
        Output min / max information for the processed curvature.
        argument: ``-m``
values: (a boolean)
        Triggers a series of derived curvature values
        argument: ``-G``
write: (a boolean)
        Write curvature files
        argument: ``--writeCurvatureFiles``
copy_inputs: (a boolean)
        If running as a node, set this to True.This will copy the input
        files to the node directory.
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (a file name)
        Output curvature stats file

EulerNumber

Link to code

Wraps the executable command mris_euler_number.

This program computes EulerNumber for a cortical surface

Examples

>>> from nipype.interfaces.freesurfer import EulerNumber
>>> ft = EulerNumber()
>>> ft.inputs.in_file = 'lh.pial'
>>> ft.cmdline
'mris_euler_number lh.pial'

Inputs:

[Mandatory]
in_file: (an existing file name)
        Input file for EulerNumber
        argument: ``%s``, position: -1

[Optional]
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (a file name)
        Output file for EulerNumber

ExtractMainComponent

Link to code

Wraps the executable command mris_extract_main_component.

Extract the main component of a tesselated surface

Examples

>>> from nipype.interfaces.freesurfer import ExtractMainComponent
>>> mcmp = ExtractMainComponent(in_file='lh.pial')
>>> mcmp.cmdline
'mris_extract_main_component lh.pial lh.maincmp'

Inputs:

[Mandatory]
in_file: (an existing file name)
        input surface file
        argument: ``%s``, position: 1

[Optional]
out_file: (a file name)
        surface containing main component
        argument: ``%s``, position: 2
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (an existing file name)
        surface containing main component

FixTopology

Link to code

Wraps the executable command mris_fix_topology.

This program computes a mapping from the unit sphere onto the surface of the cortex from a previously generated approximation of the cortical surface, thus guaranteeing a topologically correct surface.

Examples

>>> from nipype.interfaces.freesurfer import FixTopology
>>> ft = FixTopology()
>>> ft.inputs.in_orig = 'lh.orig' 
>>> ft.inputs.in_inflated = 'lh.inflated' 
>>> ft.inputs.sphere = 'lh.qsphere.nofix' 
>>> ft.inputs.hemisphere = 'lh'
>>> ft.inputs.subject_id = '10335'
>>> ft.inputs.mgz = True
>>> ft.inputs.ga = True
>>> ft.cmdline 
'mris_fix_topology -ga -mgz -sphere qsphere.nofix 10335 lh'

Inputs:

[Mandatory]
in_orig: (an existing file name)
        Undocumented input file <hemisphere>.orig
in_inflated: (an existing file name)
        Undocumented input file <hemisphere>.inflated
in_brain: (an existing file name)
        Implicit input brain.mgz
in_wm: (an existing file name)
        Implicit input wm.mgz
hemisphere: (a string)
        Hemisphere being processed
        argument: ``%s``, position: -1
subject_id: (a string, nipype default value: subject_id)
        Subject being processed
        argument: ``%s``, position: -2
copy_inputs: (a boolean)
        If running as a node, set this to True otherwise, the topology
        fixing will be done in place.

[Optional]
seed: (an integer (int or long))
        Seed for setting random number generator
        argument: ``-seed %d``
ga: (a boolean)
        No documentation. Direct questions to analysis-
        bugs@nmr.mgh.harvard.edu
        argument: ``-ga``
mgz: (a boolean)
        No documentation. Direct questions to analysis-
        bugs@nmr.mgh.harvard.edu
        argument: ``-mgz``
sphere: (a file name)
        Sphere input file
        argument: ``-sphere %s``
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (a file name)
        Output file for FixTopology

Jacobian

Link to code

Wraps the executable command mris_jacobian.

This program computes the Jacobian of a surface mapping.

Examples

>>> from nipype.interfaces.freesurfer import Jacobian
>>> jacobian = Jacobian()
>>> jacobian.inputs.in_origsurf = 'lh.pial'
>>> jacobian.inputs.in_mappedsurf = 'lh.pial'
>>> jacobian.cmdline
'mris_jacobian lh.pial lh.pial lh.jacobian'

Inputs:

[Mandatory]
in_origsurf: (an existing file name)
        Original surface
        argument: ``%s``, position: -3
in_mappedsurf: (an existing file name)
        Mapped surface
        argument: ``%s``, position: -2

[Optional]
out_file: (a file name)
        Output Jacobian of the surface mapping
        argument: ``%s``, position: -1
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (a file name)
        Output Jacobian of the surface mapping

LTAConvert

Link to code

Wraps the executable command lta_convert.

Convert different transformation formats. Some formats may require you to pass an image if the geometry information is missing form the transform file format.

For complete details, see the lta_convert documentation.

Inputs:

[Mandatory]
in_lta: (an existing file name or 'identity.nofile')
        input transform of LTA type
        argument: ``--inlta %s``
        mutually_exclusive: in_lta, in_fsl, in_mni, in_reg, in_niftyreg,
          in_itk
in_fsl: (an existing file name)
        input transform of FSL type
        argument: ``--infsl %s``
        mutually_exclusive: in_lta, in_fsl, in_mni, in_reg, in_niftyreg,
          in_itk
in_mni: (an existing file name)
        input transform of MNI/XFM type
        argument: ``--inmni %s``
        mutually_exclusive: in_lta, in_fsl, in_mni, in_reg, in_niftyreg,
          in_itk
in_reg: (an existing file name)
        input transform of TK REG type (deprecated format)
        argument: ``--inreg %s``
        mutually_exclusive: in_lta, in_fsl, in_mni, in_reg, in_niftyreg,
          in_itk
in_niftyreg: (an existing file name)
        input transform of Nifty Reg type (inverse RAS2RAS)
        argument: ``--inniftyreg %s``
        mutually_exclusive: in_lta, in_fsl, in_mni, in_reg, in_niftyreg,
          in_itk
in_itk: (an existing file name)
        input transform of ITK type
        argument: ``--initk %s``
        mutually_exclusive: in_lta, in_fsl, in_mni, in_reg, in_niftyreg,
          in_itk

[Optional]
out_lta: (a boolean or a file name)
        output linear transform (LTA Freesurfer format)
        argument: ``--outlta %s``
out_fsl: (a boolean or a file name)
        output transform in FSL format
        argument: ``--outfsl %s``
out_mni: (a boolean or a file name)
        output transform in MNI/XFM format
        argument: ``--outmni %s``
out_reg: (a boolean or a file name)
        output transform in reg dat format
        argument: ``--outreg %s``
out_itk: (a boolean or a file name)
        output transform in ITK format
        argument: ``--outitk %s``
invert: (a boolean)
        argument: ``--invert``
ltavox2vox: (a boolean)
        argument: ``--ltavox2vox``
        requires: out_lta
source_file: (an existing file name)
        argument: ``--src %s``
target_file: (an existing file name)
        argument: ``--trg %s``
target_conform: (a boolean)
        argument: ``--trgconform``
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_lta: (an existing file name)
        output linear transform (LTA Freesurfer format)
out_fsl: (an existing file name)
        output transform in FSL format
out_mni: (an existing file name)
        output transform in MNI/XFM format
out_reg: (an existing file name)
        output transform in reg dat format
out_itk: (an existing file name)
        output transform in ITK format

MRIFill

Link to code

Wraps the executable command mri_fill.

This program creates hemispheric cutting planes and fills white matter with specific values for subsequent surface tesselation.

Examples

>>> from nipype.interfaces.freesurfer import MRIFill
>>> fill = MRIFill()
>>> fill.inputs.in_file = 'wm.mgz' 
>>> fill.inputs.out_file = 'filled.mgz' 
>>> fill.cmdline 
'mri_fill wm.mgz filled.mgz'

Inputs:

[Mandatory]
in_file: (an existing file name)
        Input white matter file
        argument: ``%s``, position: -2
out_file: (a file name)
        Output filled volume file name for MRIFill
        argument: ``%s``, position: -1

[Optional]
segmentation: (an existing file name)
        Input segmentation file for MRIFill
        argument: ``-segmentation %s``
transform: (an existing file name)
        Input transform file for MRIFill
        argument: ``-xform %s``
log_file: (a file name)
        Output log file for MRIFill
        argument: ``-a %s``
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (a file name)
        Output file from MRIFill
log_file: (a file name)
        Output log file from MRIFill

MRIMarchingCubes

Link to code

Wraps the executable command mri_mc.

Uses Freesurfer’s mri_mc to create surfaces by tessellating a given input volume

Example

>>> import nipype.interfaces.freesurfer as fs
>>> mc = fs.MRIMarchingCubes()
>>> mc.inputs.in_file = 'aseg.mgz'
>>> mc.inputs.label_value = 17
>>> mc.inputs.out_file = 'lh.hippocampus'
>>> mc.run() 

Inputs:

[Mandatory]
in_file: (an existing file name)
        Input volume to tesselate voxels from.
        argument: ``%s``, position: 1
label_value: (an integer (int or long))
        Label value which to tesselate from the input volume. (integer, if
        input is "filled.mgz" volume, 127 is rh, 255 is lh)
        argument: ``%d``, position: 2

[Optional]
connectivity_value: (an integer (int or long), nipype default value:
          1)
        Alter the marching cubes connectivity: 1=6+,2=18,3=6,4=26
        (default=1)
        argument: ``%d``, position: -1
out_file: (a file name)
        output filename or True to generate one
        argument: ``./%s``, position: -2
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

surface: (an existing file name)
        binary surface of the tessellation

MRIPretess

Link to code

Wraps the executable command mri_pretess.

Uses Freesurfer’s mri_pretess to prepare volumes to be tessellated.

Description

Changes white matter (WM) segmentation so that the neighbors of all voxels labeled as WM have a face in common - no edges or corners allowed.

Example

>>> import nipype.interfaces.freesurfer as fs
>>> pretess = fs.MRIPretess()
>>> pretess.inputs.in_filled = 'wm.mgz'
>>> pretess.inputs.in_norm = 'norm.mgz'
>>> pretess.inputs.nocorners = True
>>> pretess.cmdline
'mri_pretess -nocorners wm.mgz wm norm.mgz wm_pretesswm.mgz'
>>> pretess.run() 

Inputs:

[Mandatory]
in_filled: (an existing file name)
        filled volume, usually wm.mgz
        argument: ``%s``, position: -4
label: (a unicode string or an integer (int or long), nipype default
          value: wm)
        label to be picked up, can be a Freesurfer's string like 'wm' or a
        label value (e.g. 127 for rh or 255 for lh)
        argument: ``%s``, position: -3
in_norm: (an existing file name)
        the normalized, brain-extracted T1w image. Usually norm.mgz
        argument: ``%s``, position: -2

[Optional]
out_file: (a file name)
        the output file after mri_pretess.
        argument: ``%s``, position: -1
nocorners: (a boolean)
        do not remove corner configurations in addition to edge ones.
        argument: ``-nocorners``
keep: (a boolean)
        keep WM edits
        argument: ``-keep``
test: (a boolean)
        adds a voxel that should be removed by mri_pretess. The value of the
        voxel is set to that of an ON-edited WM, so it should be kept with
        -keep. The output will NOT be saved.
        argument: ``-test``
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (an existing file name)
        output file after mri_pretess

MRITessellate

Link to code

Wraps the executable command mri_tessellate.

Uses Freesurfer’s mri_tessellate to create surfaces by tessellating a given input volume

Example

>>> import nipype.interfaces.freesurfer as fs
>>> tess = fs.MRITessellate()
>>> tess.inputs.in_file = 'aseg.mgz'
>>> tess.inputs.label_value = 17
>>> tess.inputs.out_file = 'lh.hippocampus'
>>> tess.run() 

Inputs:

[Mandatory]
in_file: (an existing file name)
        Input volume to tesselate voxels from.
        argument: ``%s``, position: -3
label_value: (an integer (int or long))
        Label value which to tesselate from the input volume. (integer, if
        input is "filled.mgz" volume, 127 is rh, 255 is lh)
        argument: ``%d``, position: -2

[Optional]
out_file: (a file name)
        output filename or True to generate one
        argument: ``%s``, position: -1
tesselate_all_voxels: (a boolean)
        Tessellate the surface of all voxels with different labels
        argument: ``-a``
use_real_RAS_coordinates: (a boolean)
        Saves surface with real RAS coordinates where c_(r,a,s) != 0
        argument: ``-n``
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

surface: (an existing file name)
        binary surface of the tessellation

MRIsCalc

Link to code

Wraps the executable command mris_calc.

‘mris_calc’ is a simple calculator that operates on FreeSurfer curvatures and volumes. In most cases, the calculator functions with three arguments: two inputs and an <ACTION> linking them. Some actions, however, operate with only one input <file1>. In all cases, the first input <file1> is the name of a FreeSurfer curvature overlay (e.g. rh.curv) or volume file (e.g. orig.mgz). For two inputs, the calculator first assumes that the second input is a file. If, however, this second input file doesn’t exist, the calculator assumes it refers to a float number, which is then processed according to <ACTION>.Note: <file1> and <file2> should typically be generated on the same subject.

Examples

>>> from nipype.interfaces.freesurfer import MRIsCalc
>>> example = MRIsCalc()
>>> example.inputs.in_file1 = 'lh.area' 
>>> example.inputs.in_file2 = 'lh.area.pial' 
>>> example.inputs.action = 'add'
>>> example.inputs.out_file = 'area.mid'
>>> example.cmdline 
'mris_calc -o lh.area.mid lh.area add lh.area.pial'

Inputs:

[Mandatory]
in_file1: (an existing file name)
        Input file 1
        argument: ``%s``, position: -3
action: (a string)
        Action to perform on input file(s)
        argument: ``%s``, position: -2
out_file: (a file name)
        Output file after calculation
        argument: ``-o %s``

[Optional]
in_file2: (an existing file name)
        Input file 2
        argument: ``%s``, position: -1
        mutually_exclusive: in_float, in_int
in_float: (a float)
        Input float
        argument: ``%f``, position: -1
        mutually_exclusive: in_file2, in_int
in_int: (an integer (int or long))
        Input integer
        argument: ``%d``, position: -1
        mutually_exclusive: in_file2, in_float
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (a file name)
        Output file after calculation

MRIsCombine

Link to code

Wraps the executable command mris_convert.

Uses Freesurfer’s mris_convert to combine two surface files into one.

For complete details, see the mris_convert Documentation.

If given an out_file that does not begin with 'lh.' or 'rh.', mris_convert will prepend 'lh.' to the file name. To avoid this behavior, consider setting out_file = './<filename>', or leaving out_file blank.

In a Node/Workflow, out_file is interpreted literally.

Example

>>> import nipype.interfaces.freesurfer as fs
>>> mris = fs.MRIsCombine()
>>> mris.inputs.in_files = ['lh.pial', 'rh.pial']
>>> mris.inputs.out_file = 'bh.pial'
>>> mris.cmdline
'mris_convert --combinesurfs lh.pial rh.pial bh.pial'
>>> mris.run()  

Inputs:

[Mandatory]
in_files: (a list of from 2 to 2 items which are a file name)
        Two surfaces to be combined.
        argument: ``--combinesurfs %s``, position: 1
out_file: (a file name)
        Output filename. Combined surfaces from in_files.
        argument: ``%s``, position: -1

[Optional]
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (an existing file name)
        Output filename. Combined surfaces from in_files.

MRIsConvert

Link to code

Wraps the executable command mris_convert.

Uses Freesurfer’s mris_convert to convert surface files to various formats

Example

>>> import nipype.interfaces.freesurfer as fs
>>> mris = fs.MRIsConvert()
>>> mris.inputs.in_file = 'lh.pial'
>>> mris.inputs.out_datatype = 'gii'
>>> mris.run() 

Inputs:

[Mandatory]
in_file: (an existing file name)
        File to read/convert
        argument: ``%s``, position: -2
out_file: (a file name)
        output filename or True to generate one
        argument: ``%s``, position: -1
        mutually_exclusive: out_datatype
out_datatype: ('asc' or 'ico' or 'tri' or 'stl' or 'vtk' or 'gii' or
          'mgh' or 'mgz')
        These file formats are supported: ASCII: .ascICO: .ico, .tri GEO:
        .geo STL: .stl VTK: .vtk GIFTI: .gii MGH surface-encoded 'volume':
        .mgh, .mgz
        mutually_exclusive: out_file

[Optional]
annot_file: (an existing file name)
        input is annotation or gifti label data
        argument: ``--annot %s``
parcstats_file: (an existing file name)
        infile is name of text file containing label/val pairs
        argument: ``--parcstats %s``
label_file: (an existing file name)
        infile is .label file, label is name of this label
        argument: ``--label %s``
scalarcurv_file: (an existing file name)
        input is scalar curv overlay file (must still specify surface)
        argument: ``-c %s``
functional_file: (an existing file name)
        input is functional time-series or other multi-frame data (must
        specify surface)
        argument: ``-f %s``
labelstats_outfile: (a file name)
        outfile is name of gifti file to which label stats will be written
        argument: ``--labelstats %s``
patch: (a boolean)
        input is a patch, not a full surface
        argument: ``-p``
rescale: (a boolean)
        rescale vertex xyz so total area is same as group average
        argument: ``-r``
normal: (a boolean)
        output is an ascii file where vertex data
        argument: ``-n``
xyz_ascii: (a boolean)
        Print only surface xyz to ascii file
        argument: ``-a``
vertex: (a boolean)
        Writes out neighbors of a vertex in each row
        argument: ``-v``
scale: (a float)
        scale vertex xyz by scale
        argument: ``-s %.3f``
dataarray_num: (an integer (int or long))
        if input is gifti, 'num' specifies which data array to use
        argument: ``--da_num %d``
talairachxfm_subjid: (a string)
        apply talairach xfm of subject to vertex xyz
        argument: ``-t %s``
origname: (a string)
        read orig positions
        argument: ``-o %s``
to_scanner: (a boolean)
        convert coordinates from native FS (tkr) coords to scanner coords
        argument: ``--to-scanner``
to_tkr: (a boolean)
        convert coordinates from scanner coords to native FS (tkr) coords
        argument: ``--to-tkr``
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

converted: (an existing file name)
        converted output surface

MRIsExpand

Link to code

Wraps the executable command mris_expand.

Expands a surface (typically ?h.white) outwards while maintaining smoothness and self-intersection constraints.

Examples

>>> from nipype.interfaces.freesurfer import MRIsExpand
>>> mris_expand = MRIsExpand(thickness=True, distance=0.5)
>>> mris_expand.inputs.in_file = 'lh.white'
>>> mris_expand.cmdline
'mris_expand -thickness lh.white 0.5 expanded'
>>> mris_expand.inputs.out_name = 'graymid'
>>> mris_expand.cmdline
'mris_expand -thickness lh.white 0.5 graymid'

Inputs:

[Mandatory]
in_file: (an existing file name)
        Surface to expand
        argument: ``%s``, position: -3
distance: (a float)
        Distance in mm or fraction of cortical thickness
        argument: ``%g``, position: -2

[Optional]
out_name: (a unicode string, nipype default value: expanded)
        Output surface file
        If no path, uses directory of `in_file`
        If no path AND missing "lh." or "rh.", derive from `in_file`
        argument: ``%s``, position: -1
thickness: (a boolean)
        Expand by fraction of cortical thickness, not mm
        argument: ``-thickness``
thickness_name: (a unicode string)
        Name of thickness file (implicit: "thickness")
        If no path, uses directory of `in_file`
        If no path AND missing "lh." or "rh.", derive from `in_file`
        argument: ``-thickness_name %s``
pial: (a unicode string)
        Name of pial file (implicit: "pial")
        If no path, uses directory of `in_file`
        If no path AND missing "lh." or "rh.", derive from `in_file`
        argument: ``-pial %s``
sphere: (a unicode string, nipype default value: sphere)
        WARNING: Do not change this trait
spring: (a float)
        Spring term (implicit: 0.05)
        argument: ``-S %g``
dt: (a float)
        dt (implicit: 0.25)
        argument: ``-T %g``
write_iterations: (an integer (int or long))
        Write snapshots of expansion every N iterations
        argument: ``-W %d``
smooth_averages: (an integer (int or long))
        Smooth surface with N iterations after expansion
        argument: ``-A %d``
nsurfaces: (an integer (int or long))
        Number of surfacces to write during expansion
        argument: ``-N %d``
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (a file name)
        Output surface file

MRIsInflate

Link to code

Wraps the executable command mris_inflate.

This program will inflate a cortical surface.

Examples

>>> from nipype.interfaces.freesurfer import MRIsInflate
>>> inflate = MRIsInflate()
>>> inflate.inputs.in_file = 'lh.pial'
>>> inflate.inputs.no_save_sulc = True
>>> inflate.cmdline 
'mris_inflate -no-save-sulc lh.pial lh.inflated'

Inputs:

[Mandatory]
in_file: (an existing file name)
        Input file for MRIsInflate
        argument: ``%s``, position: -2

[Optional]
out_file: (a file name)
        Output file for MRIsInflate
        argument: ``%s``, position: -1
out_sulc: (a file name)
        Output sulc file
        mutually_exclusive: no_save_sulc
no_save_sulc: (a boolean)
        Do not save sulc file as output
        argument: ``-no-save-sulc``
        mutually_exclusive: out_sulc
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (a file name)
        Output file for MRIsInflate
out_sulc: (a file name)
        Output sulc file

MakeAverageSubject

Link to code

Wraps the executable command make_average_subject.

Make an average freesurfer subject

Examples

>>> from nipype.interfaces.freesurfer import MakeAverageSubject
>>> avg = MakeAverageSubject(subjects_ids=['s1', 's2'])
>>> avg.cmdline
'make_average_subject --out average --subjects s1 s2'

Inputs:

[Mandatory]
subjects_ids: (a list of items which are a unicode string)
        freesurfer subjects ids to average
        argument: ``--subjects %s``

[Optional]
out_name: (a file name, nipype default value: average)
        name for the average subject
        argument: ``--out %s``
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

average_subject_name: (a unicode string)
        Output registration file

MakeSurfaces

Link to code

Wraps the executable command mris_make_surfaces.

This program positions the tessellation of the cortical surface at the white matter surface, then the gray matter surface and generate surface files for these surfaces as well as a ‘curvature’ file for the cortical thickness, and a surface file which approximates layer IV of the cortical sheet.

Examples

>>> from nipype.interfaces.freesurfer import MakeSurfaces
>>> makesurfaces = MakeSurfaces()
>>> makesurfaces.inputs.hemisphere = 'lh'
>>> makesurfaces.inputs.subject_id = '10335'
>>> makesurfaces.inputs.in_orig = 'lh.pial'
>>> makesurfaces.inputs.in_wm = 'wm.mgz'
>>> makesurfaces.inputs.in_filled = 'norm.mgz'
>>> makesurfaces.inputs.in_label = 'aparc+aseg.nii'
>>> makesurfaces.inputs.in_T1 = 'T1.mgz'
>>> makesurfaces.inputs.orig_pial = 'lh.pial'
>>> makesurfaces.cmdline
'mris_make_surfaces -T1 T1.mgz -orig pial -orig_pial pial 10335 lh'

Inputs:

[Mandatory]
hemisphere: ('lh' or 'rh')
        Hemisphere being processed
        argument: ``%s``, position: -1
subject_id: (a string, nipype default value: subject_id)
        Subject being processed
        argument: ``%s``, position: -2
in_orig: (an existing file name)
        Implicit input file <hemisphere>.orig
        argument: ``-orig %s``
in_wm: (an existing file name)
        Implicit input file wm.mgz
in_filled: (an existing file name)
        Implicit input file filled.mgz

[Optional]
in_white: (an existing file name)
        Implicit input that is sometimes used
in_label: (an existing file name)
        Implicit input label/<hemisphere>.aparc.annot
        mutually_exclusive: noaparc
orig_white: (an existing file name)
        Specify a white surface to start with
        argument: ``-orig_white %s``
orig_pial: (an existing file name)
        Specify a pial surface to start with
        argument: ``-orig_pial %s``
        requires: in_label
fix_mtl: (a boolean)
        Undocumented flag
        argument: ``-fix_mtl``
no_white: (a boolean)
        Undocumented flag
        argument: ``-nowhite``
white_only: (a boolean)
        Undocumented flage
        argument: ``-whiteonly``
in_aseg: (an existing file name)
        Input segmentation file
        argument: ``-aseg %s``
in_T1: (an existing file name)
        Input brain or T1 file
        argument: ``-T1 %s``
mgz: (a boolean)
        No documentation. Direct questions to analysis-
        bugs@nmr.mgh.harvard.edu
        argument: ``-mgz``
noaparc: (a boolean)
        No documentation. Direct questions to analysis-
        bugs@nmr.mgh.harvard.edu
        argument: ``-noaparc``
        mutually_exclusive: in_label
maximum: (a float)
        No documentation (used for longitudinal processing)
        argument: ``-max %.1f``
longitudinal: (a boolean)
        No documentation (used for longitudinal processing)
        argument: ``-long``
white: (a string)
        White surface name
        argument: ``-white %s``
copy_inputs: (a boolean)
        If running as a node, set this to True.This will copy the input
        files to the node directory.
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_white: (a file name)
        Output white matter hemisphere surface
out_curv: (a file name)
        Output curv file for MakeSurfaces
out_area: (a file name)
        Output area file for MakeSurfaces
out_cortex: (a file name)
        Output cortex file for MakeSurfaces
out_pial: (a file name)
        Output pial surface for MakeSurfaces
out_thickness: (a file name)
        Output thickness file for MakeSurfaces

ParcellationStats

Link to code

Wraps the executable command mris_anatomical_stats.

This program computes a number of anatomical properties.

Examples

>>> from nipype.interfaces.freesurfer import ParcellationStats
>>> import os
>>> parcstats = ParcellationStats()
>>> parcstats.inputs.subject_id = '10335'
>>> parcstats.inputs.hemisphere = 'lh'
>>> parcstats.inputs.wm = './../mri/wm.mgz' 
>>> parcstats.inputs.transform = './../mri/transforms/talairach.xfm' 
>>> parcstats.inputs.brainmask = './../mri/brainmask.mgz' 
>>> parcstats.inputs.aseg = './../mri/aseg.presurf.mgz' 
>>> parcstats.inputs.ribbon = './../mri/ribbon.mgz' 
>>> parcstats.inputs.lh_pial = 'lh.pial' 
>>> parcstats.inputs.rh_pial = 'lh.pial' 
>>> parcstats.inputs.lh_white = 'lh.white' 
>>> parcstats.inputs.rh_white = 'rh.white' 
>>> parcstats.inputs.thickness = 'lh.thickness' 
>>> parcstats.inputs.surface = 'white'
>>> parcstats.inputs.out_table = 'lh.test.stats'
>>> parcstats.inputs.out_color = 'test.ctab'
>>> parcstats.cmdline 
'mris_anatomical_stats -c test.ctab -f lh.test.stats 10335 lh white'

Inputs:

[Mandatory]
subject_id: (a string, nipype default value: subject_id)
        Subject being processed
        argument: ``%s``, position: -3
hemisphere: ('lh' or 'rh')
        Hemisphere being processed
        argument: ``%s``, position: -2
wm: (an existing file name)
        Input file must be <subject_id>/mri/wm.mgz
lh_white: (an existing file name)
        Input file must be <subject_id>/surf/lh.white
rh_white: (an existing file name)
        Input file must be <subject_id>/surf/rh.white
lh_pial: (an existing file name)
        Input file must be <subject_id>/surf/lh.pial
rh_pial: (an existing file name)
        Input file must be <subject_id>/surf/rh.pial
transform: (an existing file name)
        Input file must be <subject_id>/mri/transforms/talairach.xfm
thickness: (an existing file name)
        Input file must be <subject_id>/surf/?h.thickness
brainmask: (an existing file name)
        Input file must be <subject_id>/mri/brainmask.mgz
aseg: (an existing file name)
        Input file must be <subject_id>/mri/aseg.presurf.mgz
ribbon: (an existing file name)
        Input file must be <subject_id>/mri/ribbon.mgz

[Optional]
cortex_label: (an existing file name)
        implicit input file {hemi}.cortex.label
surface: (a string)
        Input surface (e.g. 'white')
        argument: ``%s``, position: -1
mgz: (a boolean)
        Look for mgz files
        argument: ``-mgz``
in_cortex: (a file name)
        Input cortex label
        argument: ``-cortex %s``
in_annotation: (a file name)
        compute properties for each label in the annotation file separately
        argument: ``-a %s``
        mutually_exclusive: in_label
in_label: (a file name)
        limit calculations to specified label
        argument: ``-l %s``
        mutually_exclusive: in_annotatoin, out_color
tabular_output: (a boolean)
        Tabular output
        argument: ``-b``
out_table: (a file name)
        Table output to tablefile
        argument: ``-f %s``
        requires: tabular_output
out_color: (a file name)
        Output annotation files's colortable to text file
        argument: ``-c %s``
        mutually_exclusive: in_label
copy_inputs: (a boolean)
        If running as a node, set this to True.This will copy the input
        files to the node directory.
th3: (a boolean)
        turns on new vertex-wise volume calc for mris_anat_stats
        argument: ``-th3``
        requires: cortex_label
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_table: (a file name)
        Table output to tablefile
out_color: (a file name)
        Output annotation files's colortable to text file

RelabelHypointensities

Link to code

Wraps the executable command mri_relabel_hypointensities.

Relabel Hypointensities

Examples

>>> from nipype.interfaces.freesurfer import RelabelHypointensities
>>> relabelhypos = RelabelHypointensities()
>>> relabelhypos.inputs.lh_white = 'lh.pial'
>>> relabelhypos.inputs.rh_white = 'lh.pial'
>>> relabelhypos.inputs.surf_directory = '.'
>>> relabelhypos.inputs.aseg = 'aseg.mgz'
>>> relabelhypos.cmdline
'mri_relabel_hypointensities aseg.mgz . aseg.hypos.mgz'

Inputs:

[Mandatory]
lh_white: (an existing file name)
        Implicit input file must be lh.white
rh_white: (an existing file name)
        Implicit input file must be rh.white
aseg: (an existing file name)
        Input aseg file
        argument: ``%s``, position: -3

[Optional]
surf_directory: (a directory name, nipype default value: .)
        Directory containing lh.white and rh.white
        argument: ``%s``, position: -2
out_file: (a file name)
        Output aseg file
        argument: ``%s``, position: -1
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (a file name)
        Output aseg file
        argument: ``%s``

RemoveIntersection

Link to code

Wraps the executable command mris_remove_intersection.

This program removes the intersection of the given MRI

Examples

>>> from nipype.interfaces.freesurfer import RemoveIntersection
>>> ri = RemoveIntersection()
>>> ri.inputs.in_file = 'lh.pial'
>>> ri.cmdline
'mris_remove_intersection lh.pial lh.pial'

Inputs:

[Mandatory]
in_file: (an existing file name)
        Input file for RemoveIntersection
        argument: ``%s``, position: -2

[Optional]
out_file: (a file name)
        Output file for RemoveIntersection
        argument: ``%s``, position: -1
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (a file name)
        Output file for RemoveIntersection

RemoveNeck

Link to code

Wraps the executable command mri_remove_neck.

Crops the neck out of the mri image

Examples

>>> from nipype.interfaces.freesurfer import TalairachQC
>>> remove_neck = RemoveNeck()
>>> remove_neck.inputs.in_file = 'norm.mgz'
>>> remove_neck.inputs.transform = 'trans.mat'
>>> remove_neck.inputs.template = 'trans.mat'
>>> remove_neck.cmdline
'mri_remove_neck norm.mgz trans.mat trans.mat norm_noneck.mgz'

Inputs:

[Mandatory]
in_file: (an existing file name)
        Input file for RemoveNeck
        argument: ``%s``, position: -4
transform: (an existing file name)
        Input transform file for RemoveNeck
        argument: ``%s``, position: -3
template: (an existing file name)
        Input template file for RemoveNeck
        argument: ``%s``, position: -2

[Optional]
out_file: (a file name)
        Output file for RemoveNeck
        argument: ``%s``, position: -1
radius: (an integer (int or long))
        Radius
        argument: ``-radius %d``
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (a file name)
        Output file with neck removed

SampleToSurface

Link to code

Wraps the executable command mri_vol2surf.

Sample a volume to the cortical surface using Freesurfer’s mri_vol2surf.

You must supply a sampling method, range, and units. You can project either a given distance (in mm) or a given fraction of the cortical thickness at that vertex along the surface normal from the target surface, and then set the value of that vertex to be either the value at that point or the average or maximum value found along the projection vector.

By default, the surface will be saved as a vector with a length equal to the number of vertices on the target surface. This is not a problem for Freesurfer programs, but if you intend to use the file with interfaces to another package, you must set the reshape input to True, which will factor the surface vector into a matrix with dimensions compatible with proper Nifti files.

Examples

>>> import nipype.interfaces.freesurfer as fs
>>> sampler = fs.SampleToSurface(hemi="lh")
>>> sampler.inputs.source_file = "cope1.nii.gz"
>>> sampler.inputs.reg_file = "register.dat"
>>> sampler.inputs.sampling_method = "average"
>>> sampler.inputs.sampling_range = 1
>>> sampler.inputs.sampling_units = "frac"
>>> sampler.cmdline  
'mri_vol2surf --hemi lh --o ...lh.cope1.mgz --reg register.dat --projfrac-avg 1.000 --mov cope1.nii.gz'
>>> res = sampler.run() 

Inputs:

[Mandatory]
source_file: (an existing file name)
        volume to sample values from
        argument: ``--mov %s``
hemi: ('lh' or 'rh')
        target hemisphere
        argument: ``--hemi %s``
reg_file: (an existing file name)
        source-to-reference registration file
        argument: ``--reg %s``
        mutually_exclusive: reg_file, reg_header, mni152reg
reg_header: (a boolean)
        register based on header geometry
        argument: ``--regheader %s``
        mutually_exclusive: reg_file, reg_header, mni152reg
        requires: subject_id
mni152reg: (a boolean)
        source volume is in MNI152 space
        argument: ``--mni152reg``
        mutually_exclusive: reg_file, reg_header, mni152reg
sampling_method: ('point' or 'max' or 'average')
        how to sample -- at a point or at the max or average over a range
        argument: ``%s``
        mutually_exclusive: projection_stem
        requires: sampling_range, sampling_units
projection_stem: (a string)
        stem for precomputed linear estimates and volume fractions
        mutually_exclusive: sampling_method

[Optional]
reference_file: (an existing file name)
        reference volume (default is orig.mgz)
        argument: ``--ref %s``
surface: (a string)
        target surface (default is white)
        argument: ``--surf %s``
apply_rot: (a tuple of the form: (a float, a float, a float))
        rotation angles (in degrees) to apply to reg matrix
        argument: ``--rot %.3f %.3f %.3f``
apply_trans: (a tuple of the form: (a float, a float, a float))
        translation (in mm) to apply to reg matrix
        argument: ``--trans %.3f %.3f %.3f``
override_reg_subj: (a boolean)
        override the subject in the reg file header
        argument: ``--srcsubject %s``
        requires: subject_id
sampling_range: (a float or a tuple of the form: (a float, a float, a
          float))
        sampling range - a point or a tuple of (min, max, step)
sampling_units: ('mm' or 'frac')
        sampling range type -- either 'mm' or 'frac'
smooth_vol: (a float)
        smooth input volume (mm fwhm)
        argument: ``--fwhm %.3f``
smooth_surf: (a float)
        smooth output surface (mm fwhm)
        argument: ``--surf-fwhm %.3f``
interp_method: ('nearest' or 'trilinear')
        interpolation method
        argument: ``--interp %s``
cortex_mask: (a boolean)
        mask the target surface with hemi.cortex.label
        argument: ``--cortex``
        mutually_exclusive: mask_label
mask_label: (an existing file name)
        label file to mask output with
        argument: ``--mask %s``
        mutually_exclusive: cortex_mask
float2int_method: ('round' or 'tkregister')
        method to convert reg matrix values (default is round)
        argument: ``--float2int %s``
fix_tk_reg: (a boolean)
        make reg matrix round-compatible
        argument: ``--fixtkreg``
subject_id: (a string)
        subject id
target_subject: (a string)
        sample to surface of different subject than source
        argument: ``--trgsubject %s``
surf_reg: (a boolean or a unicode string)
        use surface registration to target subject
        argument: ``--surfreg %s``
        requires: target_subject
ico_order: (an integer (int or long))
        icosahedron order when target_subject is 'ico'
        argument: ``--icoorder %d``
        requires: target_subject
reshape: (a boolean)
        reshape surface vector to fit in non-mgh format
        argument: ``--reshape``
        mutually_exclusive: no_reshape
no_reshape: (a boolean)
        do not reshape surface vector (default)
        argument: ``--noreshape``
        mutually_exclusive: reshape
reshape_slices: (an integer (int or long))
        number of 'slices' for reshaping
        argument: ``--rf %d``
scale_input: (a float)
        multiple all intensities by scale factor
        argument: ``--scale %.3f``
frame: (an integer (int or long))
        save only one frame (0-based)
        argument: ``--frame %d``
out_file: (a file name)
        surface file to write
        argument: ``--o %s``
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' or 'gii')
        output file type
        argument: ``--out_type %s``
hits_file: (a boolean or an existing file name)
        save image with number of hits at each voxel
        argument: ``--srchit %s``
hits_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')
        hits file type
        argument: ``--srchit_type``
vox_file: (a boolean or a file name)
        text file with the number of voxels intersecting the surface
        argument: ``--nvox %s``
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (an existing file name)
        surface file
hits_file: (an existing file name)
        image with number of hits at each voxel
vox_file: (an existing file name)
        text file with the number of voxels intersecting the surface

SmoothTessellation

Link to code

Wraps the executable command mris_smooth.

This program smooths the tessellation of a surface using ‘mris_smooth’

See also

SurfaceSmooth() Interface
For smoothing a scalar field along a surface manifold

Example

>>> import nipype.interfaces.freesurfer as fs
>>> smooth = fs.SmoothTessellation()
>>> smooth.inputs.in_file = 'lh.hippocampus.stl'
>>> smooth.run() 

Inputs:

[Mandatory]
in_file: (an existing file name)
        Input volume to tesselate voxels from.
        argument: ``%s``, position: -2

[Optional]
curvature_averaging_iterations: (an integer (int or long))
        Number of curvature averaging iterations (default=10)
        argument: ``-a %d``
smoothing_iterations: (an integer (int or long))
        Number of smoothing iterations (default=10)
        argument: ``-n %d``
snapshot_writing_iterations: (an integer (int or long))
        Write snapshot every "n" iterations
        argument: ``-w %d``
use_gaussian_curvature_smoothing: (a boolean)
        Use Gaussian curvature smoothing
        argument: ``-g``
gaussian_curvature_norm_steps: (an integer (int or long))
        Use Gaussian curvature smoothing
        argument: ``%d ``
gaussian_curvature_smoothing_steps: (an integer (int or long))
        Use Gaussian curvature smoothing
        argument: ``%d``
disable_estimates: (a boolean)
        Disables the writing of curvature and area estimates
        argument: ``-nw``
normalize_area: (a boolean)
        Normalizes the area after smoothing
        argument: ``-area``
use_momentum: (a boolean)
        Uses momentum
        argument: ``-m``
out_file: (a file name)
        output filename or True to generate one
        argument: ``%s``, position: -1
out_curvature_file: (a file name)
        Write curvature to ?h.curvname (default "curv")
        argument: ``-c %s``
out_area_file: (a file name)
        Write area to ?h.areaname (default "area")
        argument: ``-b %s``
seed: (an integer (int or long))
        Seed for setting random number generator
        argument: ``-seed %d``
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

surface: (an existing file name)
        Smoothed surface file

Sphere

Link to code

Wraps the executable command mris_sphere.

This program will add a template into an average surface

Examples

>>> from nipype.interfaces.freesurfer import Sphere
>>> sphere = Sphere()
>>> sphere.inputs.in_file = 'lh.pial'
>>> sphere.cmdline
'mris_sphere lh.pial lh.sphere'

Inputs:

[Mandatory]
in_file: (an existing file name)
        Input file for Sphere
        argument: ``%s``, position: -2

[Optional]
out_file: (a file name)
        Output file for Sphere
        argument: ``%s``, position: -1
seed: (an integer (int or long))
        Seed for setting random number generator
        argument: ``-seed %d``
magic: (a boolean)
        No documentation. Direct questions to analysis-
        bugs@nmr.mgh.harvard.edu
        argument: ``-q``
in_smoothwm: (an existing file name)
        Input surface required when -q flag is not selected
num_threads: (an integer (int or long))
        allows for specifying more threads
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (a file name)
        Output file for Sphere

Surface2VolTransform

Link to code

Wraps the executable command mri_surf2vol.

Use FreeSurfer mri_surf2vol to apply a transform.

Examples

>>> from nipype.interfaces.freesurfer import Surface2VolTransform
>>> xfm2vol = Surface2VolTransform()
>>> xfm2vol.inputs.source_file = 'lh.cope1.mgz'
>>> xfm2vol.inputs.reg_file = 'register.mat'
>>> xfm2vol.inputs.hemi = 'lh'
>>> xfm2vol.inputs.template_file = 'cope1.nii.gz'
>>> xfm2vol.inputs.subjects_dir = '.'
>>> xfm2vol.cmdline
'mri_surf2vol --hemi lh --volreg register.mat --surfval lh.cope1.mgz --sd . --template cope1.nii.gz --outvol lh.cope1_asVol.nii --vtxvol lh.cope1_asVol_vertex.nii'
>>> res = xfm2vol.run()

Inputs:

[Mandatory]
source_file: (an existing file name)
        This is the source of the surface values
        argument: ``--surfval %s``
        mutually_exclusive: mkmask
hemi: (a unicode string)
        hemisphere of data
        argument: ``--hemi %s``
reg_file: (an existing file name)
        tkRAS-to-tkRAS matrix (tkregister2 format)
        argument: ``--volreg %s``
        mutually_exclusive: subject_id

[Optional]
transformed_file: (a file name)
        Output volume
        argument: ``--outvol %s``
template_file: (an existing file name)
        Output template volume
        argument: ``--template %s``
mkmask: (a boolean)
        make a mask instead of loading surface values
        argument: ``--mkmask``
        mutually_exclusive: source_file
vertexvol_file: (a file name)
        Path name of the vertex output volume, which is the same as output
        volume except that the value of each voxel is the vertex-id that is
        mapped to that voxel.
        argument: ``--vtxvol %s``
surf_name: (a unicode string)
        surfname (default is white)
        argument: ``--surf %s``
projfrac: (a float)
        thickness fraction
        argument: ``--projfrac %s``
subjects_dir: (a unicode string)
        freesurfer subjects directory defaults to $SUBJECTS_DIR
        argument: ``--sd %s``
subject_id: (a unicode string)
        subject id
        argument: ``--identity %s``
        mutually_exclusive: reg_file
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

transformed_file: (an existing file name)
        Path to output file if used normally
vertexvol_file: (a file name)
        vertex map volume path id. Optional

SurfaceSmooth

Link to code

Wraps the executable command mri_surf2surf.

Smooth a surface image with mri_surf2surf.

The surface is smoothed by an interative process of averaging the value at each vertex with those of its adjacent neighbors. You may supply either the number of iterations to run or a desired effective FWHM of the smoothing process. If the latter, the underlying program will calculate the correct number of iterations internally.

See also

SmoothTessellation() Interface
For smoothing a tessellated surface (e.g. in gifti or .stl)

Examples

>>> import nipype.interfaces.freesurfer as fs
>>> smoother = fs.SurfaceSmooth()
>>> smoother.inputs.in_file = "lh.cope1.mgz"
>>> smoother.inputs.subject_id = "subj_1"
>>> smoother.inputs.hemi = "lh"
>>> smoother.inputs.fwhm = 5
>>> smoother.cmdline 
'mri_surf2surf --cortex --fwhm 5.0000 --hemi lh --sval lh.cope1.mgz --tval ...lh.cope1_smooth5.mgz --s subj_1'
>>> smoother.run() 

Inputs:

[Mandatory]
in_file: (a file name)
        source surface file
        argument: ``--sval %s``
subject_id: (a string)
        subject id of surface file
        argument: ``--s %s``
hemi: ('lh' or 'rh')
        hemisphere to operate on
        argument: ``--hemi %s``

[Optional]
fwhm: (a float)
        effective FWHM of the smoothing process
        argument: ``--fwhm %.4f``
        mutually_exclusive: smooth_iters
smooth_iters: (an integer (int or long))
        iterations of the smoothing process
        argument: ``--smooth %d``
        mutually_exclusive: fwhm
cortex: (a boolean, nipype default value: True)
        only smooth within $hemi.cortex.label
        argument: ``--cortex``
reshape: (a boolean)
        reshape surface vector to fit in non-mgh format
        argument: ``--reshape``
out_file: (a file name)
        surface file to write
        argument: ``--tval %s``
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (an existing file name)
        smoothed surface file

SurfaceSnapshots

Link to code

Wraps the executable command tksurfer.

Use Tksurfer to save pictures of the cortical surface.

By default, this takes snapshots of the lateral, medial, ventral, and dorsal surfaces. See the six_images option to add the anterior and posterior surfaces.

You may also supply your own tcl script (see the Freesurfer wiki for information on scripting tksurfer). The screenshot stem is set as the environment variable “_SNAPSHOT_STEM”, which you can use in your own scripts.

Node that this interface will not run if you do not have graphics enabled on your system.

Examples

>>> import nipype.interfaces.freesurfer as fs
>>> shots = fs.SurfaceSnapshots(subject_id="fsaverage", hemi="lh", surface="pial")
>>> shots.inputs.overlay = "zstat1.nii.gz"
>>> shots.inputs.overlay_range = (2.3, 6)
>>> shots.inputs.overlay_reg = "register.dat"
>>> res = shots.run() 

Inputs:

[Mandatory]
subject_id: (a string)
        subject to visualize
        argument: ``%s``, position: 1
hemi: ('lh' or 'rh')
        hemisphere to visualize
        argument: ``%s``, position: 2
surface: (a string)
        surface to visualize
        argument: ``%s``, position: 3

[Optional]
show_curv: (a boolean)
        show curvature
        argument: ``-curv``
        mutually_exclusive: show_gray_curv
show_gray_curv: (a boolean)
        show curvature in gray
        argument: ``-gray``
        mutually_exclusive: show_curv
overlay: (an existing file name)
        load an overlay volume/surface
        argument: ``-overlay %s``
        requires: overlay_range
overlay_reg: (a file name)
        registration matrix file to register overlay to surface
        argument: ``-overlay-reg %s``
        mutually_exclusive: overlay_reg, identity_reg, mni152_reg
identity_reg: (a boolean)
        use the identity matrix to register the overlay to the surface
        argument: ``-overlay-reg-identity``
        mutually_exclusive: overlay_reg, identity_reg, mni152_reg
mni152_reg: (a boolean)
        use to display a volume in MNI152 space on the average subject
        argument: ``-mni152reg``
        mutually_exclusive: overlay_reg, identity_reg, mni152_reg
overlay_range: (a float or a tuple of the form: (a float, a float) or
          a tuple of the form: (a float, a float, a float))
        overlay range--either min, (min, max) or (min, mid, max)
        argument: ``%s``
overlay_range_offset: (a float)
        overlay range will be symettric around offset value
        argument: ``-foffset %.3f``
truncate_overlay: (a boolean)
        truncate the overlay display
        argument: ``-truncphaseflag 1``
reverse_overlay: (a boolean)
        reverse the overlay display
        argument: ``-revphaseflag 1``
invert_overlay: (a boolean)
        invert the overlay display
        argument: ``-invphaseflag 1``
demean_overlay: (a boolean)
        remove mean from overlay
        argument: ``-zm``
annot_file: (an existing file name)
        path to annotation file to display
        argument: ``-annotation %s``
        mutually_exclusive: annot_name
annot_name: (a string)
        name of annotation to display (must be in $subject/label directory
        argument: ``-annotation %s``
        mutually_exclusive: annot_file
label_file: (an existing file name)
        path to label file to display
        argument: ``-label %s``
        mutually_exclusive: label_name
label_name: (a string)
        name of label to display (must be in $subject/label directory
        argument: ``-label %s``
        mutually_exclusive: label_file
colortable: (an existing file name)
        load colortable file
        argument: ``-colortable %s``
label_under: (a boolean)
        draw label/annotation under overlay
        argument: ``-labels-under``
label_outline: (a boolean)
        draw label/annotation as outline
        argument: ``-label-outline``
patch_file: (an existing file name)
        load a patch
        argument: ``-patch %s``
orig_suffix: (a string)
        set the orig surface suffix string
        argument: ``-orig %s``
sphere_suffix: (a string)
        set the sphere.reg suffix string
        argument: ``-sphere %s``
show_color_scale: (a boolean)
        display the color scale bar
        argument: ``-colscalebarflag 1``
show_color_text: (a boolean)
        display text in the color scale bar
        argument: ``-colscaletext 1``
six_images: (a boolean)
        also take anterior and posterior snapshots
screenshot_stem: (a string)
        stem to use for screenshot file names
stem_template_args: (a list of items which are a string)
        input names to use as arguments for a string-formated stem template
        requires: screenshot_stem
tcl_script: (an existing file name)
        override default screenshot script
        argument: ``%s``
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

snapshots: (a list of items which are an existing file name)
        tiff images of the surface from different perspectives

SurfaceTransform

Link to code

Wraps the executable command mri_surf2surf.

Transform a surface file from one subject to another via a spherical registration.

Both the source and target subject must reside in your Subjects Directory, and they must have been processed with recon-all, unless you are transforming to one of the icosahedron meshes.

Examples

>>> from nipype.interfaces.freesurfer import SurfaceTransform
>>> sxfm = SurfaceTransform()
>>> sxfm.inputs.source_file = "lh.cope1.nii.gz"
>>> sxfm.inputs.source_subject = "my_subject"
>>> sxfm.inputs.target_subject = "fsaverage"
>>> sxfm.inputs.hemi = "lh"
>>> sxfm.run() 

Inputs:

[Mandatory]
source_file: (an existing file name)
        surface file with source values
        argument: ``--sval %s``
        mutually_exclusive: source_annot_file
source_annot_file: (an existing file name)
        surface annotation file
        argument: ``--sval-annot %s``
        mutually_exclusive: source_file
source_subject: (a string)
        subject id for source surface
        argument: ``--srcsubject %s``
hemi: ('lh' or 'rh')
        hemisphere to transform
        argument: ``--hemi %s``
target_subject: (a string)
        subject id of target surface
        argument: ``--trgsubject %s``

[Optional]
target_ico_order: (1 or 2 or 3 or 4 or 5 or 6 or 7)
        order of the icosahedron if target_subject is 'ico'
        argument: ``--trgicoorder %d``
source_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')
        source file format
        argument: ``--sfmt %s``
        requires: source_file
target_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 'gii')
        output format
        argument: ``--tfmt %s``
reshape: (a boolean)
        reshape output surface to conform with Nifti
        argument: ``--reshape``
reshape_factor: (an integer (int or long))
        number of slices in reshaped image
        argument: ``--reshape-factor``
out_file: (a file name)
        surface file to write
        argument: ``--tval %s``
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (an existing file name)
        transformed surface file

TalairachAVI

Link to code

Wraps the executable command talairach_avi.

Front-end for Avi Snyders image registration tool. Computes the talairach transform that maps the input volume to the MNI average_305. This does not add the xfm to the header of the input file. When called by recon-all, the xfm is added to the header after the transform is computed.

Examples

>>> from nipype.interfaces.freesurfer import TalairachAVI
>>> example = TalairachAVI()
>>> example.inputs.in_file = 'norm.mgz'
>>> example.inputs.out_file = 'trans.mat'
>>> example.cmdline
'talairach_avi --i norm.mgz --xfm trans.mat'
>>> example.run() 

Inputs:

[Mandatory]
in_file: (an existing file name)
        input volume
        argument: ``--i %s``
out_file: (a file name)
        output xfm file
        argument: ``--xfm %s``

[Optional]
atlas: (a string)
        alternate target atlas (in freesurfer/average dir)
        argument: ``--atlas %s``
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_file: (a file name)
        The output transform for TalairachAVI
out_log: (a file name)
        The output log file for TalairachAVI
out_txt: (a file name)
        The output text file for TaliarachAVI

TalairachQC

Link to code

Wraps the executable command tal_QC_AZS.

Examples

>>> from nipype.interfaces.freesurfer import TalairachQC
>>> qc = TalairachQC()
>>> qc.inputs.log_file = 'dirs.txt'
>>> qc.cmdline
'tal_QC_AZS dirs.txt'

Inputs:

[Mandatory]
log_file: (an existing file name)
        The log file for TalairachQC
        argument: ``%s``, position: 0

[Optional]
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

log_file: (an existing file name, nipype default value:
          output.nipype)
        The output log

Tkregister2

Link to code

Wraps the executable command tkregister2.

Examples

Get transform matrix between orig (tkRAS) and native (scannerRAS) coordinates in Freesurfer. Implements the first step of mapping surfaces to native space in this guide.

>>> from nipype.interfaces.freesurfer import Tkregister2
>>> tk2 = Tkregister2(reg_file='T1_to_native.dat')
>>> tk2.inputs.moving_image = 'T1.mgz'
>>> tk2.inputs.target_image = 'structural.nii'
>>> tk2.inputs.reg_header = True
>>> tk2.cmdline
'tkregister2 --mov T1.mgz --noedit --reg T1_to_native.dat --regheader --targ structural.nii'
>>> tk2.run() 

The example below uses tkregister2 without the manual editing stage to convert FSL-style registration matrix (.mat) to FreeSurfer-style registration matrix (.dat)

>>> from nipype.interfaces.freesurfer import Tkregister2
>>> tk2 = Tkregister2()
>>> tk2.inputs.moving_image = 'epi.nii'
>>> tk2.inputs.fsl_in_matrix = 'flirt.mat'
>>> tk2.cmdline
'tkregister2 --fsl flirt.mat --mov epi.nii --noedit --reg register.dat'
>>> tk2.run() 

Inputs:

[Mandatory]
moving_image: (an existing file name)
        moving volume
        argument: ``--mov %s``
reg_file: (a file name, nipype default value: register.dat)
        freesurfer-style registration file
        argument: ``--reg %s``

[Optional]
target_image: (an existing file name)
        target volume
        argument: ``--targ %s``
        mutually_exclusive: fstarg
fstarg: (a boolean)
        use subject's T1 as reference
        argument: ``--fstarg``
        mutually_exclusive: target_image
fsl_in_matrix: (an existing file name)
        fsl-style registration input matrix
        argument: ``--fsl %s``
xfm: (an existing file name)
        use a matrix in MNI coordinates as initial registration
        argument: ``--xfm %s``
lta_in: (an existing file name)
        use a matrix in MNI coordinates as initial registration
        argument: ``--lta %s``
invert_lta_in: (a boolean)
        Invert input LTA before applying
        requires: lta_in
fsl_out: (a bool or None or a file name)
        compute an FSL-compatible resgitration matrix
        argument: ``--fslregout %s``
lta_out: (a bool or None or a file name)
        output registration file (LTA format)
        argument: ``--ltaout %s``
invert_lta_out: (a boolean)
        Invert input LTA before applying
        argument: ``--ltaout-inv``
        requires: lta_in
subject_id: (a string)
        freesurfer subject ID
        argument: ``--s %s``
noedit: (a boolean, nipype default value: True)
        do not open edit window (exit)
        argument: ``--noedit``
reg_header: (a boolean)
        compute regstration from headers
        argument: ``--regheader``
fstal: (a boolean)
        set mov to be tal and reg to be tal xfm
        argument: ``--fstal``
        mutually_exclusive: target_image, moving_image, reg_file
movscale: (a float)
        adjust registration matrix to scale mov
        argument: ``--movscale %f``
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

reg_file: (an existing file name)
        freesurfer-style registration file
fsl_file: (a file name)
        FSL-style registration file
lta_file: (a file name)
        LTA-style registration file

VolumeMask

Link to code

Wraps the executable command mris_volmask.

Computes a volume mask, at the same resolution as the <subject>/mri/brain.mgz. The volume mask contains 4 values: LH_WM (default 10), LH_GM (default 100), RH_WM (default 20), RH_GM (default 200). The algorithm uses the 4 surfaces situated in <subject>/surf/ [lh|rh].[white|pial] and labels voxels based on the signed-distance function from the surface.

Examples

>>> from nipype.interfaces.freesurfer import VolumeMask
>>> volmask = VolumeMask()
>>> volmask.inputs.left_whitelabel = 2
>>> volmask.inputs.left_ribbonlabel = 3
>>> volmask.inputs.right_whitelabel = 41
>>> volmask.inputs.right_ribbonlabel = 42
>>> volmask.inputs.lh_pial = 'lh.pial'
>>> volmask.inputs.rh_pial = 'lh.pial'
>>> volmask.inputs.lh_white = 'lh.pial'
>>> volmask.inputs.rh_white = 'lh.pial'
>>> volmask.inputs.subject_id = '10335'
>>> volmask.inputs.save_ribbon = True
>>> volmask.cmdline
'mris_volmask --label_left_ribbon 3 --label_left_white 2 --label_right_ribbon 42 --label_right_white 41 --save_ribbon 10335'

Inputs:

[Mandatory]
left_whitelabel: (an integer (int or long))
        Left white matter label
        argument: ``--label_left_white %d``
left_ribbonlabel: (an integer (int or long))
        Left cortical ribbon label
        argument: ``--label_left_ribbon %d``
right_whitelabel: (an integer (int or long))
        Right white matter label
        argument: ``--label_right_white %d``
right_ribbonlabel: (an integer (int or long))
        Right cortical ribbon label
        argument: ``--label_right_ribbon %d``
lh_pial: (an existing file name)
        Implicit input left pial surface
rh_pial: (an existing file name)
        Implicit input right pial surface
lh_white: (an existing file name)
        Implicit input left white matter surface
rh_white: (an existing file name)
        Implicit input right white matter surface
subject_id: (a string, nipype default value: subject_id)
        Subject being processed
        argument: ``%s``, position: -1

[Optional]
aseg: (an existing file name)
        Implicit aseg.mgz segmentation. Specify a different aseg by using
        the 'in_aseg' input.
        mutually_exclusive: in_aseg
in_aseg: (an existing file name)
        Input aseg file for VolumeMask
        argument: ``--aseg_name %s``
        mutually_exclusive: aseg
save_ribbon: (a boolean)
        option to save just the ribbon for the hemispheres in the format
        ?h.ribbon.mgz
        argument: ``--save_ribbon``
copy_inputs: (a boolean)
        If running as a node, set this to True.This will copy the implicit
        input files to the node directory.
subjects_dir: (an existing directory name)
        subjects directory
args: (a unicode string)
        Additional parameters to the command
        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', nipype default value: {})
        Environment variables

Outputs:

out_ribbon: (a file name)
        Output cortical ribbon mask
lh_ribbon: (a file name)
        Output left cortical ribbon mask
rh_ribbon: (a file name)
        Output right cortical ribbon mask

copy2subjdir()

Link to code

Method to copy an input to the subjects directory

createoutputdirs()

Link to code

create all output directories. If not created, some freesurfer interfaces fail