Skip to content

Examples

Find a Python script or Jupyter notebook by task. Source links open the files on GitHub. Walkthrough links explain the same or a related workflow in the docs.

Run an example

From the repository root, install Lumic and its example dependencies in a Python 3.12 environment. Then run the scripts as modules from Python/.

python -m pip install -e './Python/lumic[examples]'
cd Python
python -m examples.spectral_image_workflow

Open the notebooks from Python/examples/notebooks/ in Jupyter and select the kernel for the same environment. If you're new to Jupyter, see Run your first notebook. Examples marked COS-7 download fetch the public high-SNR image on first use (about 145 MB) and reuse the local copy afterward. Examples marked live FPbase need internet access and the fpbase extra. To install both extras from the repository root, use python -m pip install -e './Python/lumic[examples,fpbase]'.

Load and inspect real data

Example What it shows Walkthrough
Download COS-7 data (.py) Download selected acquisitions or reference images from BioImage Archive. Load spectral images
Inspect and load spectral images (.py) Inspect a CZI or OME-TIFF header before loading pixels. COS-7 download by default. Load spectral images
Load a CZI (.py) Read pixels, inspect metadata, and select a plane. COS-7 download by default. Load spectral images
Load an OME-TIFF (.py) Export the COS-7 CZI to a temporary OME-TIFF and load it. COS-7 download. Load spectral images
Render a spectral image in RGB (.py) Preview a CZI using shared scaling and copy a plane from a Z stack. COS-7 download by default. Load spectral images
Compare image loading (.ipynb) Compare the detector pixels loaded from a CZI and its OME-TIFF export. COS-7 download. Load spectral images
Inspect image metadata (.ipynb) Compare the metadata Lumic reads from a CZI and its OME-TIFF export. COS-7 download. What metadata does Lumic return?
Import a ZEN spectrum (.ipynb) Read a bundled ZEN XML spectrum into a Lumic Spectrum.

Simulate images

Example What it shows Walkthrough
Simulate a binary mixture (.py) Make a small, noiseless EGFP and mCherry image. Live FPbase. Simulate a spectral image
Render a mixture of three fluorophores (.py) Make an RGB preview of a 20 × 20 mixture. Live FPbase. Simulate a spectral image
Render a ternary mixture (.py) Render mixtures inside a triangle with one pure fluorophore at each vertex. Live FPbase. Unmix a ternary image
Render a spatial scene (.py) Compare the same fluorescent shapes with and without approximate optical blur. Simulate a spectral image
Compare noise in images (.py) View the same scene at several noise levels. Add shot noise
Compare Poisson noise in spectra (.py) Plot how relative shot noise increases as the expected counts fall. Add shot noise

Unmix, evaluate, and save results

Example What it shows Walkthrough
Unmix a COS-7 image (.ipynb) Unmix a real spectral acquisition and inspect the fitted results. COS-7 download. Unmix a real experimental image
Explore the convex hull (.ipynb) See how the hull finds distinct spectra in a synthetic mixture. Estimate unknown spectra
Map spectral uniqueness (.py) Compare spectral distinctness in image coordinates and in the hull projection. Spectral uniqueness maps
Unmix overlapping circles (.py) Estimate spectra from a simulated image, then compare the fitted spectra and maps with the known inputs. Evaluate simulation recovery
Run a spectral image workflow (.py) Unfold and unmix a simulation, restore the image layout, then compare and export the fitted results. Save images and spectra
Export spectral and RGB images (.py) Save a simulation as OME-TIFF, verify its round trip, and export an RGB preview. Save images and spectra

Extend Lumic

Example What it shows Walkthrough
Image reader template (.py) Implement the reader interface for an additional image format. Adding an image reader