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 tasks are ImageJ/Fiji-style local contrast enhancement with
CLAHE and frictionless 2D/3D image cropping.
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 usingcv2.createCLAHE.imagej_reference: Python implementation ported from Fiji'smpicbg.ij.clahe.PlugIn2D grayscale CLAHE path. 3D stacks are processed slice-by-slice. Thefastcheckbox only affects this backend.gpu_cupy: experimental CuPy/CUDA batch backend. If CuPy or a CUDA device is not available, it falls back toopencv_cpu. It may be slower thanopencv_cpufor 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.
The OpenCV backend is faster, but it rescales the ImageJ-style maximum slope
before passing it as OpenCV clipLimit for a more ImageJ-like user experience;
maximum slope values up to 1 apply no enhancement in the OpenCV backend. 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.
Crop Image
The crop task provides a compact widget for 2D images and 3D grayscale stacks.
It is organized around four imaging workflows: crop from a drawn ROI, tile by
total tile count, tile by pixel size, and advanced coordinate cropping. A progress bar reports
saved or created crop pieces as completed / total.
The widget asks for confirmation before likely mistakes, including very tiny
crops from a large source image/stack and operations that would save more than
1000 crop TIFF files.
For detailed step-by-step crop workflows, see src/napari_em_assistant/tasks/crop_image/README.md.
For large images, choose a save folder and use either tiling workflow:
Tile by Total Count: enter the total number of output tiles wanted. The plugin chooses a near-even Y/X grid automatically and keeps full Z depth for 3D stacks. For example,6creates six image tiles.Tile by Pixel Size: save tiles with the requested output dimensions. For example, a6000 x 6000 x 500stack withz size = 0,y size = 2000, andx size = 2000writes nine500 x 2000 x 2000stack tiles.z size = 0keeps the full Z depth in every tile.
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_referencefast and exact paths - OpenCV CLAHE on synthetic
uint8anduint16images - shape preservation
- dtype preservation where possible
- 3D stack support
- GPU stub behavior
gpu_cupyCPU fallback behavior- batch result and progress reporting
Run tests with:
python3 -m pytest tests/tasks/test_enhance_local_contrast_clahe.py
Metadata
Release files for napari-em-assistant 0.2.3
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_em_assistant-0.2.3.tar.gz | 28.3 kB | Without provenance | Details for napari_em_assistant-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| napari_em_assistant-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for napari_em_assistant-0.2.3-py3-none-any.whl |
Total release size: 60.3 kB
Release files / napari_em_assistant-0.2.3.tar.gz
| Download URL | napari_em_assistant-0.2.3.tar.gz |
|---|---|
| Size | 28.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
780bafa882e421b3cab41792c806972fefc83decaa55e9613c4df6ab6cda2e15
|
|
BLAKE2b-256 checksum How to use checksums |
2a4732e3cf009b2253295ab8037891abd25262b6c0ca94ec237690d3976f165b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / napari_em_assistant-0.2.3-py3-none-any.whl
| Download URL | napari_em_assistant-0.2.3-py3-none-any.whl |
|---|---|
| Size | 32.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
09f398c6e5f1afe3ca28f0f263032623faf0176b27bb48d1bf8d221803e2f36f
|
|
BLAKE2b-256 checksum How to use checksums |
34ec5f9dc2dad9b1dd89374c22852cffc9b80238562afa3868e7a86e440f54db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for napari-em-assistant 0.2.3
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.