Architecture¶
This repo is a napari plugin organized around a Qt widget and a set of tab modules.
Entry points¶
src/senoquant/napari.yamldeclares the napari widget and reader.src/senoquant/_widget.pydefinesSenoQuantWidgetand registers the tabbed UI.src/senoquant/_reader.pyexposes the reader entrypoint.
UI structure¶
The main widget (SenoQuantWidget) composes eight tabs:
- Segmentation (
src/senoquant/tabs/segmentation). - Spots (
src/senoquant/tabs/spots). - Prediction (
src/senoquant/tabs/prediction). - SenNet Portal (
src/senoquant/tabs/sennet_portal). - Quantification (
src/senoquant/tabs/quantification). - Visualization (
src/senoquant/tabs/visualization). - Batch (
src/senoquant/tabs/batch). - Settings (
src/senoquant/tabs/settings).
Each tab follows a frontend/backend split:
frontend.pybuilds the Qt widgets and handles UI events.backend.pyperforms the model discovery or processing logic.- Segmentation additionally uses
segmentation/_frontend/mixins to keep UI code split across smaller modules.
Prediction-specific note:
- The tab-level UI is fixed (
Select model,Model interface,Run), and each prediction model contributes its own Qt widget throughSenoQuantPredictionModel.build_widget(...).
Reader pipeline¶
The reader implementation lives in src/senoquant/reader/core.py and
uses a hybrid BioIO strategy. The reader:
- Prefers fast format-specific BioIO plugins for pixel loading.
- Uses bioio-bioformats for metadata extraction when available.
- Falls back to the data reader for metadata when BioFormats metadata open fails.
- Uses
dask_tiles=Truewhen BioFormats is used for pixel loading. - Extracts channel colors from OME metadata when available.
- Falls back to a default colormap cycle when all channels have the same color.
- Iterates scenes and channels to create napari layers.
Batch pipeline¶
Batch processing is orchestrated by BatchBackend in
src/senoquant/tabs/batch/backend.py. The flow is:
- Enumerate input files and resolve channel indices.
- Run segmentation (nuclear/cytoplasmic) as configured.
- Run spot detection per selected channels, then apply optional diameter-based spot filtering.
- Run quantification using a lightweight viewer shim.
- Write masks and quantification outputs to disk.
- Persist
senoquant_settings.jsonin the batch output root with the effectivebatch_jobconfiguration.
Prediction pipeline¶
Prediction runs are orchestrated by PredictionTab +
PredictionBackend:
- Discover model folders under
src/senoquant/tabs/prediction/models/. - Load the selected model class from
<model_name>/model.py. - Build model-defined UI in the
Model interfacebox. - Collect model widget settings and run model code in a background thread.
- Normalize model output into napari layer specs and add layers to the viewer.
- Append run metadata (
task="prediction", runner name/type, settings).
Settings storage¶
The Settings tab uses SettingsBackend to read/write unified
senoquant.settings JSON bundles. These bundles can include:
tab_settingspayloads for tab-level settings snapshots.batch_jobpayloads compatible with batch config serialization.feature_settingsandsegmentation_runspayloads produced by quantification exports.
Cross-tab settings orchestration¶
SenoQuantWidget instantiates all tab widgets. Settings currently receives
Segmentation, Spots, and Batch tab references and uses them to:
- Export segmentation and spots configuration into
tab_settings. - Export batch state into
batch_job. - Restore those states when loading a bundle.
Prediction, Quantification, and Visualization settings are currently not restored by the Settings tab.