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.interfaces.freesurfer.brainmask

brainprep.interfaces.freesurfer.brainmask(image_file, output_dir, entities, legacy=False)[source]

Skull-strip a BIDS-compliant anatomical image using FreeSurfer’s mri_synthstrip.

mri_synthstrip is a FreeSurfer command-line tool that applies SynthStrip, a deep learning-ased skull-stripping method developed to work across diverse imaging modalities, resolutions, and subject population [1].

mri_synthstrip enforces orientation standards and a target voxel spacing to feed the image through its neural network architecture. When writing the generated binary mask back into NIfTI format, the floating-point arithmetic used to re-calculate the qform and sform affine matrices can introduce small variations. This causes downstream neuroimaging packages like ITK, ANTs, or MONAI to flag the header as modified, offset, or corrupted. fslcpgeom is used to copy the exact geometric header from the input scan directly onto the mri_synthstrip mask.

Parameters:
image_fileFile

Path to the input image file (T1w, T2w, FLAIR, etc.).

output_dirDirectory

Directory where the reoriented image will be saved.

entitiesdict

A dictionary of parsed BIDS entities including modality.

legacybool

With old version the ‘-f: BG fill value, defaults to min(image.min, 0)’ is not available, the legacy mode adapt the command line accordingly. Default False.

Returns:
commandlist[str]

Skull-stripping command-line.

outputstuple[File]

-brain_file : File - Skull-stripped brain image file. -mask_file : File - Binary brain mask image file.

References