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.maskdiff

brainprep.interfaces.maskdiff(mask1_file, mask2_file, output_dir, entities, inv_mask1=False, inv_mask2=False, dryrun=False)[source]

Compute summary statistics comparing two binary masks.

This function loads two binary mask images, verifies that they share the same spatial dimensions and affine transformation, computes their voxel-wise intersection, and writes a summary table containing voxel counts and physical volumes (in mm³) for each mask and their intersection.

Parameters:
mask1_fileFile

Path to the first binary mask image.

mask2_fileFile

Path to the second binary mask image.

output_dirDirectory

Directory where the defacing mask will be saved.

entitiesdict

A dictionary of parsed BIDS entities including modality.

inv_mask1bool

If True, the first mask is inverted before comparison. This is useful when the mask represents an exclusion region rather than an inclusion region. Default False.

inv_mask2bool

If True, the second mask is inverted before comparison. This is useful when the mask represents an exclusion region rather than an inclusion region. Default False.

dryrunbool

If True, skip actual computation and file writing. Default False.

Returns:
summary_fileFile

Path to the generated summary TSV file.

Raises:
ValueError

If both masks have not identical shapes and affines.