Skip to main content

Breast ultrasound benign-malignant diagnosis with segmentation-assisted multi-task learning.

Project description

JwzTumor

PyPI version PyPI downloads Python License

Breast ultrasound benign-malignant diagnosis with segmentation-assisted multi-task learning.

Overview

JwzTumor implements LABDG-Pre + DGBC-MTLNet + MPTC-Head, a multi-task system for breast tumor diagnosis from ultrasound images:

  • LABDG-Pre: Lesion-aware boundary-preserving domain-generalized preprocessing
  • DGBC-MTLNet: Domain-generalized boundary-context collaborative multi-task network (CNN-Mamba hybrid)
  • MPTC-Head: Morphology-prompted topology-consistent classification head (4-stream)

The system outputs: classification probability, segmentation mask, edge map, SDM, uncertainty map, and explainability visualizations.

Project Structure

jwz-tumor/
  pyproject.toml
  configs/          # 8 YAML configs
  dataset/          # BUSBRA + BUSI data
  src/JwzTumor/
    data/           # Datasets, preprocessing, augmentation, cache, audit, collate
    models/         # LABDG-Pre, DGBCEncoder, MPP, decoder, MPTC-Head
    losses/         # 7 loss modules + factory
    training/       # Stage trainer, scheduler, callbacks
    inference/      # Predictor, TTA, postprocessing, visualization
    evaluation/     # Classification + segmentation metrics
    cli/            # 6 CLI commands
    utils/          # Config, seed, logging, I/O, registry
  tests/            # 12 test files

Datasets

BUSBRA (Training)

  • Images: bus_{id}-{side}.png, Masks: mask_{id}-{side}.png
  • Labels: bus_data.csv (Pathology: benign/malignant)
  • CV: 5-fold-cv.csv or 10-fold-cv.csv
  • Case-level splitting (no leak)

BUSI (Testing)

  • Directory-based: benign/, malignant/
  • Skip: normal-不使用/
  • Multi-mask: OR union in original size before resize
  • RGB images converted to grayscale

Installation

# Install from PyPI
pip install JwzTumor

# Using uv
uv pip install -e .

# Development
uv pip install -e ".[dev]"

Quick Start

# Show version
jwzt version

# Export config template
jwzt get --name train_full --output configs/my_config.yaml

# Train
jwzt train --config configs/train_full.yaml --experiment-name exp001 --fold 1

# Stage-specific training
jwzt train --config configs/train_pretrain_pre.yaml --stage pretrain_pre --fold 1
jwzt train --config configs/train_pretrain_seg.yaml --stage pretrain_seg --fold 1
jwzt train --config configs/train_cls_head.yaml --stage train_cls --fold 1
jwzt train --config configs/train_finetune.yaml --stage finetune_all --fold 1

# Predict
jwzt pred --config configs/infer_busi.yaml --model checkpoints/best_auc.ckpt --data dataset/Dataset_BUSI_with_GT --output outputs/busi_predictions

# Evaluate
jwzt eval --config configs/eval_busi.yaml --pred outputs/busi_predictions --data dataset/Dataset_BUSI_with_GT

# Audit dataset
jwzt audit-data --data-root dataset --output outputs/dataset_audit_summary.json

# Debug training
jwzt train --config configs/train_debug.yaml --experiment-name debug_run

Training Strategy

Four-stage training:

  1. pretrain_pre: Train LABDG-Pre only (coarse localization, structure maps)
  2. pretrain_seg: Train DGBC-MTLNet segmentation (encoder + decoder)
  3. train_cls: Train MPTC-Head only (freeze encoder + preprocessing)
  4. finetune_all: End-to-end fine-tuning with all losses

Metrics

Classification: AUC, Accuracy, Sensitivity, Specificity, Precision, F1 Segmentation: Dice, IoU, HD95, Boundary-F1

Stargazers over time

Stargazers over time

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jwztumor-1.0.6.tar.gz (95.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jwztumor-1.0.6-py3-none-any.whl (114.6 kB view details)

Uploaded Python 3

File details

Details for the file jwztumor-1.0.6.tar.gz.

File metadata

  • Download URL: jwztumor-1.0.6.tar.gz
  • Upload date:
  • Size: 95.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for jwztumor-1.0.6.tar.gz
Algorithm Hash digest
SHA256 6879213ccb7972ccdccdb48b3b385b33ecd1945f19c4fb464e879b3deeffabab
MD5 f0528dc6624937026e2abdd4d31ed00d
BLAKE2b-256 15b6b4b2b7b214ad6dcb920ebfe3b6a32142c28b9017eadc4eaeb3fb4e76c2dc

See more details on using hashes here.

File details

Details for the file jwztumor-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: jwztumor-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 114.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for jwztumor-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 02778766abb2978e671f44fe81ce58f52ca5451037b3f7682f6e19549cc445a4
MD5 297a43153bfd3758a59b7bd4cb622485
BLAKE2b-256 92399e2c7eb1346af7444d9b7ce9900d37902b2e0ea379972b08b2a05688d91a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page