Warning: This document is for an old version of smriprep. The main version is master.

smriprep.interfaces.freesurfer module

Nipype’s recon-all replacement.

class smriprep.interfaces.freesurfer.MRIsConvertData(**inputs)[source]

Bases: MRIsConvert

Wrapped executable: mris_convert.

Convert surface data files (label, curvature, functional, etc) Wraps mris_convert to automatically select the correct ?h.white surface if passed a file from the subject’s surf/ directory

Mandatory 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. Mutually exclusive with inputs: annot_file, parcstats_file, label_file, scalarcurv_file, functional_file.

  • 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. Mutually exclusive with inputs: annot_file, parcstats_file, label_file, scalarcurv_file, functional_file.

  • 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. Mutually exclusive with inputs: annot_file, parcstats_file, label_file, scalarcurv_file, functional_file.

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

  • 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. Mutually exclusive with inputs: annot_file, parcstats_file, label_file, scalarcurv_file, functional_file.

  • 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. Mutually exclusive with inputs: annot_file, parcstats_file, label_file, scalarcurv_file, functional_file.

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

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

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

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

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

class smriprep.interfaces.freesurfer.MakeMidthickness(**inputs)[source]

Bases: MakeMidthickness, FSCommandOpenMP

Wrapped executable: mris_expand.

Patched MakeMidthickness interface

Ensures output filenames are specified with hemisphere labels, when appropriate. This may not cover all use-cases in MRIsExpand, but we’re just making midthickness files.

This interface also sets the OMP_NUM_THREADS environment variable to floor(1.5x) the number of threads requested by the user, as tests indicate that cores are underutilized by a factor of 2/3.

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

Explicit hemisphere labels should still be respected:

>>> mris_expand.inputs.out_name = 'rh.graymid'
>>> mris_expand.cmdline
'mris_expand -thickness lh.white 0.5 rh.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: {})

  • graymid (a list of items which are any value) – Existing graymid/midthickness file.

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

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

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

class smriprep.interfaces.freesurfer.ReconAll(command=None, terminal_output=None, write_cmdline=False, **inputs)[source]

Bases: ReconAll

Wrapped executable: recon-all.

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

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

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

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

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

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

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

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

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

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  • steps (a list of items which are ‘motioncor’ or ‘talairach’ or ‘nuintensitycor’ or ‘normalization’ or ‘skullstrip’ or ‘gcareg’ or ‘canorm’ or ‘careg’ or ‘careginv’ or ‘rmneck’ or ‘skull-lta’ or ‘calabel’ or ‘normalization2’ or ‘maskbfs’ or ‘segmentation’ or ‘tessellate’ or ‘smooth1’ or ‘inflate1’ or ‘qsphere’ or ‘fix’ or ‘white’ or ‘smooth2’ or ‘inflate2’ or ‘curvHK’ or ‘curvstats’ or ‘sphere’ or ‘surfreg’ or ‘jacobian_white’ or ‘avgcurv’ or ‘cortparc’ or ‘pial’ or ‘pctsurfcon’ or ‘parcstats’ or ‘cortparc2’ or ‘parcstats2’ or ‘cortparc3’ or ‘parcstats3’ or ‘label-exvivo-ec’ or ‘cortribbon’ or ‘hyporelabel’ or ‘segstats’ or ‘aparc2aseg’ or ‘apas2aseg’ or ‘wmparc’ or ‘balabels’) – Specific process directives. Mutually exclusive with inputs: directive.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

property cmdline

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