spectral_unmixing.estimate_alpha_from_volume๏
- spectral_unmixing.estimate_alpha_from_volume(source, target, signal_percentile=99.0, background_percentile=1.0, min_mask_voxels=16, *, method='mean_ratio', target_low_percentile=None, preprocess_alpha_inputs=True, alpha_max=1.0, mi_bins=64, max_alpha_voxels=500000, random_state=0, return_details=False)[source]๏
Estimate a bleed-through coefficient alpha from matching source and target volumes.
- Parameters:
source, target (array-like) โ Matching source and target image volumes. Typical microscopy input is a
ZYXvolume, but any matching shape is accepted.signal_percentile (float, optional) โ Percentile used to define a bright-source signal mask.
background_percentile (float, optional) โ Low percentile used for optional percentile-based background subtraction before alpha estimation.
min_mask_voxels (int, optional) โ Minimum number of voxels required in the final alpha-estimation mask.
method ({โmean_ratioโ, โlinear_fitโ, โcorr_minโ, โmi_minโ}, optional) โ Scalar alpha-estimation strategy.
target_low_percentile (float or None, optional) โ Optional extra target constraint for the estimation mask. If provided, voxels are restricted to bright source signal and low target signal whenever that yields enough voxels.
preprocess_alpha_inputs (bool, optional) โ If
True, apply percentile-based background subtraction and clip negative values to zero before alpha estimation. IfFalse, estimate alpha directly on the original intensities converted tofloat32.alpha_max (float, optional) โ Upper search bound for optimization-based methods
"corr_min"and"mi_min".mi_bins (int, optional) โ Number of histogram bins used by the mutual-information estimator.
max_alpha_voxels (int or None, optional) โ Optional cap on the number of voxels used after masking. If the mask is larger, voxels are subsampled without replacement.
random_state (int, optional) โ Random seed used for optional voxel subsampling.
return_details (bool, optional) โ If
True, also return a dictionary describing preprocessing, thresholds, mask size, subsampling, and method-specific diagnostics.
- Return type:
float|tuple[float,dict]- Returns:
float or tuple โ Estimated alpha, or
(alpha, details)ifreturn_details=True.- Raises:
ValueError โ If the input data are incompatible, the estimation mask is too small, or the estimated alpha is invalid.