nipype.interfaces.freesurfer.utils module

Interfaces to assorted Freesurfer utility programs.

AddXFormToHeader

Link to code

Bases: FSCommand

Wrapped executable: mri_add_xform_to_header.

Just adds specified xform to the volume header.

Danger

Input transform MUST be an absolute path to a DataSink’ed transform or the output will reference a transform in the workflow cache directory!

Examples

>>> 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]

Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Input volume. Maps to a command-line argument: %s (position: -2).

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

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

  • copy_name (a boolean) – Do not try to load the xfmfile, just copy name. Maps to a command-line argument: -c.

  • 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) – Output volume. Maps to a command-line argument: %s (position: -1). (Nipype default value: output.mgz)

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

  • verbose (a boolean) – Be verbose. Maps to a command-line argument: -v.

Outputs:

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

Aparc2Aseg

Link to code

Bases: FSCommand

Wrapped executable: 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'
Mandatory Inputs:
  • lh_annotation (a pathlike object or string representing an existing file) – Input file must be <subject_id>/label/lh.aparc.annot.

  • lh_pial (a pathlike object or string representing an existing file) – Input file must be <subject_id>/surf/lh.pial.

  • lh_ribbon (a pathlike object or string representing an existing file) – Input file must be <subject_id>/mri/lh.ribbon.mgz.

  • lh_white (a pathlike object or string representing an existing file) – Input file must be <subject_id>/surf/lh.white.

  • out_file (a pathlike object or string representing a file) – Full path of file to save the output segmentation in. Maps to a command-line argument: --o %s.

  • rh_annotation (a pathlike object or string representing an existing file) – Input file must be <subject_id>/label/rh.aparc.annot.

  • rh_pial (a pathlike object or string representing an existing file) – Input file must be <subject_id>/surf/rh.pial.

  • rh_ribbon (a pathlike object or string representing an existing file) – Input file must be <subject_id>/mri/rh.ribbon.mgz.

  • rh_white (a pathlike object or string representing an existing file) – Input file must be <subject_id>/surf/rh.white.

  • ribbon (a pathlike object or string representing an existing file) – Input file must be <subject_id>/mri/ribbon.mgz.

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

Optional Inputs:
  • a2009s (a boolean) – Using the a2009s atlas. Maps to a command-line argument: --a2009s.

  • 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) – Input aseg file. Maps to a command-line argument: --aseg %s.

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

  • ctxseg (a pathlike object or string representing an existing file) – Maps to a command-line argument: --ctxseg %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: {})

  • filled (a pathlike object or string representing an existing file) – Implicit input filled file. Only required with FS v5.3.

  • hypo_wm (a boolean) – Label hypointensities as WM. Maps to a command-line argument: --hypo-as-wm.

  • 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. Maps to a command-line argument: --labelwm.

  • rip_unknown (a boolean) – Do not label WM based on ‘unknown’ corical label. Maps to a command-line argument: --rip-unknown.

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

  • volmask (a boolean) – Volume mask flag. Maps to a command-line argument: --volmask.

Outputs:

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

Aparc2Aseg.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

Apas2Aseg

Link to code

Bases: FSCommand

Wrapped executable: 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'
Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Input aparc+aseg.mgz. Maps to a command-line argument: --i %s.

  • out_file (a pathlike object or string representing a file) – Output aseg file. Maps to a command-line argument: --o %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: {})

  • 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 aseg file. Maps to a command-line argument: %s.

ApplyMask

Link to code

Bases: FSCommand

Wrapped executable: 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.

Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Input image (will be masked). Maps to a command-line argument: %s (position: -3).

  • mask_file (a pathlike object or string representing an existing file) – Image defining mask space. 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_xfm (a boolean) – Invert transformation. Maps to a command-line argument: -invert.

  • keep_mask_deletion_edits (a boolean) – Transfer voxel-deletion edits (voxels=1) from mask to out vol. Maps to a command-line argument: -keep_mask_deletion_edits.

  • mask_thresh (a float) – Threshold mask before applying. Maps to a command-line argument: -T %.4f.

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

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

  • transfer (an integer) – Transfer only voxel value # from mask to out. Maps to a command-line argument: -transfer %d.

  • use_abs (a boolean) – Take absolute value of mask before applying. Maps to a command-line argument: -abs.

  • xfm_file (a pathlike object or string representing an existing file) – LTA-format transformation matrix to align mask with input. Maps to a command-line argument: -xform %s.

  • xfm_source (a pathlike object or string representing an existing file) – Image defining transform source space. Maps to a command-line argument: -lta_src %s.

  • xfm_target (a pathlike object or string representing an existing file) – Image defining transform target space. Maps to a command-line argument: -lta_dst %s.

Outputs:

out_file (a pathlike object or string representing an existing file) – Masked image.

CheckTalairachAlignment

Link to code

Bases: FSCommand

Wrapped executable: 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() 
Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Specify the talairach.xfm file to check. Maps to a command-line argument: -xfm %s (position: -1). Mutually exclusive with inputs: subject.

  • subject (a string) – Specify subject’s name. Maps to a command-line argument: -subj %s (position: -1). Mutually exclusive with inputs: in_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: {})

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

  • threshold (a float) – Talairach transforms for subjects with p-values <= T are considered as very unlikely default=0.010. Maps to a command-line argument: -T %.3f. (Nipype default value: 0.01)

Outputs:

out_file (a pathlike object or string representing an existing file) – The input file for CheckTalairachAlignment.

Contrast

Link to code

Bases: FSCommand

Wrapped executable: 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'
Mandatory Inputs:
  • annotation (a pathlike object or string representing an existing file) – Input annotation file must be <subject_id>/label/<hemisphere>.aparc.annot.

  • cortex (a pathlike object or string representing an existing file) – Input cortex label must be <subject_id>/label/<hemisphere>.cortex.label.

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

  • orig (a pathlike object or string representing an existing file) – Implicit input file mri/orig.mgz.

  • rawavg (a pathlike object or string representing an existing file) – Implicit input file mri/rawavg.mgz.

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

  • thickness (a pathlike object or string representing an existing file) – Input file must be <subject_id>/surf/?h.thickness.

  • white (a pathlike object or string representing an existing file) – Input file must be <subject_id>/surf/<hemisphere>.white.

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

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

Outputs:
  • out_contrast (a pathlike object or string representing a file) – Output contrast file from Contrast.

  • out_log (a pathlike object or string representing an existing file) – Output log from Contrast.

  • out_stats (a pathlike object or string representing a file) – Output stats file from Contrast.

Contrast.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

Curvature

Link to code

Bases: FSCommand

Wrapped executable: 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'
Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – Input file for Curvature. 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.

  • averages (an integer) – Perform this number iterative averages of curvature measure before saving. Maps to a command-line argument: -a %d.

  • copy_input (a boolean) – Copy input file to current directory.

  • distances (a tuple of the form: (an integer, an integer)) – Undocumented input integer distances. Maps to a command-line argument: -distances %d %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: {})

  • n (a boolean) – Undocumented boolean flag. Maps to a command-line argument: -n.

  • save (a boolean) – Save curvature files (will only generate screen output without this option). Maps to a command-line argument: -w.

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

  • threshold (a float) – Undocumented input threshold. Maps to a command-line argument: -thresh %.3f.

Outputs:
  • out_gauss (a pathlike object or string representing a file) – Gaussian curvature output file.

  • out_mean (a pathlike object or string representing a file) – Mean curvature output file.

CurvatureStats

Link to code

Bases: FSCommand

Wrapped executable: 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'
Mandatory Inputs:
  • curvfile1 (a pathlike object or string representing an existing file) – Input file for CurvatureStats. Maps to a command-line argument: %s (position: -2).

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

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

  • subject_id (a string) – Subject being processed. Maps to a command-line argument: %s (position: -4). (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: {})

  • min_max (a boolean) – Output min / max information for the processed curvature. Maps to a command-line argument: -m.

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

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

  • surface (a pathlike object or string representing an existing file) – Specify surface file for CurvatureStats. Maps to a command-line argument: -F %s.

  • values (a boolean) – Triggers a series of derived curvature values. Maps to a command-line argument: -G.

  • write (a boolean) – Write curvature files. Maps to a command-line argument: --writeCurvatureFiles.

Outputs:

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

CurvatureStats.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

EulerNumber

Link to code

Bases: FSCommand

Wrapped executable: 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'
Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – Input file for EulerNumber. 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:
  • defects (an integer) – Number of defects.

  • euler (an integer) – Euler number of cortical surface. A value of 2 signals a topologically correct surface model with no holes.

ExtractMainComponent

Link to code

Bases: CommandLine

Wrapped executable: mris_extract_main_component.

Extract the main component of a tessellated surface

Examples

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

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

  • out_file (a pathlike object or string representing a file) – Surface containing main component. Maps to a command-line argument: %s (position: 2).

Outputs:

out_file (a pathlike object or string representing an existing file) – Surface containing main component.

FixTopology

Link to code

Bases: FSCommand

Wrapped executable: 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'
Mandatory Inputs:
  • copy_inputs (a boolean) – If running as a node, set this to True otherwise, the topology fixing will be done in place.

  • hemisphere (a string) – Hemisphere being processed. Maps to a command-line argument: %s (position: -1).

  • in_brain (a pathlike object or string representing an existing file) – Implicit input brain.mgz.

  • in_inflated (a pathlike object or string representing an existing file) – Undocumented input file <hemisphere>.inflated.

  • in_orig (a pathlike object or string representing an existing file) – Undocumented input file <hemisphere>.orig.

  • in_wm (a pathlike object or string representing an existing file) – Implicit input wm.mgz.

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

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

  • ga (a boolean) – No documentation. Direct questions to analysis-bugs@nmr.mgh.harvard.edu. Maps to a command-line argument: -ga.

  • mgz (a boolean) – No documentation. Direct questions to analysis-bugs@nmr.mgh.harvard.edu. Maps to a command-line argument: -mgz.

  • seed (an integer) – Seed for setting random number generator. Maps to a command-line argument: -seed %d.

  • sphere (a pathlike object or string representing a file) – Sphere input file. Maps to a command-line argument: -sphere %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 file for FixTopology.

FixTopology.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

ImageInfo

Link to code

Bases: FSCommand

Wrapped executable: mri_info.

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

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

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

Outputs:
  • TE (a string) – Echo time (msec).

  • TI (a string) – Inversion time (msec).

  • TR (a string) – Repetition time(msec).

  • data_type (a string) – Image data type.

  • dimensions (a tuple) – Image dimensions (voxels).

  • file_format (a string) – File format.

  • info (any value) – Output of mri_info.

  • orientation (a string) – Image orientation.

  • out_file (a pathlike object or string representing an existing file) – Text file with image information.

  • ph_enc_dir (a string) – Phase encode direction.

  • vox_sizes (a tuple) – Voxel sizes (mm).

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

Collate expected outputs and apply output traits validation.

ImageInfo.info_regexp(info, field, delim='\n')

Jacobian

Link to code

Bases: FSCommand

Wrapped executable: 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'
Mandatory Inputs:
  • in_mappedsurf (a pathlike object or string representing an existing file) – Mapped surface. Maps to a command-line argument: %s (position: -2).

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

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

  • out_file (a pathlike object or string representing a file) – Output Jacobian of the surface mapping. Maps to a command-line argument: %s (position: -1).

  • 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 Jacobian of the surface mapping.

LTAConvert

Link to code

Bases: CommandLine

Wrapped executable: 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.

Mandatory Inputs:
  • in_fsl (a pathlike object or string representing an existing file) – Input transform of FSL type. Maps to a command-line argument: --infsl %s. Mutually exclusive with inputs: in_lta, in_fsl, in_mni, in_reg, in_niftyreg, in_itk.

  • in_itk (a pathlike object or string representing an existing file) – Input transform of ITK type. Maps to a command-line argument: --initk %s. Mutually exclusive with inputs: in_lta, in_fsl, in_mni, in_reg, in_niftyreg, in_itk.

  • in_lta (a pathlike object or string representing an existing file or ‘identity.nofile’) – Input transform of LTA type. Maps to a command-line argument: --inlta %s. Mutually exclusive with inputs: in_lta, in_fsl, in_mni, in_reg, in_niftyreg, in_itk.

  • in_mni (a pathlike object or string representing an existing file) – Input transform of MNI/XFM type. Maps to a command-line argument: --inmni %s. Mutually exclusive with inputs: in_lta, in_fsl, in_mni, in_reg, in_niftyreg, in_itk.

  • in_niftyreg (a pathlike object or string representing an existing file) – Input transform of Nifty Reg type (inverse RAS2RAS). Maps to a command-line argument: --inniftyreg %s. Mutually exclusive with inputs: in_lta, in_fsl, in_mni, in_reg, in_niftyreg, in_itk.

  • in_reg (a pathlike object or string representing an existing file) – Input transform of TK REG type (deprecated format). Maps to a command-line argument: --inreg %s. Mutually exclusive with inputs: in_lta, in_fsl, in_mni, in_reg, in_niftyreg, in_itk.

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 (a boolean) – Maps to a command-line argument: --invert.

  • ltavox2vox (a boolean) – Maps to a command-line argument: --ltavox2vox. Requires inputs: out_lta.

  • out_fsl (a boolean or a pathlike object or string representing a file) – Output transform in FSL format. Maps to a command-line argument: --outfsl %s.

  • out_itk (a boolean or a pathlike object or string representing a file) – Output transform in ITK format. Maps to a command-line argument: --outitk %s.

  • out_lta (a boolean or a pathlike object or string representing a file) – Output linear transform (LTA Freesurfer format). Maps to a command-line argument: --outlta %s.

  • out_mni (a boolean or a pathlike object or string representing a file) – Output transform in MNI/XFM format. Maps to a command-line argument: --outmni %s.

  • out_reg (a boolean or a pathlike object or string representing a file) – Output transform in reg dat format. Maps to a command-line argument: --outreg %s.

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

  • target_conform (a boolean) – Maps to a command-line argument: --trgconform.

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

Outputs:
  • out_fsl (a pathlike object or string representing an existing file) – Output transform in FSL format.

  • out_itk (a pathlike object or string representing an existing file) – Output transform in ITK format.

  • out_lta (a pathlike object or string representing an existing file) – Output linear transform (LTA Freesurfer format).

  • out_mni (a pathlike object or string representing an existing file) – Output transform in MNI/XFM format.

  • out_reg (a pathlike object or string representing an existing file) – Output transform in reg dat format.

MRIFill

Link to code

Bases: FSCommand

Wrapped executable: mri_fill.

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

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'
Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Input white matter file. Maps to a command-line argument: %s (position: -2).

  • out_file (a pathlike object or string representing a file) – Output filled volume file name for MRIFill. 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: {})

  • log_file (a pathlike object or string representing a file) – Output log file for MRIFill. Maps to a command-line argument: -a %s.

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

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

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

Outputs:
  • log_file (a pathlike object or string representing a file) – Output log file from MRIFill.

  • out_file (a pathlike object or string representing a file) – Output file from MRIFill.

MRIMarchingCubes

Link to code

Bases: FSCommand

Wrapped executable: 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() 
Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Input volume to tessellate voxels from. Maps to a command-line argument: %s (position: 1).

  • label_value (an integer) – Label value which to tessellate from the input volume. (integer, if input is “filled.mgz” volume, 127 is rh, 255 is lh). Maps to a command-line argument: %d (position: 2).

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

  • connectivity_value (an integer) – Alter the marching cubes connectivity: 1=6+,2=18,3=6,4=26 (default=1). Maps to a command-line argument: %d (position: -1). (Nipype default value: 1)

  • 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) – Output filename or True to generate one. Maps to a command-line argument: ./%s (position: -2).

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

Outputs:

surface (a pathlike object or string representing an existing file) – Binary surface of the tessellation .

MRIPretess

Link to code

Bases: FSCommand

Wrapped executable: mri_pretess.

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

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() 
Mandatory Inputs:
  • in_filled (a pathlike object or string representing an existing file) – Filled volume, usually wm.mgz. Maps to a command-line argument: %s (position: -4).

  • in_norm (a pathlike object or string representing an existing file) – The normalized, brain-extracted T1w image. Usually norm.mgz. Maps to a command-line argument: %s (position: -2).

  • label (a string or an integer) – 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). Maps to a command-line argument: %s (position: -3). (Nipype default value: wm)

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 (a boolean) – Keep WM edits. Maps to a command-line argument: -keep.

  • nocorners (a boolean) – Do not remove corner configurations in addition to edge ones. Maps to a command-line argument: -nocorners.

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

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

  • 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. Maps to a command-line argument: -test.

Outputs:

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

MRITessellate

Link to code

Bases: FSCommand

Wrapped executable: 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() 
Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Input volume to tessellate voxels from. Maps to a command-line argument: %s (position: -3).

  • label_value (an integer) – Label value which to tessellate from the input volume. (integer, if input is “filled.mgz” volume, 127 is rh, 255 is lh). Maps to a command-line argument: %d (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: {})

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

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

  • tesselate_all_voxels (a boolean) – Tessellate the surface of all voxels with different labels. Maps to a command-line argument: -a.

  • use_real_RAS_coordinates (a boolean) – Saves surface with real RAS coordinates where c_(r,a,s) != 0. Maps to a command-line argument: -n.

Outputs:

surface (a pathlike object or string representing an existing file) – Binary surface of the tessellation .

MRIsCalc

Link to code

Bases: FSCommand

Wrapped executable: 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'
Mandatory Inputs:
  • action (a string) – Action to perform on input file(s). Maps to a command-line argument: %s (position: -2).

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

  • out_file (a pathlike object or string representing a file) – Output file after calculation. Maps to a command-line argument: -o %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: {})

  • in_file2 (a pathlike object or string representing an existing file) – Input file 2. Maps to a command-line argument: %s (position: -1). Mutually exclusive with inputs: in_float, in_int.

  • in_float (a float) – Input float. Maps to a command-line argument: %f (position: -1). Mutually exclusive with inputs: in_file2, in_int.

  • in_int (an integer) – Input integer. Maps to a command-line argument: %d (position: -1). Mutually exclusive with inputs: in_file2, in_float.

  • 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 file after calculation.

MRIsCombine

Link to code

Bases: FSSurfaceCommand

Wrapped executable: 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()  
Mandatory Inputs:
  • in_files (a list of from 2 to 2 items which are a pathlike object or string representing a file) – Two surfaces to be combined. Maps to a command-line argument: --combinesurfs %s (position: 1).

  • out_file (a pathlike object or string representing a file) – Output filename. Combined surfaces from in_files. 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 an existing file) – Output filename. Combined surfaces from in_files.

MRIsCombine.normalize_filenames()

Filename normalization routine to perform only when run in Node context. Interpret out_file as a literal path to reduce surprise.

MRIsConvert

Link to code

Bases: FSCommand

Wrapped executable: 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() 
Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – File to read/convert. Maps to a command-line argument: %s (position: -2).

  • 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 with inputs: out_file.

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

Optional Inputs:
  • annot_file (a pathlike object or string representing an existing file) – Input is annotation or gifti label data. Maps to a command-line argument: --annot %s.

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

  • dataarray_num (an integer) – If input is gifti, ‘num’ specifies which data array to use. Maps to a command-line argument: --da_num %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: {})

  • functional_file (a pathlike object or string representing an existing file) – Input is functional time-series or other multi-frame data (must specify surface). Maps to a command-line argument: -f %s.

  • label_file (a pathlike object or string representing an existing file) – Infile is .label file, label is name of this label. Maps to a command-line argument: --label %s.

  • labelstats_outfile (a pathlike object or string representing a file) – Outfile is name of gifti file to which label stats will be written. Maps to a command-line argument: --labelstats %s.

  • normal (a boolean) – Output is an ascii file where vertex data. Maps to a command-line argument: -n.

  • origname (a string) – Read orig positions. Maps to a command-line argument: -o %s.

  • parcstats_file (a pathlike object or string representing an existing file) – Infile is name of text file containing label/val pairs. Maps to a command-line argument: --parcstats %s.

  • patch (a boolean) – Input is a patch, not a full surface. Maps to a command-line argument: -p.

  • rescale (a boolean) – Rescale vertex xyz so total area is same as group average. Maps to a command-line argument: -r.

  • scalarcurv_file (a pathlike object or string representing an existing file) – Input is scalar curv overlay file (must still specify surface). Maps to a command-line argument: -c %s.

  • scale (a float) – Scale vertex xyz by scale. Maps to a command-line argument: -s %.3f.

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

  • talairachxfm_subjid (a string) – Apply talairach xfm of subject to vertex xyz. Maps to a command-line argument: -t %s.

  • to_scanner (a boolean) – Convert coordinates from native FS (tkr) coords to scanner coords. Maps to a command-line argument: --to-scanner.

  • to_tkr (a boolean) – Convert coordinates from scanner coords to native FS (tkr) coords. Maps to a command-line argument: --to-tkr.

  • vertex (a boolean) – Writes out neighbors of a vertex in each row. Maps to a command-line argument: -v.

  • xyz_ascii (a boolean) – Print only surface xyz to ascii file. Maps to a command-line argument: -a.

Outputs:

converted (a pathlike object or string representing an existing file) – Converted output surface.

MRIsExpand

Link to code

Bases: FSSurfaceCommand

Wrapped executable: 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'
Mandatory Inputs:
  • distance (a float) – Distance in mm or fraction of cortical thickness. Maps to a command-line argument: %g (position: -2).

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

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

  • dt (a float) – Dt (implicit: 0.25). Maps to a command-line argument: -T %g.

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

  • nsurfaces (an integer) – Number of surfacces to write during expansion. Maps to a command-line argument: -N %d.

  • out_name (a string) – Output surface file. If no path, uses directory of in_file. If no path AND missing “lh.” or “rh.”, derive from in_file. Maps to a command-line argument: %s (position: -1). (Nipype default value: expanded)

  • pial (a 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. Maps to a command-line argument: -pial %s.

  • smooth_averages (an integer) – Smooth surface with N iterations after expansion. Maps to a command-line argument: -A %d.

  • sphere (a string) – WARNING: Do not change this trait. (Nipype default value: sphere)

  • spring (a float) – Spring term (implicit: 0.05). Maps to a command-line argument: -S %g.

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

  • thickness (a boolean) – Expand by fraction of cortical thickness, not mm. Maps to a command-line argument: -thickness.

  • thickness_name (a 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. Maps to a command-line argument: -thickness_name %s.

  • write_iterations (an integer) – Write snapshots of expansion every N iterations. Maps to a command-line argument: -W %d.

Outputs:

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

MRIsExpand.normalize_filenames()

Filename normalization routine to perform only when run in Node context. Find full paths for pial, thickness and sphere files for copying.

MRIsInflate

Link to code

Bases: FSCommand

Wrapped executable: 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'
Mandatory Inputs:

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

  • no_save_sulc (a boolean) – Do not save sulc file as output. Maps to a command-line argument: -no-save-sulc. Mutually exclusive with inputs: out_sulc.

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

  • out_sulc (a pathlike object or string representing a file) – Output sulc file. Mutually exclusive with inputs: no_save_sulc.

  • 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 file for MRIsInflate.

  • out_sulc (a pathlike object or string representing a file) – Output sulc file.

MakeAverageSubject

Link to code

Bases: FSCommand

Wrapped executable: 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'
Mandatory Inputs:

subjects_ids (a list of items which are a string) – Freesurfer subjects ids to average. Maps to a command-line argument: --subjects %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: {})

  • out_name (a pathlike object or string representing a file) – Name for the average subject. Maps to a command-line argument: --out %s. (Nipype default value: average)

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

Outputs:

average_subject_name (a string) – Output registration file.

MakeSurfaces

Link to code

Bases: FSCommand

Wrapped executable: 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'
Mandatory Inputs:
  • hemisphere (‘lh’ or ‘rh’) – Hemisphere being processed. Maps to a command-line argument: %s (position: -1).

  • in_filled (a pathlike object or string representing an existing file) – Implicit input file filled.mgz.

  • in_orig (a pathlike object or string representing an existing file) – Implicit input file <hemisphere>.orig. Maps to a command-line argument: -orig %s.

  • in_wm (a pathlike object or string representing an existing file) – Implicit input file wm.mgz.

  • subject_id (a string) – Subject being processed. Maps to a command-line argument: %s (position: -2). (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: {})

  • fix_mtl (a boolean) – Undocumented flag. Maps to a command-line argument: -fix_mtl.

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

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

  • in_label (a pathlike object or string representing an existing file) – Implicit input label/<hemisphere>.aparc.annot. Mutually exclusive with inputs: noaparc.

  • in_white (a pathlike object or string representing an existing file) – Implicit input that is sometimes used.

  • longitudinal (a boolean) – No documentation (used for longitudinal processing). Maps to a command-line argument: -long.

  • maximum (a float) – No documentation (used for longitudinal processing). Maps to a command-line argument: -max %.1f.

  • mgz (a boolean) – No documentation. Direct questions to analysis-bugs@nmr.mgh.harvard.edu. Maps to a command-line argument: -mgz.

  • no_white (a boolean) – Undocumented flag. Maps to a command-line argument: -nowhite.

  • noaparc (a boolean) – No documentation. Direct questions to analysis-bugs@nmr.mgh.harvard.edu. Maps to a command-line argument: -noaparc. Mutually exclusive with inputs: in_label.

  • orig_pial (a pathlike object or string representing an existing file) – Specify a pial surface to start with. Maps to a command-line argument: -orig_pial %s. Requires inputs: in_label.

  • orig_white (a pathlike object or string representing an existing file) – Specify a white surface to start with. Maps to a command-line argument: -orig_white %s.

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

  • white (a string) – White surface name. Maps to a command-line argument: -white %s.

  • white_only (a boolean) – Undocumented flag. Maps to a command-line argument: -whiteonly.

Outputs:
  • out_area (a pathlike object or string representing a file) – Output area file for MakeSurfaces.

  • out_cortex (a pathlike object or string representing a file) – Output cortex file for MakeSurfaces.

  • out_curv (a pathlike object or string representing a file) – Output curv file for MakeSurfaces.

  • out_pial (a pathlike object or string representing a file) – Output pial surface for MakeSurfaces.

  • out_thickness (a pathlike object or string representing a file) – Output thickness file for MakeSurfaces.

  • out_white (a pathlike object or string representing a file) – Output white matter hemisphere surface.

MakeSurfaces.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

ParcellationStats

Link to code

Bases: FSCommand

Wrapped executable: 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'
Mandatory Inputs:
  • aseg (a pathlike object or string representing an existing file) – Input file must be <subject_id>/mri/aseg.presurf.mgz.

  • brainmask (a pathlike object or string representing an existing file) – Input file must be <subject_id>/mri/brainmask.mgz.

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

  • lh_pial (a pathlike object or string representing an existing file) – Input file must be <subject_id>/surf/lh.pial.

  • lh_white (a pathlike object or string representing an existing file) – Input file must be <subject_id>/surf/lh.white.

  • rh_pial (a pathlike object or string representing an existing file) – Input file must be <subject_id>/surf/rh.pial.

  • rh_white (a pathlike object or string representing an existing file) – Input file must be <subject_id>/surf/rh.white.

  • ribbon (a pathlike object or string representing an existing file) – Input file must be <subject_id>/mri/ribbon.mgz.

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

  • thickness (a pathlike object or string representing an existing file) – Input file must be <subject_id>/surf/?h.thickness.

  • transform (a pathlike object or string representing an existing file) – Input file must be <subject_id>/mri/transforms/talairach.xfm.

  • wm (a pathlike object or string representing an existing file) – Input file must be <subject_id>/mri/wm.mgz.

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.

  • cortex_label (a pathlike object or string representing an existing file) – Implicit input file {hemi}.cortex.label.

  • 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_annotation (a pathlike object or string representing an existing file) – Compute properties for each label in the annotation file separately. Maps to a command-line argument: -a %s. Mutually exclusive with inputs: in_label.

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

  • in_label (a pathlike object or string representing an existing file) – Limit calculations to specified label. Maps to a command-line argument: -l %s. Mutually exclusive with inputs: in_annotatoin, out_color.

  • mgz (a boolean) – Look for mgz files. Maps to a command-line argument: -mgz.

  • out_color (a pathlike object or string representing a file) – Output annotation files’s colortable to text file. Maps to a command-line argument: -c %s. Mutually exclusive with inputs: in_label.

  • out_table (a pathlike object or string representing a file) – Table output to tablefile. Maps to a command-line argument: -f %s. Requires inputs: tabular_output.

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

  • surface (a string) – Input surface (e.g. ‘white’). Maps to a command-line argument: %s (position: -1).

  • tabular_output (a boolean) – Tabular output. Maps to a command-line argument: -b.

  • th3 (a boolean) – Turns on new vertex-wise volume calc for mris_anat_stats. Maps to a command-line argument: -th3. Requires inputs: cortex_label.

Outputs:
  • out_color (a pathlike object or string representing a file) – Output annotation files’s colortable to text file.

  • out_table (a pathlike object or string representing a file) – Table output to tablefile.

ParcellationStats.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

RelabelHypointensities

Link to code

Bases: FSCommand

Wrapped executable: 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'
Mandatory Inputs:
  • aseg (a pathlike object or string representing an existing file) – Input aseg file. Maps to a command-line argument: %s (position: -3).

  • lh_white (a pathlike object or string representing an existing file) – Implicit input file must be lh.white.

  • rh_white (a pathlike object or string representing an existing file) – Implicit input file must be rh.white.

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

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

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

  • surf_directory (a pathlike object or string representing an existing directory) – Directory containing lh.white and rh.white. Maps to a command-line argument: %s (position: -2). (Nipype default value: .)

Outputs:

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

RemoveIntersection

Link to code

Bases: FSCommand

Wrapped executable: 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'
Mandatory Inputs:

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

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

  • 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 file for RemoveIntersection.

RemoveNeck

Link to code

Bases: FSCommand

Wrapped executable: 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'
Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Input file for RemoveNeck. Maps to a command-line argument: %s (position: -4).

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

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

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

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

  • radius (an integer) – Radius. Maps to a command-line argument: -radius %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 file with neck removed.

SampleToSurface

Link to code

Bases: FSCommand

Wrapped executable: 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() 
Mandatory Inputs:
  • hemi (‘lh’ or ‘rh’) – Target hemisphere. Maps to a command-line argument: --hemi %s.

  • mni152reg (a boolean) – Source volume is in MNI152 space. Maps to a command-line argument: --mni152reg. Mutually exclusive with inputs: reg_file, reg_header, mni152reg.

  • projection_stem (a string) – Stem for precomputed linear estimates and volume fractions. Mutually exclusive with inputs: sampling_method.

  • reg_file (a pathlike object or string representing an existing file) – Source-to-reference registration file. Maps to a command-line argument: --reg %s. Mutually exclusive with inputs: reg_file, reg_header, mni152reg.

  • reg_header (a boolean) – Register based on header geometry. Maps to a command-line argument: --regheader %s. Mutually exclusive with inputs: reg_file, reg_header, mni152reg. Requires inputs: subject_id.

  • sampling_method (‘point’ or ‘max’ or ‘average’) – How to sample – at a point or at the max or average over a range. Maps to a command-line argument: %s. Mutually exclusive with inputs: projection_stem. Requires inputs: sampling_range, sampling_units.

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

Optional Inputs:
  • apply_rot (a tuple of the form: (a float, a float, a float)) – Rotation angles (in degrees) to apply to reg matrix. Maps to a command-line 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. Maps to a command-line argument: --trans %.3f %.3f %.3f.

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

  • cortex_mask (a boolean) – Mask the target surface with hemi.cortex.label. Maps to a command-line argument: --cortex. Mutually exclusive with inputs: mask_label.

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

  • fix_tk_reg (a boolean) – Make reg matrix round-compatible. Maps to a command-line argument: --fixtkreg.

  • float2int_method (‘round’ or ‘tkregister’) – Method to convert reg matrix values (default is round). Maps to a command-line argument: --float2int %s.

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

  • hits_file (a boolean or a pathlike object or string representing an existing file) – Save image with number of hits at each voxel. Maps to a command-line 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. Maps to a command-line argument: --srchit_type.

  • ico_order (an integer) – Icosahedron order when target_subject is ‘ico’. Maps to a command-line argument: --icoorder %d. Requires inputs: target_subject.

  • interp_method (‘nearest’ or ‘trilinear’) – Interpolation method. Maps to a command-line argument: --interp %s.

  • mask_label (a pathlike object or string representing an existing file) – Label file to mask output with. Maps to a command-line argument: --mask %s. Mutually exclusive with inputs: cortex_mask.

  • no_reshape (a boolean) – Do not reshape surface vector (default). Maps to a command-line argument: --noreshape. Mutually exclusive with inputs: reshape.

  • out_file (a pathlike object or string representing a file) – Surface file to write. Maps to a command-line 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. Maps to a command-line argument: --out_type %s.

  • override_reg_subj (a boolean) – Override the subject in the reg file header. Maps to a command-line argument: --srcsubject %s. Requires inputs: subject_id.

  • reference_file (a pathlike object or string representing an existing file) – Reference volume (default is orig.mgz). Maps to a command-line argument: --ref %s.

  • reshape (a boolean) – Reshape surface vector to fit in non-mgh format. Maps to a command-line argument: --reshape. Mutually exclusive with inputs: no_reshape.

  • reshape_slices (an integer) – Number of ‘slices’ for reshaping. Maps to a command-line argument: --rf %d.

  • 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’.

  • scale_input (a float) – Multiple all intensities by scale factor. Maps to a command-line argument: --scale %.3f.

  • smooth_surf (a float) – Smooth output surface (mm fwhm). Maps to a command-line argument: --surf-fwhm %.3f.

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

  • subject_id (a string) – Subject id.

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

  • surf_reg (a boolean or a string) – Use surface registration to target subject. Maps to a command-line argument: --surfreg %s. Requires inputs: target_subject.

  • surface (a string) – Target surface (default is white). Maps to a command-line argument: --surf %s.

  • target_subject (a string) – Sample to surface of different subject than source. Maps to a command-line argument: --trgsubject %s.

  • vox_file (a boolean or a pathlike object or string representing a file) – Text file with the number of voxels intersecting the surface. Maps to a command-line argument: --nvox %s.

Outputs:
  • hits_file (a pathlike object or string representing an existing file) – Image with number of hits at each voxel.

  • out_file (a pathlike object or string representing an existing file) – Surface file.

  • vox_file (a pathlike object or string representing an existing file) – Text file with the number of voxels intersecting the surface.

SmoothTessellation

Link to code

Bases: FSCommand

Wrapped executable: mris_smooth.

Smooth a tessellated surface.

See also

nipype.interfaces.freesurfer.utils.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() 
Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – Input volume to tessellate voxels from. 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.

  • curvature_averaging_iterations (an integer) – Number of curvature averaging iterations (default=10). Maps to a command-line argument: -a %d.

  • disable_estimates (a boolean) – Disables the writing of curvature and area estimates. Maps to a command-line argument: -nw.

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

  • gaussian_curvature_norm_steps (an integer) – Use Gaussian curvature smoothing. Maps to a command-line argument: %d.

  • gaussian_curvature_smoothing_steps (an integer) – Use Gaussian curvature smoothing. Maps to a command-line argument: %d.

  • normalize_area (a boolean) – Normalizes the area after smoothing. Maps to a command-line argument: -area.

  • out_area_file (a pathlike object or string representing a file) – Write area to ?h.areaname (default “area”). Maps to a command-line argument: -b %s.

  • out_curvature_file (a pathlike object or string representing a file) – Write curvature to ?h.curvname (default “curv”). Maps to a command-line argument: -c %s.

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

  • seed (an integer) – Seed for setting random number generator. Maps to a command-line argument: -seed %d.

  • smoothing_iterations (an integer) – Number of smoothing iterations (default=10). Maps to a command-line argument: -n %d.

  • snapshot_writing_iterations (an integer) – Write snapshot every n iterations. Maps to a command-line argument: -w %d.

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

  • use_gaussian_curvature_smoothing (a boolean) – Use Gaussian curvature smoothing. Maps to a command-line argument: -g.

  • use_momentum (a boolean) – Uses momentum. Maps to a command-line argument: -m.

Outputs:

surface (a pathlike object or string representing an existing file) – Smoothed surface file.

Sphere

Link to code

Bases: FSCommandOpenMP

Wrapped executable: 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'
Mandatory Inputs:

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

  • in_smoothwm (a pathlike object or string representing an existing file) – Input surface required when -q flag is not selected.

  • magic (a boolean) – No documentation. Direct questions to analysis-bugs@nmr.mgh.harvard.edu. Maps to a command-line argument: -q.

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

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

  • seed (an integer) – Seed for setting random number generator. 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 file for Sphere.

Surface2VolTransform

Link to code

Bases: FSCommand

Wrapped executable: 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()
Mandatory Inputs:
  • hemi (a string) – Hemisphere of data. Maps to a command-line argument: --hemi %s.

  • reg_file (a pathlike object or string representing an existing file) – TkRAS-to-tkRAS matrix (tkregister2 format). Maps to a command-line argument: --volreg %s. Mutually exclusive with inputs: subject_id.

  • source_file (a pathlike object or string representing an existing file) – This is the source of the surface values. Maps to a command-line argument: --surfval %s. Mutually exclusive with inputs: mkmask.

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

  • mkmask (a boolean) – Make a mask instead of loading surface values. Maps to a command-line argument: --mkmask. Mutually exclusive with inputs: source_file.

  • projfrac (a float) – Thickness fraction. Maps to a command-line argument: --projfrac %s.

  • subject_id (a string) – Subject id. Maps to a command-line argument: --identity %s. Mutually exclusive with inputs: reg_file.

  • subjects_dir (a string) – Freesurfer subjects directory defaults to $SUBJECTS_DIR. Maps to a command-line argument: --sd %s.

  • surf_name (a string) – Surfname (default is white). Maps to a command-line argument: --surf %s.

  • template_file (a pathlike object or string representing an existing file) – Output template volume. Maps to a command-line argument: --template %s.

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

  • vertexvol_file (a pathlike object or string representing a file) – 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. Maps to a command-line argument: --vtxvol %s.

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

  • vertexvol_file (a pathlike object or string representing a file) – Vertex map volume path id. Optional.

SurfaceSmooth

Link to code

Bases: FSCommand

Wrapped executable: mri_surf2surf.

Smooth a surface image with mri_surf2surf.

The surface is smoothed by an iterative 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

nipype.interfaces.freesurfer.utils.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() 
Mandatory Inputs:
  • hemi (‘lh’ or ‘rh’) – Hemisphere to operate on. Maps to a command-line argument: --hemi %s.

  • in_file (a pathlike object or string representing a file) – Source surface file. Maps to a command-line argument: --sval %s.

  • subject_id (a string) – Subject id of surface file. 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.

  • cortex (a boolean) – Only smooth within $hemi.cortex.label. Maps to a command-line argument: --cortex. (Nipype default value: True)

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

  • fwhm (a float) – Effective FWHM of the smoothing process. Maps to a command-line argument: --fwhm %.4f. Mutually exclusive with inputs: smooth_iters.

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

  • reshape (a boolean) – Reshape surface vector to fit in non-mgh format. Maps to a command-line argument: --reshape.

  • smooth_iters (an integer) – Iterations of the smoothing process. Maps to a command-line argument: --smooth %d. Mutually exclusive with inputs: fwhm.

  • 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) – Smoothed surface file.

SurfaceSnapshots

Link to code

Bases: FSCommand

Wrapped executable: 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() 
Mandatory Inputs:
  • hemi (‘lh’ or ‘rh’) – Hemisphere to visualize. Maps to a command-line argument: %s (position: 2).

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

  • surface (a string) – Surface to visualize. Maps to a command-line argument: %s (position: 3).

Optional Inputs:
  • annot_file (a pathlike object or string representing an existing file) – Path to annotation file to display. Maps to a command-line argument: -annotation %s. Mutually exclusive with inputs: annot_name.

  • annot_name (a string) – Name of annotation to display (must be in $subject/label directory. Maps to a command-line argument: -annotation %s. Mutually exclusive with inputs: annot_file.

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

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

  • demean_overlay (a boolean) – Remove mean from overlay. Maps to a command-line argument: -zm.

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

  • identity_reg (a boolean) – Use the identity matrix to register the overlay to the surface. Maps to a command-line argument: -overlay-reg-identity. Mutually exclusive with inputs: overlay_reg, identity_reg, mni152_reg.

  • invert_overlay (a boolean) – Invert the overlay display. Maps to a command-line argument: -invphaseflag 1.

  • label_file (a pathlike object or string representing an existing file) – Path to label file to display. Maps to a command-line argument: -label %s. Mutually exclusive with inputs: label_name.

  • label_name (a string) – Name of label to display (must be in $subject/label directory. Maps to a command-line argument: -label %s. Mutually exclusive with inputs: label_file.

  • label_outline (a boolean) – Draw label/annotation as outline. Maps to a command-line argument: -label-outline.

  • label_under (a boolean) – Draw label/annotation under overlay. Maps to a command-line argument: -labels-under.

  • mni152_reg (a boolean) – Use to display a volume in MNI152 space on the average subject. Maps to a command-line argument: -mni152reg. Mutually exclusive with inputs: overlay_reg, identity_reg, mni152_reg.

  • orig_suffix (a string) – Set the orig surface suffix string. Maps to a command-line argument: -orig %s.

  • overlay (a pathlike object or string representing an existing file) – Load an overlay volume/surface. Maps to a command-line argument: -overlay %s. Requires inputs: overlay_range.

  • 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). Maps to a command-line argument: %s.

  • overlay_range_offset (a float) – Overlay range will be symmetric around offset value. Maps to a command-line argument: -foffset %.3f.

  • overlay_reg (a pathlike object or string representing an existing file) – Registration matrix file to register overlay to surface. Maps to a command-line argument: -overlay-reg %s. Mutually exclusive with inputs: overlay_reg, identity_reg, mni152_reg.

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

  • reverse_overlay (a boolean) – Reverse the overlay display. Maps to a command-line argument: -revphaseflag 1.

  • screenshot_stem (a string) – Stem to use for screenshot file names.

  • show_color_scale (a boolean) – Display the color scale bar. Maps to a command-line argument: -colscalebarflag 1.

  • show_color_text (a boolean) – Display text in the color scale bar. Maps to a command-line argument: -colscaletext 1.

  • show_curv (a boolean) – Show curvature. Maps to a command-line argument: -curv. Mutually exclusive with inputs: show_gray_curv.

  • show_gray_curv (a boolean) – Show curvature in gray. Maps to a command-line argument: -gray. Mutually exclusive with inputs: show_curv.

  • six_images (a boolean) – Also take anterior and posterior snapshots.

  • sphere_suffix (a string) – Set the sphere.reg suffix string. Maps to a command-line argument: -sphere %s.

  • stem_template_args (a list of items which are a string) – Input names to use as arguments for a string-formated stem template. Requires inputs: screenshot_stem.

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

  • tcl_script (a pathlike object or string representing an existing file) – Override default screenshot script. Maps to a command-line argument: %s.

  • truncate_overlay (a boolean) – Truncate the overlay display. Maps to a command-line argument: -truncphaseflag 1.

Outputs:

snapshots (a list of items which are a pathlike object or string representing an existing file) – Tiff images of the surface from different perspectives.

SurfaceTransform

Link to code

Bases: FSCommand

Wrapped executable: 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() 
Mandatory Inputs:
  • hemi (‘lh’ or ‘rh’) – Hemisphere to transform. Maps to a command-line argument: --hemi %s.

  • source_annot_file (a pathlike object or string representing an existing file) – Surface annotation file. Maps to a command-line argument: --sval-annot %s. Mutually exclusive with inputs: source_file.

  • source_file (a pathlike object or string representing an existing file) – Surface file with source values. Maps to a command-line argument: --sval %s. Mutually exclusive with inputs: source_annot_file.

  • source_subject (a string) – Subject id for source surface. Maps to a command-line argument: --srcsubject %s.

  • target_subject (a string) – Subject id of target surface. Maps to a command-line argument: --trgsubject %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: {})

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

  • reshape (a boolean) – Reshape output surface to conform with Nifti. Maps to a command-line argument: --reshape.

  • reshape_factor (an integer) – Number of slices in reshaped image. Maps to a command-line argument: --reshape-factor.

  • 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. Maps to a command-line argument: --sfmt %s. Requires inputs: source_file.

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

  • 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’. Maps to a command-line argument: --trgicoorder %d.

  • 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. Maps to a command-line argument: --tfmt %s.

Outputs:

out_file (a pathlike object or string representing an existing file) – Transformed surface file.

TalairachAVI

Link to code

Bases: FSCommand

Wrapped executable: 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() 
Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Input volume. Maps to a command-line argument: --i %s.

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

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

  • atlas (a string) – Alternate target atlas (in freesurfer/average dir). Maps to a command-line argument: --atlas %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) – The output transform for TalairachAVI.

  • out_log (a pathlike object or string representing a file) – The output log file for TalairachAVI.

  • out_txt (a pathlike object or string representing a file) – The output text file for TaliarachAVI.

TalairachQC

Link to code

Bases: FSScriptCommand

Wrapped executable: 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'
Mandatory Inputs:

log_file (a pathlike object or string representing an existing file) – The log file for TalairachQC. Maps to a command-line argument: %s (position: 0).

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:

log_file (a pathlike object or string representing an existing file) – The output log. (Nipype default value: output.nipype)

Tkregister2

Link to code

Bases: FSCommand

Wrapped executable: 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() 
Mandatory Inputs:
  • moving_image (a pathlike object or string representing an existing file) – Moving volume. Maps to a command-line argument: --mov %s.

  • reg_file (a pathlike object or string representing a file) – Freesurfer-style registration file. Maps to a command-line argument: --reg %s. (Nipype default value: register.dat)

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

  • fsl_in_matrix (a pathlike object or string representing an existing file) – Fsl-style registration input matrix. Maps to a command-line argument: --fsl %s.

  • fsl_out (a bool or None or a pathlike object or string representing a file) – Compute an FSL-compatible resgitration matrix. Maps to a command-line argument: --fslregout %s.

  • fstal (a boolean) – Set mov to be tal and reg to be tal xfm. Maps to a command-line argument: --fstal. Mutually exclusive with inputs: target_image, moving_image, reg_file.

  • fstarg (a boolean) – Use subject’s T1 as reference. Maps to a command-line argument: --fstarg. Mutually exclusive with inputs: target_image.

  • invert_lta_in (a boolean) – Invert input LTA before applying. Requires inputs: lta_in.

  • invert_lta_out (a boolean) – Invert input LTA before applying. Maps to a command-line argument: --ltaout-inv. Requires inputs: lta_in.

  • lta_in (a pathlike object or string representing an existing file) – Use a matrix in MNI coordinates as initial registration. Maps to a command-line argument: --lta %s.

  • lta_out (a bool or None or a pathlike object or string representing a file) – Output registration file (LTA format). Maps to a command-line argument: --ltaout %s.

  • movscale (a float) – Adjust registration matrix to scale mov. Maps to a command-line argument: --movscale %f.

  • noedit (a boolean) – Do not open edit window (exit). Maps to a command-line argument: --noedit. (Nipype default value: True)

  • reg_header (a boolean) – Compute registration from headers. Maps to a command-line argument: --regheader.

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

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

  • target_image (a pathlike object or string representing an existing file) – Target volume. Maps to a command-line argument: --targ %s. Mutually exclusive with inputs: fstarg.

  • xfm (a pathlike object or string representing an existing file) – Use a matrix in MNI coordinates as initial registration. Maps to a command-line argument: --xfm %s.

Outputs:
  • fsl_file (a pathlike object or string representing a file) – FSL-style registration file.

  • lta_file (a pathlike object or string representing a file) – LTA-style registration file.

  • reg_file (a pathlike object or string representing an existing file) – Freesurfer-style registration file.

VolumeMask

Link to code

Bases: FSCommand

Wrapped executable: 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'
Mandatory Inputs:
  • left_ribbonlabel (an integer) – Left cortical ribbon label. Maps to a command-line argument: --label_left_ribbon %d.

  • left_whitelabel (an integer) – Left white matter label. Maps to a command-line argument: --label_left_white %d.

  • lh_pial (a pathlike object or string representing an existing file) – Implicit input left pial surface.

  • lh_white (a pathlike object or string representing an existing file) – Implicit input left white matter surface.

  • rh_pial (a pathlike object or string representing an existing file) – Implicit input right pial surface.

  • rh_white (a pathlike object or string representing an existing file) – Implicit input right white matter surface.

  • right_ribbonlabel (an integer) – Right cortical ribbon label. Maps to a command-line argument: --label_right_ribbon %d.

  • right_whitelabel (an integer) – Right white matter label. Maps to a command-line argument: --label_right_white %d.

  • subject_id (a string) – Subject being processed. 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.

  • aseg (a pathlike object or string representing an existing file) – Implicit aseg.mgz segmentation. Specify a different aseg by using the ‘in_aseg’ input. Mutually exclusive with inputs: in_aseg.

  • copy_inputs (a boolean) – If running as a node, set this to True.This will copy the implicit 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: {})

  • in_aseg (a pathlike object or string representing an existing file) – Input aseg file for VolumeMask. Maps to a command-line argument: --aseg_name %s. Mutually exclusive with inputs: aseg.

  • save_ribbon (a boolean) – Option to save just the ribbon for the hemispheres in the format ?h.ribbon.mgz. Maps to a command-line argument: --save_ribbon.

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

Outputs:
  • lh_ribbon (a pathlike object or string representing a file) – Output left cortical ribbon mask.

  • out_ribbon (a pathlike object or string representing a file) – Output cortical ribbon mask.

  • rh_ribbon (a pathlike object or string representing a file) – Output right cortical ribbon mask.

VolumeMask.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

nipype.interfaces.freesurfer.utils.copy2subjdir(cls, in_file, folder=None, basename=None, subject_id=None)

Method to copy an input to the subjects directory

nipype.interfaces.freesurfer.utils.createoutputdirs(outputs)

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