qsiprep.interfaces.freesurfer module

FreeSurfer tools interfaces

Fetch some example data:

>>> import os
>>> from niworkflows import data
>>> data_root = data.get_bids_examples(variant='BIDS-examples-1-enh-ds054')
>>> os.chdir(data_root)

Disable warnings:

>>> from nipype import logging
>>> logging.getLogger('nipype.interface').setLevel('ERROR')
class qsiprep.interfaces.freesurfer.FixHeaderSynthStrip(**inputs)[source]

Bases: SynthStrip

Wrapped executable: mri_synthstrip.

Mandatory Inputs:

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

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

  • border (an integer) – Mask border threshold in mm. Default is 1. Maps to a command-line argument: -b %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: {})

  • gpu (a boolean) – Maps to a command-line argument: -g.

  • no_csf (a boolean) – Exclude CSF from brain border. Maps to a command-line argument: --no-csf.

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

  • out_brain (a pathlike object or string representing a file) – Skull stripped image with corrupt sform. Maps to a command-line argument: -o %s.

  • out_brain_mask (a pathlike object or string representing a file) – Mask image with corrupt sform. Maps to a command-line argument: -m %s.

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

Outputs:
  • out_brain (a pathlike object or string representing an existing file)

  • out_brain_mask (a pathlike object or string representing an existing file)

class qsiprep.interfaces.freesurfer.MockSynthSeg(from_file=None, resource_monitor=None, **inputs)[source]

Bases: SimpleInterface

A fake version of synthseg for testing.

Mandatory Inputs:

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

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

  • cpu (a boolean) – Enforce running with CPU rather than GPU. Maps to a command-line argument: --cpu. (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: {})

  • fast (a boolean) – Fast predictions (lower quality). Maps to a command-line argument: --fast.

  • num_threads (an integer) – Number of threads to use. Maps to a command-line argument: --threads %d. (Nipype default value: 0)

  • out_post (a pathlike object or string representing a file) – Posteriors image. Maps to a command-line argument: --post %s.

  • out_qc (a pathlike object or string representing a file) – Qc csv. Maps to a command-line argument: --qc %s.

  • out_seg (a pathlike object or string representing a file) – Segmentation image. Maps to a command-line argument: --o %s.

  • robust (a boolean) – Use robust predictions (slower). Maps to a command-line argument: --robust.

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

Outputs:
  • out_post (a pathlike object or string representing an existing file)

  • out_qc (a pathlike object or string representing an existing file)

  • out_seg (a pathlike object or string representing an existing file)

class qsiprep.interfaces.freesurfer.MockSynthStrip(from_file=None, resource_monitor=None, **inputs)[source]

Bases: SimpleInterface

Mandatory Inputs:

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

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

  • border (an integer) – Mask border threshold in mm. Default is 1. Maps to a command-line argument: -b %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: {})

  • gpu (a boolean) – Maps to a command-line argument: -g.

  • no_csf (a boolean) – Exclude CSF from brain border. Maps to a command-line argument: --no-csf.

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

  • out_brain (a pathlike object or string representing a file) – Skull stripped image with corrupt sform. Maps to a command-line argument: -o %s.

  • out_brain_mask (a pathlike object or string representing a file) – Mask image with corrupt sform. Maps to a command-line argument: -m %s.

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

Outputs:
  • out_brain (a pathlike object or string representing an existing file)

  • out_brain_mask (a pathlike object or string representing an existing file)

class qsiprep.interfaces.freesurfer.PrepareSynthStripGrid(from_file=None, resource_monitor=None, **inputs)[source]

Bases: SimpleInterface

Mandatory Inputs:

input_image (a pathlike object or string representing an existing file)

Outputs:

prepared_image (a pathlike object or string representing an existing file)

class qsiprep.interfaces.freesurfer.StructuralReference(**inputs)[source]

Bases: RobustTemplate

Wrapped executable: mri_robust_template.

Variation on RobustTemplate that simply copies the source if a single volume is provided.

>>> from qsiprep.utils.bids import collect_data
>>> t1w = collect_data('ds114', '01')[0]['t1w']
>>> template = StructuralReference()
>>> template.inputs.in_files = t1w
>>> template.inputs.auto_detect_sensitivity = True
>>> template.cmdline  
'mri_robust_template --satit --mov .../sub-01_ses-retest_T1w.nii.gz
    .../sub-01_ses-test_T1w.nii.gz --template mri_robust_template_out.mgz'
Mandatory Inputs:
  • auto_detect_sensitivity (a boolean) – Auto-detect good sensitivity (recommended for head or full brain scans). Maps to a command-line argument: --satit. Mutually exclusive with inputs: outlier_sensitivity.

  • in_files (a list of items which are a pathlike object or string representing an existing file) – Input movable volumes to be aligned to common mean/median template. Maps to a command-line argument: --mov %s.

  • out_file (a pathlike object or string representing a file) – Output template volume (final mean/median image). Maps to a command-line argument: --template %s. (Nipype default value: mri_robust_template_out.mgz)

  • outlier_sensitivity (a float) – Set outlier sensitivity manually (e.g. “–sat 4.685” ). Higher values mean less sensitivity. Maps to a command-line argument: --sat %.4f. Mutually exclusive with inputs: auto_detect_sensitivity.

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

  • average_metric (‘median’ or ‘mean’) – Construct template from: 0 Mean, 1 Median (default). Maps to a command-line argument: --average %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: {})

  • fixed_timepoint (a boolean) – Map everything to init TP# (init TP is not resampled). Maps to a command-line argument: --fixtp.

  • in_intensity_scales (a list of items which are a pathlike object or string representing an existing file) – Use initial intensity scales. Maps to a command-line argument: --iscalein %s.

  • initial_timepoint (an integer) – Use TP# for special init (default random), 0: no init. Maps to a command-line argument: --inittp %d.

  • initial_transforms (a list of items which are a pathlike object or string representing an existing file) – Use initial transforms (lta) on source. Maps to a command-line argument: --ixforms %s.

  • intensity_scaling (a boolean) – Allow also intensity scaling (default off). Maps to a command-line argument: --iscale.

  • no_iteration (a boolean) – Do not iterate, just create first template. Maps to a command-line argument: --noit.

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

  • scaled_intensity_outputs (a list of items which are a pathlike object or string representing a file or a boolean) – Final intensity scales (will activate –iscale). Maps to a command-line argument: --iscaleout %s.

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

  • subsample_threshold (an integer) – Subsample if dim > # on all axes (default no subs.). Maps to a command-line argument: --subsample %d.

  • transform_outputs (a list of items which are a pathlike object or string representing a file or a boolean) – Output xforms to template (for each input). Maps to a command-line argument: --lta %s.

Outputs:
  • out_file (a pathlike object or string representing an existing file) – Output template volume (final mean/median image).

  • scaled_intensity_outputs (a list of items which are a pathlike object or string representing an existing file) – Output final intensity scales.

  • transform_outputs (a list of items which are a pathlike object or string representing an existing file) – Output xform files from moving to template.

property cmdline

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

class qsiprep.interfaces.freesurfer.SynthSeg(**inputs)[source]

Bases: FSCommandOpenMP

Wrapped executable: mri_synthseg.

Mandatory Inputs:

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

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

  • cpu (a boolean) – Enforce running with CPU rather than GPU. Maps to a command-line argument: --cpu. (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: {})

  • fast (a boolean) – Fast predictions (lower quality). Maps to a command-line argument: --fast.

  • num_threads (an integer) – Number of threads to use. Maps to a command-line argument: --threads %d. (Nipype default value: 0)

  • out_post (a pathlike object or string representing a file) – Posteriors image. Maps to a command-line argument: --post %s.

  • out_qc (a pathlike object or string representing a file) – Qc csv. Maps to a command-line argument: --qc %s.

  • out_seg (a pathlike object or string representing a file) – Segmentation image. Maps to a command-line argument: --o %s.

  • robust (a boolean) – Use robust predictions (slower). Maps to a command-line argument: --robust.

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

Outputs:
  • out_post (a pathlike object or string representing an existing file)

  • out_qc (a pathlike object or string representing an existing file)

  • out_seg (a pathlike object or string representing an existing file)

class qsiprep.interfaces.freesurfer.SynthStrip(**inputs)[source]

Bases: FSCommandOpenMP

Wrapped executable: mri_synthstrip.

Mandatory Inputs:

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

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

  • border (an integer) – Mask border threshold in mm. Default is 1. Maps to a command-line argument: -b %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: {})

  • gpu (a boolean) – Maps to a command-line argument: -g.

  • no_csf (a boolean) – Exclude CSF from brain border. Maps to a command-line argument: --no-csf.

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

  • out_brain (a pathlike object or string representing a file) – Skull stripped image with corrupt sform. Maps to a command-line argument: -o %s.

  • out_brain_mask (a pathlike object or string representing a file) – Mask image with corrupt sform. Maps to a command-line argument: -m %s.

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

Outputs:
  • out_brain (a pathlike object or string representing an existing file)

  • out_brain_mask (a pathlike object or string representing an existing file)