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.4.tar.gz (94.2 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.4-py3-none-any.whl (113.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jwztumor-1.0.4.tar.gz
  • Upload date:
  • Size: 94.2 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.4.tar.gz
Algorithm Hash digest
SHA256 aaf87c199044711c8cce01bec311085466d760e3a415f5224972850ed1099266
MD5 7b58e441bfd3fa687b48f2abd7666de5
BLAKE2b-256 ade5eb15caf54401517f7fac7b562bb8184998b2e1ecbb298b07cb810470c7cf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jwztumor-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 113.0 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4746513cfc38cdebb58d86340d2eb73743f1cc97e87ff19a014c3537be039ad7
MD5 b8bab6269021c69d831bc09af0252e2c
BLAKE2b-256 f783c7499184a460b05c02a7ff54ce071f0a9c83608292d5ebe56f89a5c65fce

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