spectral_unmixing.make_alpha_mask

spectral_unmixing.make_alpha_mask(source, target=None, *, signal_percentile=99.0, target_low_percentile=None, min_voxels=16)[source]

Create a robust mask for alpha estimation.

Parameters:
  • source (array-like) – Prepared source intensities used to define the bright-source mask.

  • target (array-like or None, optional) – Optional prepared target intensities used to additionally constrain the mask to low-target voxels.

  • signal_percentile (float, optional) – Source percentile above which voxels are considered signal-rich.

  • target_low_percentile (float or None, optional) – If provided, only voxels at or below this target percentile are kept, unless that mask would become too small and the source-only fallback is used instead.

  • min_voxels (int, optional) – Minimum number of voxels required for a valid estimation mask.

Return type:

tuple[ndarray, dict]

Returns:

tuple – (mask, details) where mask is a boolean array and details is a metadata dictionary describing thresholds, fallback behavior, and voxel counts.