napari-nifti
A napari reader and writer for medical images: NIfTI, NRRD, MetaImage, MGH/MGZ and DICOM,
shown where they physically are and in the orientation radiologists expect. Despite its name it reads every
format MedVol reads; MLArray (.mla) files are opened by
napari-mlarray.
pip install napari-nifti # into an existing napari installation
pip install "napari-nifti[all]" # with napari and Qt
Drag files into napari or use File > Open. For a DICOM series, open its folder (File > Open Folder).
What you see
MedVol reads the file faithfully (its own geometry rules, every ambiguity resolved by a named policy and reported),
and napari-mlarray turns the result into layers. NIfTI, NRRD, MetaImage, MGH, DICOM and .mla files therefore look
the same and overlay correctly:
plane (viewer.dims.order) |
screen up | screen right |
|---|---|---|
axial (0, 1, 2) |
anterior | patient left (radiological) |
coronal (1, 0, 2) |
superior | patient left |
sagittal (2, 0, 1) |
superior | posterior |
- Every voxel is placed exactly from the file's geometry, whatever the storage order (axial, sagittal, flipped, RAS or LPS). The world axes point to I, P, L (labelled on the dims sliders), and the 3-D view is not mirrored.
- Oblique images are resampled onto world-aligned axes for display; rotations below a tenth of a voxel over the
image (scanner round-off) are ignored. See napari-mlarray for the
neurologicalconvention and other options. - Values are shown physically: scaling (NIfTI
scl_slope, DICOM rescale) is applied, e.g. Hounsfield units. - Label maps become Labels layers: DICOM SEG with names, colours and codes, and integer images whose values
look like class ids (0, 1, 2, ... with few gaps, at most 256 of them), such as nnU-Net or TotalSegmentator
segmentations.
napari_nifti.set_labels("never" | "always" | "auto")orNAPARI_NIFTI_LABELSchanges that. - A DICOM folder with several series or stacks opens as one layer each. MedVol's warnings (e.g. qform and sform
disagree) are shown as napari notifications; the full report is in
layer.metadata["medvol"].
Saving
File > Save Selected Layer(s) writes Image and Labels layers as .nii.gz, .nii, .nrrd, .nhdr, .mha,
.mhd, .mgz or .mgh:
- A layer opened with this plugin is written in its original array order. Saved to the format it came from, its header is kept (descriptions, extensions, custom keys); only what the image defines (geometry, size, data type) is rewritten. The layer's current position is saved, so a layer you moved stays where it is shown.
- Saved to another format, the geometry and values are converted and what the format cannot store is reported.
- New layers (labels you painted on an image) are written in the image's patient frame, so they line up with it in any other tool.
DICOM is read but not written from napari: writing a DICOM series or SEG needs the original or referenced series,
which MedVol supports from Python (medvol.write(image, "seg.dcm", reference="ct_dir/")).
Python
import napari
from napari_nifti import read_layers
viewer = napari.Viewer()
for data, kwargs, layer_type in read_layers("ct.nii.gz", nifti_form="qform"): # MedVol policies as keywords
getattr(viewer, f"add_{layer_type}")(data, **kwargs)
Development
pip install -e ".[test]"
pytest
The tests check every voxel's position for NIfTI (RAS, LPS, sagittal, mirrored) and NRRD written by nibabel and pynrrd, MetaImage and MGZ, a DICOM series, the label rule and save round trips.
License
Distributed under the terms of the Apache Software License 2.0.
This repository is developed and maintained by the Applied Computer Vision Lab (ACVL) of Helmholtz Imaging and the Division of Medical Image Computing at DKFZ.
Metadata
Release files for napari-nifti 1.0.0
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_nifti-1.0.0.tar.gz | 15.8 kB | With provenance | Details for napari_nifti-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| napari_nifti-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for napari_nifti-1.0.0-py3-none-any.whl |
Total release size: 27.7 kB
Release files / napari_nifti-1.0.0.tar.gz
| Download URL | napari_nifti-1.0.0.tar.gz |
|---|---|
| Size | 15.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4afa080c95eeb3fb00cd737e983e0fdf854fb6f2cc793085e47ff8d4531070db
|
|
BLAKE2b-256 checksum How to use checksums |
193be8941ccee9039316f4acf012201d0cdf3dd87ad56eaf7ef03d837c3f0438
|
| 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_nifti-1.0.0-py3-none-any.whl
| Download URL | napari_nifti-1.0.0-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d9f4263e6dde5a3cbdba3578aae985776e0cadc4441afd468fe7c519408b0c3
|
|
BLAKE2b-256 checksum How to use checksums |
19a310e053a1461ad817d9ba7e5ece819fe4762bdab27a356c9a9cab77f12b0c
|
| 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-nifti 1.0.0
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_nifti-1.0.0.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.