Functionality overviewο
This page summarizes the currently available unmixing and filtering functions at a conceptual level before the tutorial pages show them in script form.
Spectral unmixing workflowsο
Two main unmixing entry points are available:
spectral_unmixing.unmix(...)for directed linear spectral unmixingspectral_unmixing.unmix_picasso(...)for PICASSO-family blind unmixing
unmix(...): directed linear unmixingο
This is the main workflow for the common case in which one channel bleeds into another channel and a direct correction model is desired.
Forward modelο
The corrected target channel is computed by:
Optionally:
Main configuration dimensionsο
alpha_modecontrols where alpha is obtained from in multi-time-point stacks:fixed,reference_t, orper_t. Ifalpha_mode=Noneor the argument is omitted, the pipeline resolves the effective mode automatically.fixeduses a user-provided scalaralphafor the full stack. This is relevant for both single-time-point and multi-time-point stacks whenever one manually chosen coefficient should be applied everywhere. It is the natural companion ofmethod="manual".reference_testimates one scalaralphafrom a chosen reference time point, using all z-slices at that time point. This also works naturally forT=1stacks, where the only valid reference time point is0.per_testimates onealphavalue per time point, again using all z-slices for each time point. ForT=1this simply produces one estimated value.Nonemeans: ifalphais provided, the pipeline behaves asfixed; ifalphais missing andmethod="manual", a clear error is raised; otherwise the pipeline defaults toreference_twithalpha_reference_t=0.
methodcontrols how alpha is estimated:manual,mean_ratio,linear_fit,corr_min, ormi_min.source_channelandtarget_channeldefine the directed correction.bidirectional=Trueenables simultaneous correction of both channels by solving a \(2 \times 2\) linear mixing model.
Alpha-estimation methodsο
The package currently supports:
manual: user-supplied fixed alphamean_ratio: ratio of mean intensities inside a bright-source masklinear_fit: masked least-squares fit without interceptcorr_min: coefficient chosen to minimize residual source-target correlation after correctionmi_min: coefficient chosen to minimize mutual information after correction
Masking and preprocessingο
Alpha estimation can use:
low-percentile background subtraction,
clipping of negative background-corrected values,
a bright-source mask controlled by
signal_percentile,and an optional low-target constraint controlled by
target_low_percentile.
unmix_picasso(...): PICASSO-family blind unmixingο
This workflow is intended for blind unmixing scenarios in which mixing relations are inferred from the data rather than imposed as a single manual coefficient.
The implemented PICASSO-family workflows are motivated by the original PICASSO paper:
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
Currently available implementations are:
matlab_3c: close Python port of the original MATLAB 3-channel PICASSO workflowmatlab_n: explicit N-channel generalization of the MATLAB-style iterative update schemesource_sink_n: explicit source-sink multi-channel correction with either a fullsource_sink_matrixor the higher-levelsink_channels/neutral_channelsinterface; all sources contributing to one sink are optimized jointly by default, with optional background-offset estimation per modeled source-sink relation
PICASSO-family workflows still rely on linear channel-mixing assumptions. The blind component lies in estimating those relations from the data.
Filtering and projection helpersο
The package also includes post-unmixing helpers for stack processing.
apply_filters(...)ο
Supported filter types currently include:
mediangaussianordered filter chains such as
["median", "gaussian"]
The filters are applied on canonical TZCYX stacks and work for:
full
T>1, Z>1stacks,T=1orZ=1edge cases,and per-time-point parameter lists for adaptive filtering across time.
At a conceptual level:
the median filter replaces each pixel or voxel by the median within a local neighborhood
the Gaussian filter performs weighted local smoothing with a Gaussian kernel
The implementation supports:
2D slice-wise operation
optional 3D filtering via
apply_3D=Trueoptional alternate filter settings for channel 2 through dedicated keyword arguments
match_histograms_across_time(...)ο
This helper matches the intensity distribution of each time point to the
reference stack at t=0. It is useful when brightness drifts over time and a
consistent visual or analytical scale is needed before later processing.
max_z_project(...)ο
This helper computes a maximum-intensity projection over the z-axis while
preserving T and C.
If \(V(t, z, c, y, x)\) is the input stack, the projected output is:
where \(Z_{\mathrm{sel}}\) is either the full z-range or a user-specified
zrange.
Registration helpersο
The package currently provides:
register_stack(...)for time registration,correct_intra_stack_z_drift(...)for within-stack z-alignment problems.
register_stack(...) supports:
pystackreg-based rigid registration,phase_cross_correlationfrom scikit-image,channel-specific registration references,
optional z-projection selection,
and optional median pre-/post-filtering for registration reference images.
Visualization helpersο
For napari-based inspection, the package provides:
show_unmixed_channels_in_napari(...)for source/target two-channel viewsshow_all_channels_in_napari(...)for multi-channel inspection
Both helpers reuse an open napari viewer when possible and reopen one when the previous viewer has been closed.