Spectral Unmixing: Emission Curves & Recovery Map

This is the 2D counterpart to the rotatable 3D tissue-grid simulator: instead of assuming a fixed bleed-through matrix, it builds one from first principles. Three fluorophore emission curves (Gaussians centred on real FITC/PE/APC peak wavelengths) are numerically integrated against three fixed detector bandpass windows, so the crosstalk matrix M is a direct, inspectable consequence of spectral overlap — widen the curves with the crosstalk slider and watch them spill across channel boundaries in the left panel. The right panel plots a synthetic population of tissue spots as points in marker-abundance space, drawing a truth-to-recovered displacement line for each one, so the geometry of unmixing error is visible directly rather than inferred from a spatial heat-map. Compare a naive matrix-inverse recovery against one that first subtracts a calibrated autofluorescence estimate, and watch the RMS error and matrix conditioning index respond live as you tune crosstalk, autofluorescence and noise.