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.defacing.brainprep_group_defacing

brainprep.workflow.defacing.brainprep_group_defacing(output_dir, overlap_threshold=0.05, keep_intermediate=False)[source]

Group level defacing pre-processing.

Applies the following quality control procedure:

  1. Generate a TSV table containing the intersection between the brain and defacing masks.

  2. Apply threshold-based quality checks on the selected quality metrics.

  3. Generate a histogram showing the distribution of these quality metrics.

Parameters:
output_dirDirectory

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

overlap_thresholdfloat

Quality control threshold on the overalp score. Default 0.05.

keep_intermediatebool

If True, retains intermediate results (no effect on this workflow). Default False.

Returns:
Bunch

A dictionary-like object containing:

  • overalp_file : File - a TSV file containing brain/defacing masks intersection quality check (QC) data.

  • overalp_histogram_file : File - PNG file containing the histogram of the computed overlaps.

Notes

This workflow assumes the subject-level analyses have already been performed.

A qc column is added to the TSV QC output table. It contains a binary flag indicating whether the produced results should be kept: qc = 1 if the result passes the thresholds, otherwise qc = 0.

The associated PNG histograms help verify that the chosen thresholds are neither too restrictive nor too permissive.

Examples

>>> from brainprep.config import Config
>>> from brainprep.reporting import RSTReport
>>> from brainprep.workflow import brainprep_group_defacing
>>>
>>> with Config(dryrun=True, verbose=False):
...     report = RSTReport()
...     outputs = brainprep_group_defacing(
...         output_dir="/tmp/dataset/derivatives",
...     )
>>> outputs
Bunch(
    overlap_file: PosixPath('...')
    overalp_histogram_file: PosixPath('...')
)