qsiprep.interfaces package

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

Bases: SummaryInterface

Optional Inputs:
  • command (a string) – Qsiprep command.

  • version (a string) – Qsiprep version.

Outputs:

out_report (a pathlike object or string representing an existing file) – HTML segment containing summary.

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

Bases: SimpleInterface

Add a header row to a TSV file

>>> import os
>>> import pandas as pd
>>> import numpy as np
>>> from tempfile import TemporaryDirectory
>>> tmpdir = TemporaryDirectory()
>>> os.chdir(tmpdir.name)

An example TSV:

>>> np.savetxt('data.tsv', np.arange(30).reshape((6, 5)), delimiter='       ')

Add headers:

>>> from qsiprep.interfaces import AddTSVHeader
>>> addheader = AddTSVHeader()
>>> addheader.inputs.in_file = 'data.tsv'
>>> addheader.inputs.columns = ['a', 'b', 'c', 'd', 'e']
>>> res = addheader.run()
>>> pd.read_csv(res.outputs.out_file, sep='\s+', index_col=None,
...             engine='python')  
      a     b     c     d     e
0   0.0   1.0   2.0   3.0   4.0
1   5.0   6.0   7.0   8.0   9.0
2  10.0  11.0  12.0  13.0  14.0
3  15.0  16.0  17.0  18.0  19.0
4  20.0  21.0  22.0  23.0  24.0
5  25.0  26.0  27.0  28.0  29.0
>>> tmpdir.cleanup()
Mandatory Inputs:
  • columns (a list of items which are a string) – Header for columns.

  • in_file (a pathlike object or string representing an existing file) – Input file.

Outputs:

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

class qsiprep.interfaces.BIDSDataGrabber(*args, **kwargs)[source]

Bases: SimpleInterface

Collect files from a BIDS directory structure

>>> from qsiprep.interfaces import BIDSDataGrabber
>>> from qsiprep.utils.bids import collect_data
>>> bids_src = BIDSDataGrabber(anat_only=False)
>>> bids_src.inputs.subject_data = collect_data('ds114', '01')[0]
>>> bids_src.inputs.subject_id = 'ds114'
>>> res = bids_src.run()
>>> res.outputs.t1w  
['.../ds114/sub-01/ses-retest/anat/sub-01_ses-retest_T1w.nii.gz',
 '.../ds114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz']
Optional Inputs:
  • subject_data (a dictionary with keys which are a string and with values which are any value)

  • subject_id (a string)

Outputs:
  • dwi (a list of items which are any value) – Output DWI images.

  • fmap (a list of items which are any value) – Output fieldmaps.

  • out_dict (a dictionary with keys which are any value and with values which are any value) – Output data structure.

  • roi (a list of items which are any value) – Output ROI images.

  • t1w (a list of items which are any value) – Output T1w images.

  • t2w (a list of items which are any value) – Output T2w images.

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

Bases: SimpleInterface

Extract metadata from a BIDS-conforming filename

This interface uses only the basename, not the path, to determine the subject, session, task, run, acquisition or reconstruction.

Mandatory Inputs:

in_file (a pathlike object or string representing a file) – Input file, part of a BIDS tree.

Outputs:
  • acq_id (a string)

  • rec_id (a string)

  • run_id (a string)

  • session_id (a string)

  • subject_id (a string)

  • task_id (a string)

class qsiprep.interfaces.ConcatAffines(num_affines=0, *args, **kwargs)[source]

Bases: SimpleInterface

Optional Inputs:

invert (a boolean) – Invert output transform. (Nipype default value: False)

Outputs:

out_mat (a pathlike object or string representing an existing file) – Output transform.

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

Bases: SimpleInterface

Conform a series of T1w images to enable merging.

Performs two basic functions:

  1. Orient to LPS (right-left, anterior-posterior, inferior-superior)

  2. Resample to target zooms (voxel sizes) and shape (number of voxels)

Mandatory Inputs:

in_file (a pathlike object or string representing a file) – Input image.

Optional Inputs:
  • deoblique_header (a boolean)

  • target_shape (a tuple of the form: (an integer, an integer, an integer)) – Target shape information.

  • target_zooms (a tuple of the form: (a float, a float, a float)) – Target zoom information.

Outputs:
  • out_file (a pathlike object or string representing an existing file) – Conformed image.

  • transform (a pathlike object or string representing an existing file) – Conformation transform.

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

Bases: SimpleInterface

Conform a series of dwi images to enable merging. Performs three basic functions: #. Orient image to requested orientation #. Validate the qform and sform, set qform code to 1 #. Flip bvecs accordingly #. Do nothing to the bvals Note: This is not as nuanced as fmriprep’s version

Mandatory Inputs:

dwi_file (a pathlike object or string representing a file) – Dwi image.

Optional Inputs:
  • bval_file (a pathlike object or string representing an existing file)

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

  • orientation (‘LPS’ or ‘LAS’) – (Nipype default value: LPS)

Outputs:
  • bval_file (a pathlike object or string representing an existing file) – Conformed bval file.

  • bvec_file (a pathlike object or string representing an existing file) – Conformed bvec file.

  • dwi_file (a pathlike object or string representing an existing file) – Conformed dwi image.

  • out_report (a pathlike object or string representing an existing file) – HTML segment containing warning.

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

Bases: SimpleInterface

Optional Inputs:
  • bval_files (a list of items which are a pathlike object or string representing an existing file) – Bvals files.

  • confounds_file (a pathlike object or string representing an existing file) – BIDS’ _desc-confounds_timeseries.tsv file.

  • confounds_list (a list of at least 1 items which are a string or a tuple of the form: (a string, a string or None) or a tuple of the form: (a string, a string or None, a string or None)) – List of headers to extract from the confounds_file.

  • orig_bvecs (a list of items which are a pathlike object or string representing an existing file) – Original bvecs file.

  • sliceqc_file (a pathlike object or string representing an existing file) – Output from SliceQC.

  • sliceqc_mask (a pathlike object or string representing an existing file) – Mask.

  • str_or_tuple (a string or a tuple of the form: (a string, a string or None) or a tuple of the form: (a string, a string or None, a string or None))

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

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

class qsiprep.interfaces.DerivativesDataSink(allowed_entities=None, out_path_base=None, **inputs)[source]

Bases: DerivativesDataSink

Store derivative files.

A child class of the niworkflows DerivativesDataSink, using xcp_d’s configuration files.

Mandatory Inputs:
  • in_file (a list of items which are a pathlike object or string representing an existing file) – The object to be saved.

  • source_file (a list of items which are a pathlike object or string representing a file) – The source file(s) to extract entities from.

Optional Inputs:
  • base_directory (a string or os.PathLike object) – Path to the base directory for storing data.

  • check_hdr (a boolean) – Fix headers of NIfTI outputs. (Nipype default value: True)

  • compress (a list of items which are a boolean or None) – Whether in_file should be compressed (True), uncompressed (False) or left unmodified (None, default). (Nipype default value: [])

  • data_dtype (a string) – NumPy datatype to coerce NIfTI data to, or source tomatch the input file dtype.

  • dismiss_entities (a list of items which are a string or None) – A list entities that will not be propagated from the source file. (Nipype default value: [])

  • meta_dict (a dictionary with keys which are a value of class ‘str’ and with values which are any value) – An input dictionary containing metadata.

Outputs:
  • compression (a list of items which are a boolean or None) – Whether in_file should be compressed (True), uncompressed (False) or left unmodified (None).

  • fixed_hdr (a list of items which are a boolean) – Whether derivative header was fixed.

  • out_file (a list of items which are a pathlike object or string representing an existing file)

  • out_meta (a list of items which are a pathlike object or string representing an existing file)

out_path_base = ''
class qsiprep.interfaces.DerivativesMaybeDataSink(allowed_entities=None, out_path_base=None, **inputs)[source]

Bases: DerivativesDataSink

Mandatory Inputs:

source_file (a list of items which are a pathlike object or string representing a file) – The source file(s) to extract entities from.

Optional Inputs:
  • base_directory (a string or os.PathLike object) – Path to the base directory for storing data.

  • check_hdr (a boolean) – Fix headers of NIfTI outputs. (Nipype default value: True)

  • compress (a list of items which are a boolean or None) – Whether in_file should be compressed (True), uncompressed (False) or left unmodified (None, default). (Nipype default value: [])

  • data_dtype (a string) – NumPy datatype to coerce NIfTI data to, or source tomatch the input file dtype.

  • dismiss_entities (a list of items which are a string or None) – A list entities that will not be propagated from the source file. (Nipype default value: [])

  • in_file (a string or os.PathLike object referring to an existing directory or a list of items which are a pathlike object or string representing an existing file) – The object to be saved.

  • meta_dict (a dictionary with keys which are a value of class ‘str’ and with values which are any value) – An input dictionary containing metadata.

Outputs:
  • compression (a list of items which are a boolean or None) – Whether in_file should be compressed (True), uncompressed (False) or left unmodified (None).

  • fixed_hdr (a list of items which are a boolean) – Whether derivative header was fixed.

  • out_file (a list of items which are a pathlike object or string representing an existing file)

  • out_meta (a list of items which are a pathlike object or string representing an existing file)

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

Bases: SimpleInterface

The FieldToHz converts from arbitrary units to Hz

Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Input fieldmap.

  • range_hz (a float) – Range of input field map.

Outputs:

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

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

Bases: SimpleInterface

The FieldToRadS converts from arbitrary units to rad/s

Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – Input fieldmap.

Optional Inputs:

fmap_range (a float) – Range of input field map.

Outputs:
  • fmap_range (a float) – Range of input field map.

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

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

Bases: SimpleInterface

Combine various sources of confounds in one TSV file

Optional Inputs:
  • denoising_confounds (a pathlike object or string representing an existing file) – Descriptive statistics from denoising.

  • fd (a pathlike object or string representing an existing file) – Input framewise displacement.

  • motion (a pathlike object or string representing an existing file) – Input motion parameters.

  • original_bvals (a list of items which are a pathlike object or string representing an existing file) – Originals bval files.

  • original_bvecs (a list of items which are a pathlike object or string representing an existing file) – Original bvec files.

  • original_files (a list of items which are any value) – Original grouping of each volume.

  • sliceqc_file (a pathlike object or string representing an existing file) – Output from sliceqc.

Outputs:
  • confounds_file (a pathlike object or string representing an existing file) – Output confounds file.

  • confounds_list (a list of items which are a string) – List of headers.

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

Bases: SimpleInterface

Mandatory Inputs:

in_files (a list of items which are a pathlike object or string representing an existing file) – Input files.

Optional Inputs:
  • hmc (a boolean) – (Nipype default value: True)

  • to_lps (a boolean) – (Nipype default value: True)

  • zero_based_avg (a boolean) – (Nipype default value: True)

Outputs:
  • out_avg (a pathlike object or string representing an existing file) – Average image.

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

  • out_mats (a list of items which are a pathlike object or string representing an existing file) – Output matrices.

  • out_movpar (a list of items which are a pathlike object or string representing an existing file) – Output movement parameters.

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

Bases: SimpleInterface

Convert a phase difference map into a fieldmap in Hz

Mandatory Inputs:
  • in_file (a pathlike object or string representing an existing file) – Input fieldmap.

  • metadata (a dictionary with keys which are any value and with values which are any value) – BIDS metadata dictionary.

Outputs:

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

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

Bases: SimpleInterface

Convert a phase1, phase2 into a difference map

Mandatory Inputs:
  • metadatas (a list of items which are a dictionary with keys which are any value and with values which are any value) – List of phase1, phase2 metadata dicts.

  • phase_files (a list of items which are a pathlike object or string representing an existing file) – List of phase1, phase2 files.

Outputs:
  • out_file (a pathlike object or string representing a file) – The output fieldmap.

  • phasediff_metadata (a dictionary with keys which are any value and with values which are any value) – The phasediff metadata.

class qsiprep.interfaces.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.SubjectSummary(from_file=None, resource_monitor=None, **inputs)[source]

Bases: SummaryInterface

Optional Inputs:
  • dwi_groupings (a dictionary with keys which are any value and with values which are any value) – Groupings of DWI files and their output names.

  • freesurfer_status (‘Not run’ or ‘Partial’ or ‘Full’) – FreeSurfer status.

  • output_spaces (a list of items which are any value) – Target spaces.

  • session_id (a string) – Session ID.

  • subject_id (a string) – Subject ID.

  • subjects_dir (a pathlike object or string representing a directory) – FreeSurfer subjects directory.

  • t1w (a list of items which are a pathlike object or string representing an existing file) – T1w structural images.

  • t2w (a list of items which are a pathlike object or string representing an existing file) – T2w structural images.

  • template (a string) – Template space.

Outputs:
  • out_report (a pathlike object or string representing an existing file) – HTML segment containing summary.

  • subject_id (a string) – FreeSurfer subject ID.

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

Bases: SimpleInterface

Check the correctness of x-form headers (matrix and code) This interface implements the following logic: +——————-+——————+——————+——————+————————————————+ | valid quaternions | qform_code > 0 | sform_code > 0 | qform == sform | actions | +===================+==================+==================+==================+================================================+ | True | True | True | True | None | +——————-+——————+——————+——————+————————————————+ | True | True | False | * | sform, scode <- qform, qcode | +——————-+——————+——————+——————+————————————————+ | * | * | True | False | qform, qcode <- sform, scode | +——————-+——————+——————+——————+————————————————+ | * | False | True | * | qform, qcode <- sform, scode | +——————-+——————+——————+——————+————————————————+ | * | False | False | * | sform, qform <- best affine; scode, qcode <- 1 | +——————-+——————+——————+——————+————————————————+ | False | * | False | * | sform, qform <- best affine; scode, qcode <- 1 | +——————-+——————+——————+——————+————————————————+

Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – Input image.

Outputs:
  • out_file (a pathlike object or string representing an existing file) – Validated image.

  • out_report (a pathlike object or string representing an existing file) – HTML segment containing warning.

Submodules