qsiprep.interfaces.nilearn module

Image tools interfaces

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

Bases: SimpleInterface

Mandatory Inputs:

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

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

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

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

class qsiprep.interfaces.nilearn.MaskEPI(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 EPI or list of files.

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

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

  • enhance_t2 (a boolean) – Enhance T2 contrast on image. (Nipype default value: False)

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

  • exclude_zeros (a boolean) – (Nipype default value: False)

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

  • lower_cutoff (a float) – (Nipype default value: 0.2)

  • no_sanitize (a boolean) – (Nipype default value: False)

  • opening (an integer) – (Nipype default value: 2)

  • target_affine (a string or os.PathLike object referring to an existing file or None) – (Nipype default value: None)

  • target_shape (a string or os.PathLike object referring to an existing file or None) – (Nipype default value: None)

  • upper_cutoff (a float) – (Nipype default value: 0.85)

Outputs:

out_mask (a pathlike object or string representing an existing file) – Output mask.

class qsiprep.interfaces.nilearn.Merge(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 list of files to merge.

Optional Inputs:
  • compress (a boolean) – Use gzip compression on .nii output. (Nipype default value: True)

  • dtype (‘f4’ or ‘f8’ or ‘u1’ or ‘u2’ or ‘u4’ or ‘i2’ or ‘i4’) – Numpy dtype of output image. (Nipype default value: f4)

  • header_source (a pathlike object or string representing an existing file) – A Nifti file from which the header should be copied.

  • is_dwi (a boolean) – If True, negative values are set to zero. (Nipype default value: True)

Outputs:

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

qsiprep.interfaces.nilearn.biascorrect(nii, copy_input_header=True, cwd=None)[source]
qsiprep.interfaces.nilearn.calculate_gradmax_b0_mask(b0_nii, show_plot=False, quantile_max=0.8, pad_size=10, cwd=None)[source]

Robustly finds a brain mask from a low-res b=0 image.

The steps for finding a mask for a b=0 image

  1. Remove spiky outliers with a median filter

  2. Non-aggressively bias correct the image using N3

  3. Calculate the magnitude of the spatial gradient

  4. Clip the intensity values and rescale them using a Box-Cox transform

  5. Calculate a foreground threshold using Otsu’s Method

  6. Try a series of orders for opening. Select the order that maximizes the gradient from (3) at the edge of the opened mask.

Returns

mask_nii: spatial image

binary gradient-optimizing mask

scaled_nii: spatial image

robust scaled image for brain extraction

gradient_nii: spatial image

gradient image

qsiprep.interfaces.nilearn.run_imagemath(nii, op, args, copy_input_header=True, cwd=None)[source]
qsiprep.interfaces.nilearn.select_markers_for_rw(image, inner_mask, empty_mask, outer_mask, sample_proportion=0.5)[source]
qsiprep.interfaces.nilearn.watershed_refined_b0_mask(b0_nii, show_plot=False, pad_size=10, quantile_max=0.8, ribbon_size=5, cwd=None)[source]

Refine the boundary of a mask using the watershed algorithm.

Returns

mask_nii: spatial image

binary gradient-optimizing mask

weighting_mask: spatial image

smoothed mask for use with N4