napari-worm-neuron-annotator
napari-worm-neuron-annotator is a napari plugin for navigating neuron bounding-box
ROIs and controlling the visibility of checked IDs in a Labels layer.
The plugin treats the two representations differently:
- the ROI array is the authoritative neuron identity and box geometry;
- the
Labelslayer is a display context in which label valueneuron_id + 1represents a zero-based neuron ID; - napari
Vectorslayers are generated at runtime to show overlapping boxes without writing them into a dense integer mask.
Original ROI arrays and Labels data are never modified.
Features
- Checkable neuron list with a distinct active neuron.
- All/None controls and cumulative Q/W navigation.
- Independent opacity for checked and unchecked Labels.
- Exact RGB preservation when changing alpha.
- Read-only loading of
neuron_pt_tuple.npy. - Dynamic 2D bounding rectangles on the current z slice.
- Dynamic 3D 12-edge wireframes for the current volume.
- Active-neuron highlighting and view centering.
- Zero-copy Z-layer display synchronized across Image, Labels, and boxes.
- Zero-based ROI annotation with optional Excel import/export.
- Automatic restoration of the original Labels colormap and opacity when the widget closes or switches to another Labels layer.
Installation
Install into an existing napari environment:
pip install napari-worm-neuron-annotator
For a fresh environment, install napari with its default Qt 6 backend:
pip install "napari-worm-neuron-annotator[all]"
Excel support alone is available through:
pip install "napari-worm-neuron-annotator[excel]"
The base plugin does not install or select a Qt binding. The napari
environment owns the Qt backend; the convenience all extra delegates that
choice to napari.
This release targets Python 3.11–3.14 and napari 0.8.x. See the napari 0.8 migration notes for the dependency and compatibility decisions.
Basic Labels workflow
- Open a
Labelslayer. - Open
Plugins > Worm Neuron Annotator. - Select the Labels layer in the widget.
- Click a row to check and activate that ID.
- Use the checkbox column to add or remove IDs from the persistent set.
- Use Q and W to check and activate the previous or next valid ID without clearing IDs already checked.
- Use All or None to check every ID or clear all checked/active IDs.
The active row is bold and remains the current row. Unchecking the active ID clears the active state; unchecking another ID does not change the active neuron.
The Labels Layer panel also controls checked and unchecked label alpha.
The defaults are 0.50 for checked labels and 0.00 for unchecked labels.
Hide the entire mask with the normal eye icon in napari's layer list. The
original Labels colormap and opacity are restored automatically when the
widget closes or switches to another Labels layer.
For small in-memory arrays, IDs are discovered exactly from the Labels data. The plugin intentionally does not scan out-of-core arrays or arrays larger than 10 million voxels. Load an ROI NPY file in those cases.
Labels-only discovery cannot recover an identity that has already been completely overwritten in a dense mask.
Z-layer display
The compact Z Layers panel separates a 3D volume along Z so individual depth ranges can be rendered without the other ranges obscuring them:
- Select a compatible Image layer.
- Inspect the current-time curve showing how many pixels in each Z slice are
strictly above the editable threshold (default
170). Click the curve to add or remove a cut, or enter explicit cuts such as4,10. - Click Split.
- Use Show to select
Allor one generated layer.
Cuts use half-open Python ranges. For a volume with 18 Z slices, 4,10
creates [0,4), [4,10), and [10,18). A boundary slice belongs to the
following layer.
All displays every generated Image layer using additive blending, the complete Labels layer, and all currently valid checked boxes. Layer k displays only that Image range, the corresponding read-only Labels slice, and boxes whose center Z belongs to the range. A box that crosses a cut is shown whole in the one layer containing its center.
Checked and active neuron identities remain global. In an individual layer, Q/W navigates only neurons assigned to that layer; other neurons remain in the list, are shown in gray, and keep operable checkboxes. Activating a gray row does not move the view outside the selected Z layer.
Generated Image layers use slices of NumPy arrays, memory maps, or Dask
arrays rather than full-size zero-filled copies. Direct Zarr arrays should
be wrapped as Dask arrays before splitting. The Image and Labels sources
must have matching (z,y,x) or (t,z,y,x) shape, axis labels, scale,
translation, and units, with axis-aligned volume depiction and no clipping
planes. Clear removes all generated Z layers and restores the original
source visibility. Normal napari eye icons may still override visibility
until the next Show selection.
Launch the validated 20260417_w2 dataset
The repository includes a ready-to-use launcher for the local validation dataset:
pixi run launch-actual
It memory-maps volumes.npy, neuron_mask.npy, and
neuron_point_tuple.npy, opens napari, docks the navigator, and loads all
138 ROI identities automatically.
ROI input format
The ROI loader accepts a numeric NumPy array with shape:
(T, N, K), K >= 6
The first six fields are:
x_center, y_center, z_scaled, width, height, depth_scaled
Additional fields are ignored. The neuron ID is the index on the N axis:
neuron_id = 0 ... N - 1
label_value = neuron_id + 1
background label_value = 0
NaN, infinite values, non-positive sizes, and time points outside the source array are treated as missing observations. Missing neurons remain in the checkable list so that their global identity is stable, but Q/W skips them at the current time point.
Coordinate and time mapping
The plugin assumes the controlled Labels layer has one of these axis orders:
(z, y, x)
(t, z, y, x)
z_divisor, defaulting to 5, converts source z and depth coordinates:
z_index = z_scaled / z_divisor
depth_in_slices = depth_scaled / z_divisor
For a viewer that displays a cropped or strided time range:
source_t = volume_start + viewer_t * volume_stride
Configure volume_start and volume_stride before loading the NPY.
The derived ROI overlay layers copy scale, translation, axis labels, and units from the controlled Labels layer. Do not apply the z scale a second time in the ROI coordinates.
2D and 3D box display
Two managed Vectors layers are created after loading an ROI file:
Neuron boxes – selected: checked, currently valid boxes at low opacity;Neuron box – active: the active box with a thick yellow outline.
Initially only the first valid neuron is checked and active. All includes all IDs in the selected layer, while None empties both box layers and the optional text overlay. Checked identities that are missing at the current time remain checked but are temporarily omitted from the geometry.
Enable Show selected box labels to place one text label at the center of
each currently rendered checked box. The text uses the annotation table's
biological value when present and otherwise falls back to the zero-based
neuron_id. The third annotation column is not used for box labels. The
option is off by default. Use Text color to choose a session-only label
color that contrasts with the current Image colormap.
In 2D mode, the plugin draws four rectangle edges only when the current z slice intersects the box's half-open z range.
In 3D mode, each box is represented by 12 vector edges. Overlapping boxes
remain independent vector records with a neuron_id feature. They may overlap
visually, but one box does not erase the identity of another.
Vectors and the transparent Points text layer are derived display data. They are removed when the ROI is unloaded or the widget closes and are not saved as a separate annotation format.
Annotation
In ROI mode, the digital column always stores the zero-based neuron_id.
In Labels-only mode, it stores the raw Labels value.
The table automatically follows the current identities. Existing biological
names and annotation text are preserved by identity when the source changes.
Activating a neuron selects its annotation row. Selecting a table row checks
and activates the corresponding neuron without clearing other checked IDs.
The biological value is also displayed in the neuron list.
The complete navigator is vertically scrollable when the napari dock is shorter than its controls.
Excel operations support .xlsx workbooks. Saving and loading do not apply an
implicit +1 or -1 conversion.
Development
Run tests and lint from the repository root:
pixi run pytest -q
pixi run -e excel pytest -q
pixi run ruff check .
The repository uses a src layout. Pure ROI parsing and geometry live in
src/napari_worm_neuron_annotator/_roi.py; Qt and napari lifecycle behavior
live in src/napari_worm_neuron_annotator/_widget.py.
License
Distributed under the BSD-3-Clause license.
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_worm_neuron_annotator-0.2.0.tar.gz.
File metadata
- Download URL: napari_worm_neuron_annotator-0.2.0.tar.gz
- Upload date:
- Size: 103.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bd12f44131db2467c8e5ae62226c04281ef03178109fcdaf22c1a715d32b6cb
|
|
| MD5 |
b337a4111d83916542622cd531e7ecc8
|
|
| BLAKE2b-256 |
68f712f8f265bb6f11c681656f6c70dc5b36246081c11014a6f89fc000406f84
|
Provenance
The following attestation bundles were made for napari_worm_neuron_annotator-0.2.0.tar.gz:
Publisher:
release.yml on Wenlab/napari-worm-neuron-annotator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
napari_worm_neuron_annotator-0.2.0.tar.gz -
Subject digest:
5bd12f44131db2467c8e5ae62226c04281ef03178109fcdaf22c1a715d32b6cb - Sigstore transparency entry: 2287686869
- Sigstore integration time:
-
Permalink:
Wenlab/napari-worm-neuron-annotator@6a80460671c893d547822f00ea59b0bff51e01e3 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Wenlab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6a80460671c893d547822f00ea59b0bff51e01e3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file napari_worm_neuron_annotator-0.2.0-py3-none-any.whl.
File metadata
- Download URL: napari_worm_neuron_annotator-0.2.0-py3-none-any.whl
- Upload date:
- Size: 45.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d75adabf5b2c59ca28782114d67afa2e9747f0090b9cceea7684a6adbbe2625
|
|
| MD5 |
0bd1270acc81d15ecfe1abc7019a0d9e
|
|
| BLAKE2b-256 |
a7efacdfdfcfff9440b0a62263be3d048b56421e8889313f7a599a9c8fdfeb19
|
Provenance
The following attestation bundles were made for napari_worm_neuron_annotator-0.2.0-py3-none-any.whl:
Publisher:
release.yml on Wenlab/napari-worm-neuron-annotator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
napari_worm_neuron_annotator-0.2.0-py3-none-any.whl -
Subject digest:
5d75adabf5b2c59ca28782114d67afa2e9747f0090b9cceea7684a6adbbe2625 - Sigstore transparency entry: 2287686945
- Sigstore integration time:
-
Permalink:
Wenlab/napari-worm-neuron-annotator@6a80460671c893d547822f00ea59b0bff51e01e3 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Wenlab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6a80460671c893d547822f00ea59b0bff51e01e3 -
Trigger Event:
release
-
Statement type: