Skip to main content

AutomaticRange

An open‑source, reproducible intensity‑scaling method that leverages the nuclear signal as an anchor to calibrate per‑channel contrast.

Prerequisites

  • Python 3.8 (3.7 should work)
  • Python libraries:
    • pathlib
    • napari
    • numpy
    • tifffile
    • torch
    • scipy
    • scikit-image

Setup

  • Download the github repository (> Code > Download ZIP)
  • Unzip it in the given location
  • In the AutomaticRange folder, create a data/ and a annotation/ folder
  • Place the tiles to annotate into data/ folder (e.g. data/CD4/ which contains tiles_marker/ and tiles_dapi/)
  • Open VisualStudio IDE and File > Open Folder and open AutomaticRanges
  • Open the 2.0_Annotate_ranges_tiles.ipynb jupyter notebook
  • Click on Run All. This will open Napari. Then, manually adjust the range of the first image, and then press Shift + B to save annotation and go to next image. There are a few key shortcuts that can help you adjust the range faster.

Key shortcuts

  • Shift + A = reduce the minimum contrast by 10%

  • Shift + S = increase the minimum contrast by 10%

  • Shift + Q = reduce the maximum contrast by 10%

  • Shift + W = increase the maximum contrast by 10%

  • Shift + B : Save manually set range and go to next image available. If there are no more images available, this will not do anything. It means you are finished !

Annotation Strategy

  • Go as low as possible to see if there is signal enrichment in the nucleus or cell membrane.
  • If you find signal : adjust so that the noise is as low as possible but the cell signal is as clear as possible.
  • As much as possible, regions devoid of cells should be black.
  • Avoid saturating signal in cells, but privilege seeing positive signal.

Introduction

Multiplex fluorescence histochemistry (MxIF) generates large, high-dimensional TIFF images of tissue sections stained for multiple markers (e.g. CD4, nuclear stains), serving as foundational data for modern single-cell analyses. However, raw MxIF images are plagued by variable intensity ranges, heterogeneous signal-to-noise ratios, cell‑density fluctuations, and frequent artifacts such as bright spots, blurs, or folds. Under standard visualization tools (e.g. napari / FIJI), the built‑in “automatic” intensity scaling often fails to reveal biologically relevant patterns—CD4 around nuclei, for instance—forcing users to spend considerable time manually adjusting contrast ranges on each image or region to achieve clarity. This ad hoc manual adjustment is subjective, non‑reproducible, and hard to scale. Notably: 1. Human variability: Different users produce diverging contrast settings depending on their tolerance or strategy—some may avoid bright artifacts at the expense of dim but valid signals, while others may favor sensitivity but introduce spurious noise. 2. Training/annotation bias: Data used for AI model training (e.g. cell segmentation, classification, positive‑marker detection) becomes inconsistent. Varying input contrast can dramatically alter what appears as a signal or background, potentially skewing both annotations and downstream model performance. 3. Spatial heterogeneity: Large tissue scans often contain both dense and sparse regions—tone‑mapping tuned to a dense region typically underexposes signal in sparse areas, and vice versa. This intra‑image inconsistency further undermines reproducibility. Prior work has long acknowledged that arbitrary auto‑contrast settings can distort quantitative interpretation. For instance, converting 16‑bit images to 8‑bit with independent autoscaling leads to intensity-shift artifacts—two tissues with the same raw content might be visually scaled to identical brightness despite underlying differences embopress.org. Similarly, fixed global thresholds are known to fail in heterogeneous settings, and mitigation strategies like histogram equalization (e.g. CLAHE) offer partial solutions, but lack adaptability across complex MxIF scans . Feature-level normalization pipelines such as z‑score standardization, ComBat, MxNorm, and FLINO address batch effects based on summary features, but are unable to fully reconcile the pixel-wise heterogeneity seen in MxIF images pmc.ncbi.nlm.nih.gov. While methods such as UniFORM aim for unified normalization at the pixel and feature levels, they are tailored for whole‑image batch correction rather than interactive, per-region visualization, and do not directly inform the display scaling needed during image annotation. Thus, without automated, objective contrast scaling, researchers: • Waste hours on manual tuning. • Introduce population bias into annotation datasets. • Risk missing low-intensity bona fide signals—or accepting false positives. To overcome these limitations, we introduce AutomaticRange, an open‑source, reproducible intensity‑scaling method that leverages the nuclear signal as an anchor to calibrate per‑channel contrast. AutomaticRange dynamically computes intensity limits at the region-of-interest and global-image levels—excluding artifacts and factoring cell density—and adapts contrast scaling in a statistically consistent manner. We demonstrate that AutomaticRange: 1. Reduces manual setup time from minutes per image to seconds. 2. Improves uniform visibility across heterogeneous tissue regions. 3. Increases reproducibility across annotators and imaging sessions. 4. Preserves biological features critical for downstream AI models (segmentation, marker detection, cell-type classification). In the following, we describe the algorithmic design of AutomaticRange, validate its performance relative to standard autoscaling in napari and FIJI, and assess its impact on human annotations and downstream model accuracy.

napari-automatic-range

Overview

The napari-automatic-range plugin provides a simple interface for performing automatic range predictions on images using a trained model. It integrates seamlessly with the Napari viewer, allowing users to easily apply the predict_range function to their images.

Features

  • Button labeled "AutomaticRange" to execute the prediction on the current image.
  • Automatically finds the first DAPI image in the viewer for processing.
  • Displays the normalized image in the Napari viewer.

Installation

To install the plugin, clone the repository and install the required dependencies:

git clone https://github.com/yourusername/napari-automatic-range.git
cd napari-automatic-range
pip install -r requirements.txt

Usage

  1. Launch Napari.
  2. Load your images into the viewer.
  3. Click the "AutomaticRange" button in the plugin interface.
  4. The normalized image will be displayed in the viewer.

Requirements

  • Napari
  • PyTorch
  • NumPy
  • SciPy
  • scikit-image

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any enhancements or bug fixes.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for AutomaticRange 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for AutomaticRange 0.1.6
File Size Uploaded Provenance
automaticrange-0.1.6.tar.gz 25.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for AutomaticRange 0.1.6
File Interpreter ABI Platform
automaticrange-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 49.8 kB

Release files / automaticrange-0.1.6.tar.gz

Download URL automaticrange-0.1.6.tar.gz
Size 25.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cd90b36143ea7b7b0790376cefbfeb556bf380af79efc033e88f1c8eb46ab0b3
BLAKE2b-256 checksum
How to use checksums
8f2e18cfe909619c9b9b76626a0ba3a2b81806a53a9205fb9d6090a3ed6e0c87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.18

Release files / automaticrange-0.1.6-py3-none-any.whl

Download URL automaticrange-0.1.6-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a5b30bf0c0f0f1b05720406b97766b7a9098f4c9b1fedec942f7c2836df498ca
BLAKE2b-256 checksum
How to use checksums
2c3f0a028957a43c7540ef0f73b5631af2f92483a41cd6f22e912854c676e695
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.18

Security for AutomaticRange 0.1.6

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page