napari-bboxes
Axis-aligned 2-D and 3-D bounding boxes (detections, annotations) as napari layers that you can see in every 2-D plane and in 3-D, aligned with the image they belong to.
napari's own layers cannot do this for 3-D boxes: a Shapes rectangle lives in one plane, and a Surface mesh shows nothing in 2-D slices (only faces lying entirely in the slice are drawn). napari-bboxes draws a 3-D box as a one-voxel outline on the image grid, computed on demand: an axial, coronal or sagittal slice shows the rectangle where it cuts the box, and the 3-D view shows only the box edges, so the content inside stays visible. The array costs no memory.
pip install napari-bboxes
Usage
import napari
from napari_bboxes import add_bboxes
viewer = napari.Viewer()
image = viewer.add_image(ct, affine=ct_affine)
add_bboxes(
viewer,
mins=[[40, 60, 70], [10, 20, 30]], # inclusive corners in index coordinates of the image grid
maxs=[[60, 90, 110], [18, 35, 44]],
labels=[1, 2], # class per box
scores=[0.97, 0.41], # optional
names={1: "tumor", 2: "node"}, # optional display names
colors={1: (230, 60, 60)}, # optional; other classes get palette colours
grid_shape=ct.shape,
affine=image.affine.affine_matrix, # same index -> world transform as the image: boxes align with it
)
napari.run()
- 3-D boxes become a Labels layer: each box has its own number, coloured by class, and hovering shows
name (label) score. With labels or scores, a second layer shows that text on screen: in 2-D above the top-left corner of every box the current slice cuts (it follows the slice, the plane and 2-D/3-D switches), in 3-D at a box corner.text=Falseturns it off. - 2-D boxes become a Shapes layer of rectangles, with the same text next to each box.
bbox_layers(...)returns the same as layer data tuples(data, kwargs, layer_type), for napari readers.BoxShells(shape, bounds, mode)is the lazy outline array on its own.mode="auto"(default) draws the box surface for 2-D slices and the edges for the 3-D view;"faces"or"edges"force one of them.
Coordinates are array indices of a grid (voxel centres, inclusive bounds). Boxes in world or physical coordinates are converted by the caller: map the corners through the inverse of the image affine and take the bounding box.
Used by napari-mlarray for the boxes stored in MLArray files.
Development
pip install -e ".[test]"
pytest
License
MIT
Metadata
Release files for napari-bboxes 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| napari_bboxes-0.1.1.tar.gz | 16.0 kB | With provenance | Details for napari_bboxes-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| napari_bboxes-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for napari_bboxes-0.1.1-py3-none-any.whl |
Total release size: 27.4 kB
Release files / napari_bboxes-0.1.1.tar.gz
| Download URL | napari_bboxes-0.1.1.tar.gz |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e6ff0d113aad1d0b909fe69ddf8bb285e59d52a03b5466f21579bb94c4c1c49e
|
|
BLAKE2b-256 checksum How to use checksums |
c8fef0b74ee89acb90e0634db967c448c7849ea67192eb3fe74a89acfcd61c39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logRelease files / napari_bboxes-0.1.1-py3-none-any.whl
| Download URL | napari_bboxes-0.1.1-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e78210fe80d9aafa9f2b5d550aac23b5556b6e7e405d80e42d35a8638580b0c1
|
|
BLAKE2b-256 checksum How to use checksums |
cb3da2fcf89d6efc8dfeca3f8585f130b05b5d0144a3bac35f1897cac9459fba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logSecurity for napari-bboxes 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for napari_bboxes-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.