GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Falah-Jabar-Rahim/WSI-QCN: A command-line pipeline for running and comparing stain-normalization methods on histology (H&E) images.

BranchesTags
Open more actions menu

Latest commit

 

History

55 Commits
55 Commits

Folders and files

NameName
Last commit message
Last commit date
color_conversion
color_conversion
 
 
data
data
 
 
figs
figs
 
 
methods
methods
 
 
results
results
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
__init__.py
__init__.py
 
 
adv_pix2pix.py
adv_pix2pix.py
 
 
batch_runner.py
batch_runner.py
 
 
custom_layers.py
custom_layers.py
 
 
cycle_gan.py
cycle_gan.py
 
 
environment.yml
environment.yml
 
 
main.py
main.py
 
 
normalize_stain_v2.py
normalize_stain_v2.py
 
 
pix2pix.py
pix2pix.py
 
 
requirements.txt
requirements.txt
 
 
sastaindiff_normalizer_v2.py
sastaindiff_normalizer_v2.py
 
 
test_installation.py
test_installation.py
 
 
tf_gan_normalizer.py
tf_gan_normalizer.py
 
 

Repository files navigation

WSI-QCN

WSI-QA

The pipeline begins with an input whole-slide image (WSI), followed by a quality assessment (QA) stage that identifies and retains high-quality tissue tiles while excluding low-quality regions affected by artifacts, blur, background, or insufficient tissue content. The selected tiles are then processed using one of 12 color normalization methods, including traditional approaches (Ruifrok, Vahadane, Histogram Matching, Mean-Std, Macenko, Reinhard, and Multi-Macenko) and deep learning-based methods (StainGAN, StainNet, Sastaindiff, CycleGAN, and Pix2Pix), to reduce stain variability and improve color consistency. The resulting normalized images provide standardized inputs for a wide range of deep learning-based computational pathology tasks, such as nuclei detection, segmentation, classification, and quantitative analysis.

This pipeline consists of two sequential steps designed to generate high-quality, standardized H&E image tiles for downstream deep learning applications.

1. Quality Assessment (QA)

The quality assessment model is first applied WSI-SmartTiling or WSI-QA to the whole-slide images (WSIs) to identify and remove low-quality regions (e.g., background, blur, artifacts, or out-of-focus areas). Only high-quality tissue tiles are retained and exported for the next preprocessing stage.

2. Color Normalization (ColorNorm)

The retained image tiles are then processed using the color normalization pipeline provided in this repository. This step reduces stain and color variability across H&E images, producing standardized image tiles that can be directly used for downstream tasks such as nuclei detection, segmentation, classification, and quantitative analysis.

Setting Up the Pipeline:

  1. System requirements:
  • Ubuntu >= 20.04
  • CUDA version >= 12.2
  • Python version >= 3.9
  • Anaconda version >= 23.7.4
  1. QA:
  • For WSI quality assessment and tile generation, refer to WSI-SmartTiling
  1. ColorNorm:
  • Clone the repo
git clone https://github.com/Falah-Jabar-Rahim/WSI-QCN.git
cd WSI-QCN
  • Create the conda environment
conda create -n WSI-QCN python=3.10
conda activate WSI-QCN
pip install -r requirements.txt

Note: PyTorch version should matches your CUDA driver. Check your CUDA version with nvidia-smi, then follow the official installation guide

  1. Verify Installation
  • Run the following command to verify that all dependencies have been installed correctly:
python test_installation.py

Color Normalization Methods

name mode framework needs a target/reference needs a checkpoint
ruifrok sequential numpy yes (target) no
vahadane sequential numpy yes (target) no
histogram_matching sequential numpy yes (target) no
mean_std sequential numpy no no
macenko sequential torch yes (target) no
reinhard sequential torch yes (target) no
multi_macenko sequential torch yes (targets) no
staingan batch torch no yes
stainnet batch torch no yes
sastaindiff batch torch no yes
cyclegan batch tensorflow no yes
densepix2pix batch tensorflow no yes

Run python main.py --list to see this from the CLI, with each method's mode. The input tile dimensions should be divisible by 2; otherwise, some deep-learning methods may not work correctly.

Pretrained Model Checkpoints

The pretrained model checkpoints are available on Hugging Face: WSI-QCN Checkpoints

Download the required checkpoint files and place them in the corresponding directories:

WSI-QCN/
├── methods/
│   ├── GanStainNorm/
│   │   └── checkpoints/
│   ├── SAStainDiff/
│   │   └── checkpoint/
│   └── StainNet/
│       └── checkpoints/

Ensure that each checkpoint is copied into the appropriate folder before running the pipeline.

  • Input images: Place your input images in data/input/<your_folder>/, then set source_directory in main.py or specify the folder using the --input-dir argument.
  • Reference (target) images: For stain normalization methods that require a reference image (ruifrok, vahadane, histogram_matching, macenko, and reinhard), place the reference image(s) in data/reference/.

Usage

Run everything:

python main.py

Run one method:

python main.py --method stainnet

List available methods:

python main.py --list

Override the batch size (batch-capable methods only - ignored for sequential ones):

python main.py --method sastaindiff --batch-size 2

Override input/output folders:

python main.py --input-dir data/input/my_images --output-dir results/run_1

Combine as needed:

python main.py --method all --batch-size 8 --input-dir data/input/test_set

Output

Each method writes to its own subfolder, so the same image can be compared across methods:

results/
    macenko_torch/img001.png
    stainnet/img001.png
    cyclegan/img001.png
    ...

Citation:

TBD

Contact:

If you have any questions or comments, please feel free to contact: [email protected]

About

A command-line pipeline for running and comparing stain-normalization methods on histology (H&E) images.

Topics

artifact-detectionartifact-removalcolor-normalizationcomputational-pathologycomputer-visiondeep-learningdigital-pathologyhistopathology-image-analysismedical-imagingquality-assessmentquality-assessment-frameworkstain-normalizationwhole-slide-imageswsi-quality-assessmentwsi-quality-control

Resources

Readme
MIT license
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.