Skip to content
HirriririirPublic

Repository files navigation

MyoPath

MyoPath is a deep learning pipeline for objective morphometric assessment of skeletal muscle biopsies from routine H&E-stained whole slide images (WSI).

It implements a four-tissue segmentation pipeline — Cellpose-SAM for myofiber instance segmentation, a pixel classifier for fat infiltration, watershed detection for nuclei, and Boolean subtraction for connective tissue — to extract 37 morphometric features per sample. From these, seven clinically interpretable pathology indicators are derived, with Nuclear Centralization Index (NCI) and Fiber Size Variability Coefficient (Fiber CV) serving as primary biomarkers.

The pipeline has been validated on 478 H&E whole-slide images from two independent cohorts (HuashanMuscle, n = 79; GTEx, n = 399).

MyoPath Pipeline Flowchart

Data Download and Full documentation: https://myotoolkit.huashanmuscle.com/myopath/introduction.html

Data

Dataset Content Download
HuashanMuscle H&E WSI 78 de-identified whole slide images (SVS, 72.1 GB); per-slide metadata and checksums in release huashanmuscle-wsi-v1.0 Baidu Pan / OneDrive
HuashanMuscle ROI images 79 exported ROI (TIFF/JPEG + GeoJSON) Baidu Pan / OneDrive
GTEx H&E WSI 399 whole slide images GTEx Portal
GTEx ROI images 399 exported ROI (TIFF/JPEG + GeoJSON) Baidu Pan / OneDrive

The HuashanMuscle whole slide images are released under CC BY-NC 4.0. Their full-resolution pixel grid matches the ROI GeoJSON annotations; format, de-identification and coordinate details are in the dataset README attached to the release.

Key Features

  • Four-tissue segmentation: Myofiber, fat, nucleus, and connective tissue from a single H&E section
  • 37 morphometric features across five biological categories
  • Seven pathology indicators covering nuclear positioning, fiber size, shape, tissue composition, and cellular reaction
  • MyoPath Score: Composite severity measure (AUC = 0.873 on external validation)
  • Primary biomarkers: NCI (p = 1.3 × 10⁻⁵) and Fiber CV (p = 2.9 × 10⁻⁴)

Segmentation Performance

Layer Tissue Method Dice
1 Myofiber instances Cellpose-SAM 0.92
2 Fat infiltration Pixel classifier 0.95
3 Nuclei Watershed detection 0.87
4 Connective tissue Boolean subtraction 0.88

Demo Video

Watch the QuPath segmentation demo

Click the image above to watch the full QuPath segmentation walkthrough.

Pipeline Overview

Step Script Platform What it does
1 MyoPath1_roi.groovy QuPath Create a standardized 1500 µm × 1500 µm ROI
2 MyoPath2_segment.groovy QuPath Segment muscle fibers (Cellpose-SAM), fat (pixel classifier), nuclei (watershed)
3 MyoPath3_export.groovy QuPath Export ROI image (TIFF/JPEG) + annotations (GeoJSON)
4 MyoPath4_analysis.py Python Batch tissue analysis, visualization, and dystrophy report

Requirements

QuPath (Steps 1–3)

  • QuPath 0.6.0+
  • Cellpose extension — configure the Cellpose and Cellpose SAM Python paths in Edit → Preferences → Cellpose/Omnipose
  • GPU recommended for Cellpose segmentation

Python (Step 4)

  • Python 3.9+
  • Conda environment recommended

Installation

# Clone the repository
git clone https://github.com/Hirriririir/MyoPath.git
cd MyoPath

# Set up Python environment
conda create -n myopath python=3.10 -y
conda activate myopath
pip install -r requirements.txt

# Verify installation
python -c "import tiatoolbox, numpy, scipy, matplotlib, shapely, pandas; print('All dependencies OK')"

Project Structure

MyoPath/
├── MyoPath1_roi.groovy              # Step 1: Create standardized ROI
├── MyoPath2_segment.groovy          # Step 2: Three-layer tissue segmentation
├── MyoPath3_export.groovy           # Step 3: Export ROI image + annotations
├── MyoPath4_analysis.py             # Step 4: Batch analysis orchestrator
├── classifiers/
│   ├── classes.json                 # QuPath path class definitions
│   └── pixel_classifiers/
│       ├── Fat in muscle.json       # Required pixel classifier
│       └── ...                      # Other optional classifiers
├── src/
│   ├── __init__.py
│   ├── data_loader.py              # WSI and GeoJSON data loading
│   ├── coordinate_processor.py      # Coordinate transformation
│   ├── tissue_analyzer.py           # Multi-tissue area analysis
│   ├── visualizer.py                # Segmentation visualization
│   └── dystrophy_analyzer.py        # Pathology indicators & scoring
├── exports/                         # Step 3 output (per-sample)
├── results/                         # Step 4 aggregated output
├── requirements.txt
├── LICENSE
└── README.md

Usage

Step 1 — Create ROI

Open your slide in QuPath and run MyoPath1_roi.groovy to create a standardized 1500 µm × 1500 µm ROI.

Step 1 — ROI created in QuPath

Step 2 — Segment Tissues

Select the ROI and run MyoPath2_segment.groovy. Three-layer segmentation completes automatically.

Step 2 — Segmentation result

Step 3 — Export Data

Select the ROI and run MyoPath3_export.groovy to export ROI image and GeoJSON annotations.

Step 3 — Exported files

Step 4 — Batch Analysis

Step 4 — Three-view comparison output

# Test with a single sample
python MyoPath4_analysis.py --test HE_M3669

# Process all samples
python MyoPath4_analysis.py --all --cores 16

# Process specific samples
python MyoPath4_analysis.py --samples HE_M1600,HE_M2806

# Custom directories
python MyoPath4_analysis.py --all --input /data/exports --output /data/results

# Debug mode
python MyoPath4_analysis.py --test HE_M3669 --sequential --verbose

CLI Options

Flag Default Description
--test NAME — Test a single sample
--samples A,B — Process specific samples (comma-separated)
--all — Process all samples in exports/
--input DIR ../exports Exports directory path
--output DIR ../results Results directory path
--cores N 10 CPU cores for parallel processing
--sequential off Single-process mode (for debugging)
--verbose off Detailed logging

Output

exports/{sample_name}/
├── {sample}_statistics.json             # Tissue area statistics
├── {sample}_dystrophy_report.json       # Full pathology report
├── original_image.png                   # H&E image
├── standard_segmentation.png            # 4-tissue overlay
├── muscle_fiber_colormap.png            # Individual fiber colors
└── three_view_comparison.png            # Side-by-side comparison

results/
└── batch_analysis_summary.json          # Batch processing summary

Dystrophy Report

The JSON report includes 7 pathology indicators and an overall MyoPath Score (0–100):

Indicator Normal Range What it measures
Nuclear Centralization Index (NCI) < 0.03 Nuclei migrating to fiber center
Fiber Size Variability (CV) < 0.25 Size heterogeneity
Fiber Shape Regularity > 0.7 Shape abnormality
Fat Infiltration < 5% Fat tissue percentage
Fibrosis < 10% Connective tissue percentage
Nuclear/Muscle Ratio 1–3 Nuclei inside muscle fibers
Inflammatory Infiltration < 2,000/mm² Nuclear density in connective tissue
Score Range Severity
0–20 Normal / Minimal
20–40 Mild
40–60 Moderate
60–100 Severe

Key Parameters (Step 2)

Parameter Default Description
expectedDiameterMicrons 80 Expected myofiber diameter (µm)
downsample 10.0 Segmentation resolution control
splitThreshold 0.1 Fat classifier threshold
threshold — Hematoxylin channel detection threshold for nuclei

Troubleshooting

Cellpose TileFile null error: Increase downsample (e.g., 12.0 or 15.0).

No muscle fibers detected: Ensure ROI covers muscle tissue; try lowering cellprobThreshold (e.g., from 0 to −2).

Python ModuleNotFoundError: Run from the MyoPath/ directory, or use --input to specify the exports path.

Conda An unexpected error has occurred: Known conda 25.7.0 bug on Windows with GBK encoding. Does not affect results. Suppress with: CONDA_NO_PLUGINS=true conda run -n myopath python MyoPath4_analysis.py --all

Out of memory: Reduce --cores (each sample uses ~2–4 GB RAM).

Citation

Zhong H*, Gao M*, Ma S, Zhang W, Cheng N, Jiao K, Zhu B, Song J, Yan C, Yue D, Xi J, Du Z, Zhu W, Zhao C#, Luo S#. MyoPath: A deep learning pipeline for objective morphometric assessment of skeletal muscle biopsies. Journal of Pathology Informatics. 2026;100747. doi:10.1016/j.jpi.2026.100747

@article{zhong2026myopath,
  title   = {MyoPath: A deep learning pipeline for objective morphometric assessment of skeletal muscle biopsies},
  author  = {Zhong, Huahua and Gao, Mingshi and Ma, Shang and Zhang, Wenhan and Cheng, Nachuan and Jiao, Kexin and Zhu, Bochen and Song, Jie and Yan, Chong and Yue, Dongyue and Xi, Jianying and Du, Zunguo and Zhu, Wenhua and Zhao, Chongbo and Luo, Sushan},
  journal = {Journal of Pathology Informatics},
  pages   = {100747},
  year    = {2026},
  doi     = {10.1016/j.jpi.2026.100747}
}

License

MIT License.

Releases

Packages

Contributors

Languages