A napari plugin for Nikon ND2 spectral imaging workflows, including ND2-to-OME-Zarr conversion, OME-Zarr reading, spectral visualization, and ROI-based analysis across 400-740 nm.
Project description
napari-nd2-spectral-ome-zarr
napari plugin for Nikon ND2 spectral imaging workflows with emphasis on 2D spectral cubes.
Plugin Overview
The plugin is organized as 3 subplugins:
ND2 Spectral Export
- convert single files or batches from ND2 to OME-Zarr
- load single or batch OME-Zarr datasets
- validate image structure and dimensions such as axes order, shape, and wavelength metadata
Spectral Viewer
- visualize spectral images as truecolor using visible-wavelength hue mapping
- provide a single-channel grayscale image for morphology review and machine-learning workflows
- read spectral intensity versus wavelength in normalized or absolute modes
- support ROI generation and ROI-based spectral extraction
Spectral Analysis
- collect stored ROI datasets for downstream analysis
- compute emission-ratio metrics using a user-defined split wavelength
- support Student's t-test and 1-way or 2-way ANOVA
- support blind-group analysis using PCA, feature comparison, user-selected clustering, and p-value statistics
Features:
- Read
.nd2files into napari - Read
.zarrand.ome.zarrthrough the plugin loader widget - Build an estimated truecolor RGB view for spectral ranges spanning roughly 400 nm to 740 nm
- Export the loaded ND2 spectral cube to OME-Zarr with multiscales and wavelength metadata
- Plot ROI spectra from spectral OME-Zarr layers
- Keep per-image ROI spectral datasets in memory during the napari session
- Export stored ROI datasets and analysis tables to CSV
- Run split-wavelength Nile Red ratio analysis, aggregation, and group comparison in a dedicated analysis panel
The plugin is designed around 2D spectral images and keeps T, C, Z, Y, X axis semantics explicit during export.
Installation
Install the plugin in a Python environment that can run napari:
pip install -e .
Then start napari and open the plugin widgets from the Plugins menu.
Dock Widgets
The plugin now exposes 3 napari dock widgets:
ND2 Spectral ExportSpectral ViewerSpectral Analysis
All 3 widgets are configured to float by default instead of staying docked in the main napari window.
ND2 Spectral Export Workflow
ND2 Spectral Export now handles:
- single ND2 preview
- batch ND2 to OME-Zarr export
- single OME-Zarr loading
- batch OME-Zarr loading from a parent folder
Single Zarr loading
The widget supports drag-and-drop or browsing for one .zarr folder.
Before opening, it shows:
- dataset name
- axes
- full-resolution shape
- preview shape
- whether the dataset is spectral
- wavelength count and wavelength range
The user can choose which views to open:
Visible sumTruecolorRaw spectral
It also supports Use preview pyramid level for the display layers.
Batch Zarr loading
The widget also supports scanning one parent folder recursively for .zarr datasets, including nested subfolders.
The batch table shows:
opennamerelative_pathaxesshapepreview_shapewavelengthsspectral
relative_path is shown as the parent folder only, for example ./659/, instead of including the .zarr folder name.
The user can:
- browse to a root folder
- scan recursively for
.zarrdatasets - select all or clear all
- open only the checked datasets
The chosen Visible sum, Truecolor, Raw spectral, and preview options are applied to all selected Zarr datasets in the batch open action.
Reader popup note
If a user opens .zarr files through napari's generic file-open dialog, napari may still show a Choose reader popup when multiple readers claim .zarr.
This plugin cannot reliably suppress that global napari chooser by itself.
The intended workaround is:
- use the plugin's own Zarr loader in
ND2 Spectral Export - open Zarr datasets from there instead of through napari's general file-open menu
Visible sum definition
Visible sum is currently computed as the raw per-pixel mean intensity across spectral bins:
- sum all channel intensities at a pixel
- divide by the number of spectral bins
- do not normalize
So if a pixel has 24 spectral bins, the displayed gray value is:
(bin_1 + bin_2 + ... + bin_24) / 24
Spectral Viewer Workflow
Spectral Viewer is where ROIs are drawn and spectral datasets are captured.
Important ROI logic
ROI layers are now handled per image, not globally.
- Each active spectral image gets its own Shapes layer named like
image_name ROI - ROI labels are displayed through a separate companion label layer
- ROI numbering resets per image, so image 1 can have
ROI 1..Nand image 2 can also haveROI 1..N - ROIs from image 1 are not reused automatically for image 2
Recommended step-by-step use
- Select a spectral image layer.
- Click
Prepare ROI Layer. - Draw ROIs for that image only.
- Click
Plot ROI Spectrum. - The plugin stores that image's ROI spectra in memory as a dataset.
- Move to the next image.
- Click
Prepare ROI Layeragain for that image. - Draw a fresh set of ROIs starting from
ROI 1.
If you want to redraw for the current image, click Clear Active ROI. That clears only the active image's ROI shapes and restarts numbering from ROI 1.
Stored ROI datasets
When Plot ROI Spectrum is used, the selected ROI spectra are stored in memory for the current napari session.
- Stored datasets remain available even if the image layer is later closed
- Stored datasets can be exported from
Spectral Viewer - Stored datasets are consumed by the
Spectral Analysispanel - Stored datasets do not persist across a full napari restart unless they are exported
Spectral Analysis Workflow
Spectral Analysis is intended for multi-image and multi-animal experiments.
Metadata editing
The Stored ROI Datasets table lets you annotate each captured dataset with:
animal_idgroup_labelgenotypesexageregionbatchblind_id
This supports experiments such as:
- 10 images total
- multiple experimental groups such as WT vs mutant, control vs treatment, or blinded cohorts
- multiple myelin ROIs per image
- aggregation from ROI level to image level to animal level
Dataset selection and removal
Analysis no longer uses every stored dataset automatically.
- Use the
use_for_analysischeckbox column to choose which dataset IDs are included - Click
Compute Spectral Analysisto analyze only the checked datasets - Click
Remove Selected Datasetsto delete all checked datasets from memory - Click
Remove Current Rowto delete the currently selected dataset
Unchecked datasets stay in memory but are ignored by the analysis.
Available analysis outputs
The panel computes:
- ROI-level ratio table
- image-level summary table
- animal-level summary table
Each table can be exported to CSV.
Ratio and statistics
The analysis panel supports:
- user-defined split wavelength
- ratio modes such as above/below split intensity ratio
- optional normalization before ratio calculation
- two-group comparison such as WT vs mutant or control vs treatment
- one-way ANOVA by selected factor
- blind PCA and clustering for unlabeled datasets
Recommended experiment flow
- Open spectral images in napari.
- For image 1, prepare the ROI layer and draw multiple myelin ROIs.
- Plot the ROI spectrum to store that image's ROI dataset.
- Repeat for image 2, image 3, and so on.
- Open
Spectral Analysis. - Enter metadata for each stored dataset.
- Check only the dataset IDs you want to compare.
- Set the wavelength split point.
- Compute the analysis.
- Export ROI, image, or animal summary CSV files as needed.
Known Limitations
- If
.zarrfiles are opened through napari's generic file-open dialog, napari may still show aChoose readerpopup when multiple readers claim.zarr. Use the plugin's own Zarr loader to avoid that workflow. - ROI datasets are stored in memory for the current napari session and should be exported if they need to survive a full application restart.
- napari
Shapesrendering can be sensitive in some environments. The plugin uses separate ROI label layers to reduce instability, but behavior can still depend on upstream napari and vispy rendering.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file napari_nd2_spectral_ome_zarr-1.1.0.tar.gz.
File metadata
- Download URL: napari_nd2_spectral_ome_zarr-1.1.0.tar.gz
- Upload date:
- Size: 37.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a6c328a777d898a9654256c70392f768622b6f63a062809bf7a8fcbe729d249
|
|
| MD5 |
d9fe5b5250342a939b0f53b6d78cb0f6
|
|
| BLAKE2b-256 |
982a99b9104cc9492f35a56aae72107689d66fc7d7eb5e41023b672a64e429bd
|
File details
Details for the file napari_nd2_spectral_ome_zarr-1.1.0-py3-none-any.whl.
File metadata
- Download URL: napari_nd2_spectral_ome_zarr-1.1.0-py3-none-any.whl
- Upload date:
- Size: 38.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e58faf7664cb430286be4cee002e2e2e0980eb25f38481ac59b927b03e5b19f
|
|
| MD5 |
4fa5e5bb6dab271d88e2c406ada2b55f
|
|
| BLAKE2b-256 |
ea21cbaa6178a68776852cf6b272b6a08646c558325b8993d7cfe9fa87b11a17
|