Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the user guide for the big picture.

brainprep.workflow.brainprep_quasiraw

brainprep.workflow.brainprep_quasiraw(anatomical_file, output_dir, rigid=False, quick=False, keep_intermediate=False, **kwargs)[source]

Quasi-RAW pre-processing.

Applies the Quasi-RAW pre-processing described in [1] to T1-weighted, T2-weighted and FLAIR MRI images. This includes:

  1. Reorient the anatomical image to standard MNI152 template space.

  2. Compute a brain mask using a skull-stripping tool.

  3. Perform N4 bias field correction.

  4. Resample the anatomical image to 1mm isotropic voxel size.

  5. Linearly register the image to the MNI152 1mm template space (6 or 9 DOF).

  6. Apply the registration to the bias field corrected antomical image.

  7. Apply the registration to the brain mask image.

Parameters:
anatomical_fileFile

Path to the input image file: T1w, T2w or FLAIR.

output_dirDirectory

Directory where the outputs will be saved (i.e., the root of your dataset).

rigidbool

Estimate a 6 DOF transformation that maintains the original size and shape of the brain. By default a 9 DOF transformation allows for additional scaling in the x, y, and z directions, adjusting the size of the brain during the alignment process. Default False.

quickbool

Speed up processing by applying optimizations that trade accuracy for computational efficiency. This is particularly useful for large-scale batch processing where speed is prioritized. Default False.

keep_intermediatebool

If True, retains intermediate results (i.e., the workspace); useful for debugging. Default False.

**kwargsdict
entities: dict

Dictionary of parsed BIDS entities.

Returns:
Bunch

A dictionary-like object containing:

  • aligned_anatomical_file : File - path to the aligned 1 mm anatomical image - a Nifti file with the suffix “_T1w”.

  • aligned_mask_file : File - path to the aligned 1 mm mask image - a Nifti file with the suffix “_mod-T1w_brainmask”.

  • transform_file : File - path to the 9 dof affine transformation - a text file with the suffix “_mod-T1w_affine”.

Raises:
ValueError

If the input anatomical file is not BIDS-compliant or if the input modality is not supported.

Notes

This workflow assumes the anatomical image is organized in BIDS and applies the following optimizations in quick mode:

  • Use a coarser resolution: Increase the shrink factor from 1 to 4 to downsample the image before estimating the bias field, employ the MNI152 2mm template as the reference image and scale data to a 2mm space.

  • Use a Coarser Search Space: Restricted rotation search range to +/-30° on all three axes for the registration.

References

Examples

>>> from brainprep.config import Config
>>> from brainprep.reporting import RSTReport
>>> from brainprep.workflow import brainprep_quasiraw
>>>
>>> with Config(dryrun=True, verbose=False):
...     report = RSTReport()
...     outputs = brainprep_quasiraw(
...         anatomical_file=(
...             "/tmp/dataset/rawdata/sub-01/ses-01/anat/"
...             "sub-01_ses-01_run-01_T1w.nii.gz"
...         ),
...         output_dir="/tmp/dataset/derivatives",
...     )
>>> outputs
Bunch(
  aligned_anatomical_file: PosixPath('...')
  aligned_mask_file: PosixPath('...')
  transform_file: PosixPath('...')
)

Examples using brainprep.workflow.brainprep_quasiraw

Quasi-RAW

Quasi-RAW