Skip to content

About

Software for SLIC (Spectral-Lifetime Indexing of Cells): a napari plugin and the LUMINA classifier for single-cell barcoding by fluorescence lifetime, spectrum and subcellular localization.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

145 Commits

Folders and files

Repository files navigation

πŸ”¬ SLIC β€” Spectral-Lifetime Indexing of Cells

DOI License: BSD-3-Clause

Software for Spectral-Lifetime Indexing of Cells (SLIC), a single-cell barcoding strategy that combines fluorescence lifetime, spectral imprint and subcellular localization to identify many cell populations within one mixed sample, and to read a biosensor from each of them.

SLIC workflow

A barcode is a fluorophore whose lifetime and emission spectrum, together with the subcellular compartment it is targeted to, identify the cell carrying it. A single FLIM acquisition records a photon-arrival histogram per pixel in four spectral windows; averaged over a segmented cell, this yields five values β€” the phasor coordinates G and S, and three spectral intensity ratios. Cells sharing a barcode occupy the same region of that five-dimensional space, so clustering assigns each cell its barcode.

Decoding follows that principle: organelle-localized fluorescence images are segmented with a fine-tuned Cellpose model, cells are classified by five-dimensional clustering, and the biosensor module then segments and tracks cells in the time-lapse channels, aligns each with its barcode identity, and extracts its signal kinetics.

🌐 Hosted instance

https://baoyi-a.github.io/nacha-demo/ runs the plugin on the demo dataset in a browser, with no local setup. It starts a cloud machine on demand and re-installs from this repository's main on every cold start, so it runs the published code.

Repository contents

Two independent tools, each with its own README, its own environment, and no code shared between them.

🧩 Napari_plugin/ SLIC, the napari plugin β€” also known as NaCha, which is its final widget and the name the hosted demo goes by. Seven widgets carry an acquisition from a raw .ptu to one biosensor readout per barcode. Installs as bc-flim-spectra.
🧠 LUMINA_classification/ LUMINA (Lifetime-based Unmixing for Multiplexed ImagiNg and bArcoding) β€” the deep-learning classifier for dual-anchor barcodes, where one cell carries two fluorophores in two compartments.
πŸ€– .claude/skills/ One agent skill per tool, allowing a coding assistant to install and operate either of them. See below.

Releases are tagged and archived on Zenodo; the DOI above always resolves to the most recent archived version. The classification pipeline the manuscript describes is that of release 1.1 and later (see VERSIONING.md); the 1.0.x archive predates it.


1. 🧩 Napari Plugin β€” Single-Anchor Barcode Analysis

The SLIC napari plugin runs the full workflow, from .ptu ingestion through segmentation, classification and tracking to alignment and visualization.

SLIC in napari: the NaCha step

The last step, NaCha, on a sixteen-barcode dish: cells coloured by barcode class, one cell's biosensor channels and G/B ratio below, and the widget on the right. Screenshots of every step are in the plugin README.

Seven widgets, listed under Plugins β†’ bc-flim-spectra. Each has a blue Next β–Ά button that opens the following one, so the workflow chains without returning to the menu.

  • πŸ“₯ PTU Reader β€” import and decode FLIM .ptu files.
  • πŸ”¬ Barcode Seg (Cellpose) β€” N / P segmentation on the barcode intensity image, with online single- or multi-folder fine-tuning.
  • πŸŒ€ Calculate FLIM-S β€” lifetime / phasor computation.
  • 🧩 Seeded K-Means β€” semi-supervised barcode classifier (Basu et al. 2002), with per-class outlier flagging. Four alternative clusterers ship alongside it.
method_kmeans.mp4

How the classifier places a cell: seeds carried from another batch, whitening by the pooled within-cluster spread of the batch being classified, seeded K-means refining the centres on that batch, then an isolation forest that sets aside the most anomalous tenth of each cluster rather than assign a cell it cannot place. Click to play.

  • 🟑 Biosensor Seg (Cellpose) β€” dual-input segmentation on the confocal biosensor stack, using the barcode classification mask as an auxiliary channel. A biosensor experiment without barcodes also runs: the widget and NaCha detect that the sample has no barcode, skip the barcode steps, and read out every cell as one group (details).
  • 🎬 B&P Tracker β€” multi-cell tracking in dense cultures, based on XMem with a short-horizon, periodically reset memory.
  • πŸ“ˆ NaCha β€” final alignment and per-class signal readout / visualization.
demo.mp4

Sixteen barcoded populations in one dish, read out one at a time: each column is a barcode, its biosensor, the three confocal channels, and that population's own response to the stimulus. A full step-by-step instruction video is on Zenodo.

Every widget has a ⌨ Shortcuts button listing the keys of that step, including Alt+1…9 to show or hide layers (full table), and an β“˜ How to use button with the step-by-step notes.

➑️ Installation and full usage: Napari_plugin/README


2. 🧠 LUMINA β€” Dual-Anchor Barcode Classification Network

LUMINA network

LUMINA (Lifetime-based Unmixing for Multiplexed ImagiNg and bArcoding) is a deep-learning framework that integrates fluorescence lifetime, spectral features and subcellular localization to decode dual-anchor barcodes at single-cell resolution β€” one fluorophore on a nuclear anchor, a second on a mitochondrial anchor.

Reducing a cell to five averaged values cannot separate two fluorophores in two compartments, so LUMINA operates on the pixels. Each segmented cell becomes a six-plane stack: the per-pixel phasor G and S, three spectral intensity ratios, and the intensity. Each plane has its own convolutional stem; the planes are fused in a shared trunk and read out by two independent classifier heads under a class-balanced loss, so one forward pass decodes both anchors. Training is two-stage: pre-training on single-anchor data, then fine-tuning on dual-anchor data.

  • 🧹 Data_prep.py β€” build the per-cell six-plane crops from decoded FLIM data.
  • πŸ‹οΈ Train_LUMINA.py β€” pre-training and fine-tuning.
  • πŸ” Test_LUMINA.py β€” inference, with per-cell confidence scoring.
  • πŸ”₯ Visualize_heatmap.py β€” the nuclear-by-mitochondrial co-occurrence figure.
  • 🎯 Finetune_LUMINA.py β€” adapt a trained checkpoint to a new cell line.

➑️ Installation and full usage: LUMINA_classification/README


πŸ–₯ Environment

  • Python >= 3.9 (tested on Python 3.10)
  • Operating system:
    • Tested on: Windows 11
    • Expected to work on: Windows 10/11, Linux (Ubuntu 20.04)
  • GPU: optional (CUDA-enabled GPU recommended for acceleration)

Typical installation time: ~20–60 minutes depending on whether PyTorch/CUDA wheels need to be downloaded and the network speed.


⏱ Expected runtime (representative)

🧩 Napari Plugin (interactive)

  • Typical processing time per dataset: ~10–15 minutes on a CUDA GPU, most of it spent looking at masks rather than waiting.
  • Tracking step: ~5 minutes (included above).
  • Check the "Compute:" line in the segmentation panel first. The default PyTorch package has no GPU support, and on CPU segmentation of one 2048 Γ— 2048 field takes tens of minutes instead of seconds. Nothing fails β€” it is just slow, and the header is the only place that says so.
  • Runtime otherwise depends on dataset size, number of cells, and hardware.

🧠 LUMINA

  • Inference on a single sample/image: ~1 second
  • Including preprocessing (e.g., segmentation / data extraction): typically 3 minutes
  • Model training (if performed) can take longer and depends on dataset size and GPU.

πŸ€– SLIC works with an AI assistant

The repository carries its documentation in a form coding assistants read, to the agents.md and Agent Skills conventions used by Claude Code, Codex, Cursor and Copilot. Pointed at this repository, an assistant can install either tool, explain a parameter, and read a sample folder to report which steps have run and whether they look right.

βœ… Validation

Given only this repository, Claude Code builds an environment, installs the plugin and runs all seven steps on a 1.5 GB acquisition, from .ptu decoding to one signal curve per barcode.

Against the hand-curated version of the same field:

🧩 Barcode identity 271 of 271 cells got the same barcode. None wrong. Shuffling the labels drops it to 21–28 %, so the agreement is real.
πŸ”¬ Segmentation F1 0.83 (nuclei) and 0.87 (cytoplasm) at IoU β‰₯ 0.5; 0 splits, 1 merge
πŸ“‹ End to end 77 % of curated cells got the correct barcode, 5 % were declined as outliers, 18 % were never segmented, 0 % got a wrong one

Wherever it finds a cell, the barcode call matches ours. What a fully automatic run costs is coverage, not correctness β€” the stock nucleus model finds about three quarters of the nuclei our fine-tuned-and-curated reference has. The plugin provides fine-tuning on the user's own cells, which closes that gap.

The run took an afternoon on Claude Opus, most of it GPU time, and a few million tokens β€” tens of dollars of model usage. One field of one acquisition: a reproduction check, not a benchmark.

πŸ” "Where am I in the workflow?"

Napari_plugin/scripts/workflow_status.py reads a sample folder and reports which steps have run, quality checks on what they produced, and what is left. Read-only; no napari, no GPU.

python Napari_plugin/scripts/workflow_status.py <sample folder>
  [   done] 3 Calculate FLIM-S   rows=834, fovs=1, localisations={'N': 418, 'P': 416}
  [   done] 4 Seeded K-Means   clustered=418, classified=373, declined=45, classes=10
  [   done] 5 Biosensor Seg   seg_images=1, masks=1, confocal_stacks=3
  [  check] registration   best=90 CW, 90CW coverage=0.966, purity=0.998

Quality checks
  PASS  S stays under the semicircle apex (0.5) -- max S = 0.4997
  PASS  lifetimes are physical (0.1-10 ns) -- 1.24-3.80 ns
  PASS  barcode classes land on biosensor cells -- 96.6% of cells, purity 99.8%

  Next
  - Seeded K-Means: 416 row(s) were never clustered β€” it runs one localisation
    at a time and only ['N'] has been done.
  - Steps 5-7 (biosensor) have not run. They need the confocal B/G/Y stacks.

It checks the decay stacks, the masks, the phasor coordinates against the universal semicircle, the lifetimes, the declined fraction, the class sizes, and the registration β€” all four rotations, reporting coverage and purity, since coverage alone cannot separate a correct alignment from a wrong one. --json for scripting; exit status 1 on a failed check, so it gates too.

πŸ“š What the assistant reads

File Contents
AGENTS.md Repository layout, installation, the three-environment design, the headless testing pattern, and the conventions the code follows. Claude Code picks it up through the one-line CLAUDE.md.
.claude/skills/slic-napari/ The plugin: seven steps control by control, how to read each output, the failure modes with the check that identifies each, and installation notes.
.claude/skills/lumina-network/ LUMINA: the scripts, the data layout they expect, the training recipe, how to read the confidence outputs, and how to adapt a trained checkpoint to a new cell line.

Parameter descriptions in the skills were written against the widget tooltips and the argument parsers in the source. Nothing keeps them in step automatically, so where the two disagree the source is what runs.

πŸ“œ License

BSD 3-Clause License. See Napari_plugin/LICENSE for the full text.

The tracking code vendored under Napari_plugin/src/flim_s_gen/ β€” tracker/, inpainter/, tools/ and track_anything_simple.py β€” comes from Track-Anything and stays under its own MIT licence, Copyright (c) 2023 Mingqi Gao. That is the licence file sitting beside it at Napari_plugin/src/flim_s_gen/LICENSE; it covers those files, not this package.


πŸ“ Notes

  • These tools are under active development.
  • The manuscript describing the methods has been submitted but not yet published. The DOI will be provided once it becomes available. The schematics above are figure panels from that manuscript.
  • The instruction video walks through the plugin step by step.
  • The Dual-Anchor dataset, used for training the LUMINA network, is also provided.
  • The segmentation models the plugin loads by default, together with the eight models whose performance the manuscript reports, are archived separately.
  • A demo dataset is included for testing the Napari plugin functionalities.
  • The original version of all software code has been archived as well.

About

Software for SLIC (Spectral-Lifetime Indexing of Cells): a napari plugin and the LUMINA classifier for single-cell barcoding by fluorescence lifetime, spectrum and subcellular localization.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages