Skip to main content

Task-based EM image processing assistant for napari

Project description

napari-em-assistant

Task-based electron microscopy image processing tools for napari.

napari-em-assistant is organized around small, explicit processing tasks that can be used interactively on an active napari layer or applied to folders of EM images. The first task is ImageJ/Fiji-style local contrast enhancement with CLAHE.

Current Task

Enhance Local Contrast CLAHE

The CLAHE task provides a napari widget for 2D grayscale EM images and 3D grayscale stacks. It follows the ImageJ/Fiji dialog shape and default values:

  • block size: 127
  • histogram bins: 256
  • maximum slope: 3.00
  • mask: *None*
  • fast: checked

The widget can:

  • show a top acceleration bar for CPU, CUDA via CuPy, or CPU fallback
  • preview CLAHE on the active image layer
  • apply CLAHE to the active 2D image layer or 3D grayscale stack
  • create a new layer named <source_layer_name>_CLAHE
  • batch process TIFF folders to an output folder
  • show batch progress with load/process checks, status, and output path

Backends

  • opencv_cpu: fast CPU approximation using cv2.createCLAHE.
  • imagej_reference: Python implementation ported from Fiji's mpicbg.ij.clahe.PlugIn 2D grayscale CLAHE path. 3D stacks are processed slice-by-slice. The fast checkbox only affects this backend.
  • gpu_cupy: experimental CuPy/CUDA batch backend. If CuPy or a CUDA device is not available, it falls back to opencv_cpu. It may be slower than opencv_cpu for many current workloads because the implementation pays GPU transfer overhead and is not yet a fully optimized CUDA CLAHE kernel.

The acceleration bar shows the active mode for the selected backend. Detailed CuPy/OpenCV CUDA availability is still available in the tooltip for diagnostics.

OpenCV CLAHE parameters are not identical to ImageJ/Fiji CLAHE parameters. Use imagej_reference when Fiji-style output is the priority. Current OpenCV and CuPy paths should be treated as practical approximations.

Install

From this repository:

pip install -e .

Optional CuPy support depends on the workstation CUDA stack. A convenience extra is provided:

pip install -e ".[gpu]"

If that wheel does not match the local CUDA runtime, install the correct CuPy package manually and keep the base plugin install CPU-only.

Use In napari

After installation, open napari and choose:

Plugins > Enhance Local Contrast CLAHE

For interactive use, select a 2D grayscale image layer or 3D grayscale stack and use Preview or Apply to Active Layer.

For batch use, choose an input folder containing 2D images or 3D grayscale stacks saved as .tif or .tiff files, choose an output folder, select a backend, and run the batch. Outputs are saved as:

<stem>_clahe.tif

Validation

The current implementation is tested for:

  • widget and backend imports
  • Fiji-derived imagej_reference fast and exact paths
  • OpenCV CLAHE on synthetic uint8 and uint16 images
  • shape preservation
  • dtype preservation where possible
  • 3D stack support
  • GPU stub behavior
  • gpu_cupy CPU fallback behavior
  • batch result and progress reporting

Run tests with:

python3 -m pytest tests/tasks/test_enhance_local_contrast_clahe.py

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

napari_em_assistant-0.2.2.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

napari_em_assistant-0.2.2-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file napari_em_assistant-0.2.2.tar.gz.

File metadata

  • Download URL: napari_em_assistant-0.2.2.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for napari_em_assistant-0.2.2.tar.gz
Algorithm Hash digest
SHA256 c9bb3e7f03091738e720de0d8c1df001cb714c8d0664f69f5db0d54bdd0c03ae
MD5 879bf972b839b6503d6d7c6cf270047e
BLAKE2b-256 7992b2d7edad18d8253dda6caa3bcedc04b2069f9188020944deaf0e589eb3f4

See more details on using hashes here.

File details

Details for the file napari_em_assistant-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for napari_em_assistant-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 605b7dbe0f7bcf5a649605c2261e715e80273cac128489745ad8bcc4a57278b9
MD5 182b5477651a33402f54eb95068ab91d
BLAKE2b-256 25d8a0bd2b7dde9c606a8a69e27e49d204393d2e076093a95a52cfeedfddbea8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page