spectral_unmixing.prepare_source_target_for_alpha

spectral_unmixing.prepare_source_target_for_alpha(source_volume, target_volume, *, background_percentile=1.0, preprocess_alpha_inputs=True)[source]

Convert, optionally background-correct, and clip source and target volumes.

Parameters:
  • source_volume, target_volume (array-like) – Matching source and target image volumes. Any matching shape is accepted, for example ZYX or flattened arrays.

  • background_percentile (float, optional) – Low percentile used to estimate a rough background in each input.

  • preprocess_alpha_inputs (bool, optional) – If True, subtract the percentile-based background from each input and clip negative values to zero. If False, the inputs are only converted to float32.

Return type:

tuple[ndarray, ndarray, float, float]

Returns:

tuple – (source_prepared, target_prepared, source_background, target_background).

Raises:

ValueError – If the input volumes do not share the same shape or are empty.