Skip to content

MIC-DKFZ/napari-data-inspection

Repository files navigation

Napari Data Inspection

A napari plugin for fast, high-throughput inspection of 2D/3D segmentation datasets.
Select one or more images and/or labels layers; files are paired and loaded automatically so you can browse entire datasets without manual effort.

Features

  • Multi-folder pairing: any number of image/label folders
  • Prefetching & caching for steamless navigation
  • Supports common formats (e.g., NIfTI, TIFF, PNG, NRRD, MHA, B2ND) out of the box.
  • Extensible loaders (add your own formats if needed).

Installation

# a) Install the plugin
pip install napari-data-inspection
# b) Install the plugin and napari if necessary
pip install napari-data-inspection[all]

Quickstart

napari -w napari-data-inspection

Data organization

  • Filter files by patterns (e.g., *_img.nii.gz, *_seg.nii.gz) and/or separate folders per layer.
  • Number of files must match across layers; pairs are made by sorted order.

1. Separate folders per layer

Put each layer’s files in its own directory.

/data/images/
  case001.nii.gz
  case002.nii.gz
/data/labels/
  case001.nii.gz
  case002.nii.gz

2. By Patterns

Use patterns (globs) per layer.

/data/
  case001_img.nii.gz
  case001_seg.nii.gz
  case002_img.nii.gz
  case002_seg.nii.gz

Patterns

Images: *_img.nii.gz
Labels: *_seg.nii.gz

Supported file types

The data loading is based on the ViData package. The following Extensions and Backends are available.

Extension(s) Backend(s) Notes
.png, .jpg, .jpeg, .bmp imageio Standard 2D image formats
.tif, .tiff tifffile Multipage TIFF; high bit-depths supported
.nii.gz, .nii, .mha, .nrrd sitk Medical image formats (3D volumes)
.nii.gz, .nii nibabel Alternative medical imaging backend
.b2nd blosc2 Compressed N-dimensional arrays
.b2nd blosc2pkl Compressed N-dimensional arrays with metadata in a separate .pkl
.npy numpy Single NumPy array

Custom Load Functions

  • Register a reader with a decorator.
  • Reader must return (numpy_array, metadata_dict).
  • Registration happens at import time—make sure this module is imported (e.g., from your package’s init.py).
  • See here for an example.
  • metadata should contain an "affine" if entry, if any spatial transformation should be applied
# custom_io_template.py  — fill in the TODOs and import this module somewhere at startup.
import numpy as np
from typing import Tuple, Dict, List

# TODO: import your backend library (e.g., imageio, tifffile, nibabel, SimpleITK, ...)
# import imageio.v3 as iio

from vidata.registry import register_loader, register_writer

# --------------------------- READER ------------------------------------------
# Replace file extension and backend name to your custom function
@register_loader("image", ".png", ".jpg", ".jpeg", ".bmp", backend="imageio")  # To Register Image Loading
@register_loader("mask", ".png", ".bmp", backend="imageio") # To Register Label Loading
def load_custom(file: str) -> tuple[np.ndarray, dict]:
    """
    Load a file and return (data, metadata).
    metadata can be empty or include keys like: spacing, origin, direction, shear, dtype, etc.
    """
    # data = iio.imread(file)  # example for imageio
    data = ...  # TODO: replace
    meta = {}   # TODO: replace
    return data, meta

Acknowledgments

    

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.

This napari plugin was generated with copier using the napari-plugin-template.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages