Skip to content

ariel-waisman/ROI_Threshold_Adjuster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

ROI Threshold Adjuster for FIJI/ImageJ

An interactive FIJI/ImageJ plugin for real-time classification and visualization of fluorescence microscopy ROIs based on intensity thresholds.

Overview

This plugin provides an intuitive interface to classify nuclei (or any ROIs) as positive or negative based on mean fluorescence intensity, with color-coded visualization that updates in real-time. It's particularly useful for fluorescence microscopy workflows where you need to visually identify marker-positive cells.

Features

  • Real-time threshold adjustment: Interactive slider with fine-tuning buttons
  • Multi-channel support: Independent thresholds for each channel
  • Color-coded visualization: Customizable colors for positive and negative ROIs
  • Automatic bit-depth detection: Works with 8-bit, 12-bit, and 16-bit images
  • Channel synchronization: Automatically syncs with the image channel slider
  • Log2 transformation display: Shows both linear and log2 threshold values
  • Ramping speed control: Hold buttons for progressively faster threshold adjustment
  • Customizable ROI appearance: Adjustable stroke width (1-20 pixels)
  • Dynamic image/ROI updating: Switch between images or modify ROIs without restarting the plugin
  • Real-time statistics: Live display of positive/negative counts and percentages
  • Interactive histogram: Visual distribution of ROI intensities with automatic range optimization

Requirements

  • FIJI or ImageJ
  • ROI Manager with segmented regions of interest
  • A fluorescence image (grayscale or multi-channel)

Installation

  1. Download ROI_Threshold_Adjuster.py from this repository
  2. Navigate to your FIJI installation directory
  3. Copy the file to: Fiji.app/plugins/
  4. Restart FIJI or go to Help > Refresh Menus
  5. The plugin will appear in Plugins > ROI Threshold Adjuster

Usage

Basic Workflow

  1. Open your image in FIJI (works with both single-channel and multi-channel images)
  2. Segment your regions of interest (nuclei, cells, etc.) and add them to the ROI Manager
  3. Run the plugin: Go to Plugins > ROI Threshold Adjuster
  4. Adjust the threshold using the slider or +/- buttons
  5. ROIs will automatically color-code in real-time:
    • Red (default): Positive ROIs (intensity > threshold)
    • Blue (default): Negative ROIs (intensity ≤ threshold)
  6. Monitor the histogram to visualize the intensity distribution and optimize threshold placement
  7. Check statistics in real-time to see the distribution of positive vs negative ROIs

Interface Controls

Channel Selector

  • Choose which channel to analyze in multi-channel images
  • Independent thresholds are maintained for each channel
  • Automatically syncs with the image's channel slider

Color Selectors

  • Positive color: Color for ROIs above threshold
  • Negative color: Color for ROIs below threshold
  • Available colors: Red, Blue, Cyan, Yellow, Magenta, Green, White, Gray, Dark Gray, Light Gray

Stroke Width

  • Adjust the thickness of ROI outlines (1-20 pixels)
  • Default: 5 pixels

Threshold Adjustment

  • Slider: Drag for broad adjustments
  • + / - Buttons:
    • Click for single-step changes (+1)
    • Hold for ramping speed (1 → 5 → 10 → 50 → 100 per step)
  • Range automatically adjusts based on image bit-depth:
    • 8-bit: 0-255
    • 12-bit: 0-4095
    • 16-bit: 0-65535

Threshold Display

  • Shows current threshold value
  • Displays log2 transformation in parentheses
  • Useful for comparing with log-scaled data

Histogram Display

  • Visual representation of ROI mean intensity distribution
  • Automatic range optimization: Displays the 99th percentile range (0.5th-99.5th) to exclude outliers
  • Color-coded bars:
    • Light red: ROIs above threshold (positive)
    • Light blue: ROIs below threshold (negative)
  • Threshold indicator: Red vertical line shows current threshold position
  • Dynamic updates: Histogram refreshes automatically when:
    • Threshold changes
    • Channel changes
    • Image/ROIs are updated
  • Range information: Displays the actual data range at the bottom
  • Smart axis scaling: Automatically adjusts to show the relevant intensity range
  • Out-of-range indicators: Shows messages if threshold is outside the visible histogram range

Statistics Display

  • Real-time quantification of ROI classification
  • Shows:
    • Total number of ROIs
    • Positive count and percentage
    • Negative count and percentage
  • Format: Total: 68 | Positive: 45 (66.2%) | Negative: 23 (33.8%)
  • Updates automatically when threshold, channel, or ROIs change
  • Displayed in bold for easy visibility
  • Useful for:
    • Quick assessment of marker expression levels
    • Comparing thresholds across channels
    • Documenting classification results

Update Image/ROIs Button

  • Purpose: Refresh the analysis when switching images or modifying ROIs
  • When to use:
    • After switching to a different image
    • After adding, removing, or modifying ROIs in the ROI Manager
    • After changing the active image window
  • What it does:
    • Detects the currently active image
    • Reads all ROIs from the ROI Manager
    • Clears cached intensity measurements
    • Recalculates thresholds and updates visualization
    • Refreshes statistics and histogram displays
  • Note: No need to close and restart the plugin when working with multiple images!

Tips & Tricks

  • Fine-tuning: Use the +/- buttons for precise threshold adjustments
  • Quick navigation: Use the image's channel slider—the plugin will follow automatically
  • Multi-channel analysis: Set different thresholds for different markers (e.g., DAPI, EdU, Ki67)
  • Visual optimization: Adjust stroke width for better visibility on different image sizes
  • Screenshot-ready: Choose high-contrast colors (e.g., Red/Blue or Cyan/Magenta) for publications
  • Batch analysis: Keep the plugin open and use the Update button to analyze multiple images sequentially
  • Record statistics: Take note of the percentage values for each channel to document your results
  • Threshold optimization: Watch the statistics display and histogram while adjusting the threshold to find the optimal cutoff
  • Histogram interpretation: Use the histogram to identify bimodal distributions (indicating two distinct populations) or to detect outliers
  • Use the histogram: The visual distribution helps identify natural separation points between positive and negative populations

Example Use Cases

Cell Cycle Analysis

  • Segment nuclei with DAPI
  • Use EdU or Ki67 channel to identify proliferating cells
  • Use histogram to identify the separation between positive and negative populations
  • Set threshold to distinguish positive from negative cells
  • Record the percentage of proliferating cells (e.g., "35.2% EdU+")

Marker Expression Studies

  • Segment cells or nuclei
  • Analyze expression of fluorescent markers
  • Use histogram to visualize expression level distribution
  • Quantify marker-positive vs marker-negative populations
  • Compare percentages across experimental conditions

Multi-marker Experiments

  • Analyze multiple channels independently
  • Each channel maintains its own threshold and histogram
  • Easily switch between channels to optimize classification
  • Document the percentage positive for each marker

Optimization of Threshold Settings

  • Use the histogram to identify natural cutoff points in your data
  • Observe how threshold changes affect the positive/negative ratio
  • Identify outliers that might be affecting your analysis
  • Compare intensity distributions across different experimental conditions

Technical Details

How It Works

  1. ROI Selection: The plugin reads all ROIs from the ROI Manager
  2. Intensity Measurement: For each ROI, it calculates the mean fluorescence intensity in the selected channel
  3. Classification: ROIs are classified as positive (mean > threshold) or negative (mean ≤ threshold)
  4. Visualization: ROI outlines are colored based on classification
  5. Statistics Calculation: Counts and percentages are calculated and displayed in real-time
  6. Histogram Generation: Creates a 100-bin histogram of ROI mean intensities using the 99th percentile range
  7. Caching: Mean intensities are calculated once per channel and cached for performance

Bit-Depth Detection

The plugin automatically detects image bit-depth:

  • 8-bit images: Direct detection
  • 12-bit images: Detected when max pixel value ≤ 4095
  • 16-bit images: Detected when max pixel value > 4095
  • 32-bit float: Uses 16-bit range as maximum

Histogram Range Optimization

The histogram automatically focuses on the relevant data range:

  • Uses 0.5th and 99.5th percentiles to capture 99% of the data
  • Excludes outliers from the displayed range while still counting them in statistics
  • Adds a 10% margin on each side for better visualization
  • Robust against extreme values that might skew the distribution
  • Shows the actual data range at the bottom of the histogram

Troubleshooting

Problem: "No ROI Manager found" error

  • Solution: Make sure you have ROIs loaded in the ROI Manager before running the plugin

Problem: "No image open" error

  • Solution: Open an image in FIJI before launching the plugin

Problem: ROIs don't change color

  • Solution: Ensure "Show All" is checked in the ROI Manager

Problem: Threshold seems incorrect

  • Solution: Verify you're on the correct channel; check the bit-depth of your image

Problem: Can't see ROI outlines

  • Solution: Increase stroke width or choose a higher-contrast color

Problem: Plugin shows old image/ROIs after switching

  • Solution: Click the "Update Image/ROIs" button to refresh the analysis

Problem: Statistics show 0.0%

  • Solution: Verify that ROIs are loaded and the Update button has been clicked

Problem: Histogram looks compressed or shows only a small range

  • Solution: This is normal! The histogram automatically zooms to the 99% data range to exclude outliers

Problem: Threshold line not visible in histogram

  • Solution: The threshold may be outside the visible range. Check for messages like "Threshold < [value]" or "Threshold > [value]" at the top of the histogram

Author

Ariel Waisman

  • Research Associate (Investigador Adjunto), CONICET
  • Group Leader, FLENI
  • Cardiac Stem Cell Biology & Regenerative Medicine

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

Version History

v1.3.0 (2025)

  • Added interactive histogram display with automatic range optimization
  • Histogram uses percentile-based range (99% of data) to exclude outliers
  • Color-coded histogram bars (red for positive, blue for negative)
  • Real-time histogram updates with threshold changes

v1.2.0 (2025)

  • Added real-time statistics display with counts and percentages
  • Enhanced visual feedback for classification results

v1.1.0 (2025)

  • Added "Update Image/ROIs" button for dynamic image/ROI switching
  • Improved handling of multiple images in the same session

v1.0.0 (2025)

  • Initial release
  • Multi-channel support with independent thresholds
  • Real-time color-coded visualization
  • Automatic bit-depth detection
  • Ramping speed controls
  • Log2 transformation display
  • Channel synchronization

Contact

For questions, suggestions, or collaboration inquiries, please open an issue on GitHub.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages