spectral_unmixing.unmix_picassoο
- spectral_unmixing.unmix_picasso(input_path, output_path=None, channels=None, *, method='picasso', implementation='matlab_3c', alpha_mode='reference_t', alpha_reference_t=0, source_sink_matrix=None, sink_channels=None, neutral_channels=None, background_percentile=1.0, preprocess_alpha_inputs=True, mi_bins=64, alpha_max=1.0, max_iter=200, tolerance=0.0001, max_alpha_voxels=500000, random_state=0, step_size=0.2, qn=100, pixel_bin_size=16, alpha_clip=0.5, negativity_threshold=0.0009, clip_every_n_iterations=50, source_sink_optimize_background=True, source_sink_max_background=0.2, source_sink_n_restarts=4, source_sink_joint_optimization=True, clip_negative=True, output_dtype='float32', verbose=True)[source]ο
Perform PICASSO-family multi-channel blind unmixing.
This workflow is motivated by the PICASSO publication: Seo, J., Sim, Y., Kim, J. et al. PICASSO allows ultra-multiplexed fluorescence imaging of spatially overlapping proteins without reference spectra measurements. Nature Communications 13, 2475 (2022). https://doi.org/10.1038/s41467-022-30168-z
- Parameters:
input_path (str or Path) β Path to the input microscopy stack readable by OMIO.
output_path (str or Path or None, optional) β Output path for the unmixed stack written via OMIO. If
None, a filename ending in"_picasso.tif"is created next to the input.channels (sequence of int or None, optional) β Channel indices to include in blind unmixing. If
None, all channels are used.method ({βpicassoβ}, optional) β Method label reserved for the PICASSO-like workflow.
implementation ({βmatlab_3cβ, βmatlab_nβ, βsource_sink_nβ}, optional) β Concrete implementation variant:
"matlab_3c"for a close Python port of the original MATLAB 3-channel workflow,"matlab_n"for an N-channel generalization of that workflow, and"source_sink_n"for a source-sink multi-channel model inspired by the napari plugin.alpha_mode ({βreference_tβ, βper_tβ}, optional) β Whether to estimate one unmixing matrix from a reference time point or one matrix per time point.
alpha_reference_t (int, optional) β Reference time point used when
alpha_mode="reference_t".source_sink_matrix (array-like or None, optional) β Square matrix used only by
implementation="source_sink_n". The selected channels define both rows and columns. The diagonal must be1. Off-diagonal values must be-1for modeled source-to-sink spillover and0otherwise. IfNone, an all-to-all matrix with diagonal1and off-diagonal-1is used.sink_channels (sequence of int or None, optional) β Convenience alternative to
source_sink_matrixforimplementation="source_sink_n". Provide actual channel indices fromchannelsthat should be corrected as sinks. All selected channels except those listed inneutral_channelsmay contribute to these sinks.neutral_channels (sequence of int or None, optional) β Convenience option for
implementation="source_sink_n". Provide actual channel indices fromchannelsthat should remain neutral, meaning they are neither corrected as sinks nor used as sources when a source-sink matrix is auto-generated.background_percentile (float, optional) β Low percentile used for per-channel background subtraction in the selected PICASSO implementation.
preprocess_alpha_inputs (bool, optional) β Backward-compatibility parameter retained from earlier PICASSO-like implementations. The current PICASSO-family implementations define their own internal preprocessing and therefore do not switch behavior based on this flag. The value is nevertheless recorded in the JSON sidecar report for reproducibility.
mi_bins (int, optional) β Number of histogram bins used by the mutual-information estimator in the source-sink implementation.
alpha_max (float, optional) β Upper bound for source-to-sink coefficients in the source-sink implementation.
max_iter (int, optional) β Maximum number of iterations for the selected implementation.
tolerance (float, optional) β Reserved for compatibility with the previous API. The MATLAB-like implementations follow a fixed iteration count rather than tolerance- based early stopping.
max_alpha_voxels (int or None, optional) β Optional cap on the number of voxels used for coefficient estimation in the source-sink implementation.
random_state (int, optional) β Random seed used for optional subsampling during matrix estimation.
step_size (float, optional) β Incremental update step size used by the MATLAB-style implementations.
qn (int, optional) β MATLAB-style mutual-information quantization parameter.
pixel_bin_size (int, optional) β MATLAB-style 2D binning factor applied before mutual-information evaluation.
alpha_clip (float, optional) β Absolute clipping bound applied to each MATLAB-style pairwise alpha estimate before the incremental update matrix is constructed.
negativity_threshold (float, optional) β MATLAB-style negativity ratio threshold above which a pairwise alpha is divided by ten.
clip_every_n_iterations (int, optional) β Frequency of positivity enforcement during the MATLAB-style iterations.
source_sink_optimize_background (bool, optional) β If
True,implementation="source_sink_n"jointly optimizes one background parameterbetaper modeled source-to-sink relation, following the source-sink formulation used by the napari PICASSO plugin.source_sink_max_background (float, optional) β Upper bound for the optimized source-background parameters in the source-sink implementation. The values operate on globally normalized intensities in the interval
[0, 1].source_sink_n_restarts (int, optional) β Number of multi-start optimizer initializations used by the source-sink implementation for each sink.
source_sink_joint_optimization (bool, optional) β If
True(default), all modeled sources contributing to a given sink are optimized jointly. IfFalse, the package falls back to the older greedy pairwise update strategy.clip_negative (bool, optional) β If
True, clip negative unmixed intensities to zero before writing.output_dtype (str or numpy.dtype, optional) β Data type used for the written output stack.
verbose (bool, optional) β If
True, print processing progress and output paths.
- Return type:
Path- Returns:
Path β Actual path of the written output stack.
Notes
implementation="matlab_3c"is the default and aims to match the published MATLAB 3-channel workflow as closely as possible.implementation="matlab_n"is an explicit N-channel generalization of that MATLAB workflow.implementation="source_sink_n"uses a direct source-sink subtraction model inspired by the napari plugin structure. It is not a neural-MINE port of the plugin, but it follows the same idea of user-defined source/sink relations.