Label tree semantic losses for rich multi-class medical image segmentation.
6 blocks of code here have a permanent identifier (oscr:b:…), listed with the matches below: citable for good, with a page of its own. Select a match and press Cite to copy it. What a block identifier is.
The 8 matches
- [1] § Results › Analysis of error types (confusion matrices) ↔ scripts/generate_wbp_paper_assets.py, lines 59 to 148 · score 0.98 · ctx lh unknown, ctx rh unknown, Right choroid plexus, Left choroid plexus, Left Inf Lat, Optic Chiasm · block
oscr:b:V85X5VEHG7N9H-2· Report a mismatch - [2] § Results › Analysis of error types (confusion matrices) ↔ scripts/generate_wbp_subject_metrics.py, lines 1 to 88 · score 0.88 · Left Inf Lat, Optic Chiasm, WM hypointensities, Right vessel, Left vessel, small classes · block
oscr:b:Q8P2X31TDZGT0-4· Report a mismatch - [3] § Results › WBP with dense reference masks ↔ scripts/generate_wbp_subject_metrics.py, lines 1 to 88 · score 0.69 · Surface Dice, baseline losses, Dice loss, tolerance, IXI, MB42 · block
oscr:b:Q8P2X31TDZGT0-4· Report a mismatch - [4] § Methodology › Wasserstein distance in label space ↔ training/loss/treewasserstein.py, lines 8 to 53 · score 0.67 · Wasserstein distance, distance matrix, ground distance, leaf nodes, edges · block
oscr:b:Z4ZJQVGRXEPJF-3· Report a mismatch - [5] § Experimental setup › Implementation details › HSI ↔ training/nnUNetTrainer/network_training/nnUNetTrainerTreeWeightedCE_plus_DiceLoss.py, lines 40 to 86 · score 0.60 · tree weighted CE, Dice loss, batch, node, training, classes · block
oscr:b:A0Q1PFJ27GZVG-8· Report a mismatch - [6] § Experimental setup › Implementation details › HSI ↔ training/nnUNetTrainer/network_training/nnUNetTrainerWassersteinLoss.py, lines 44 to 123 · score 0.59 · weighted CE loss, Dice loss, EfficientNet, Wasserstein, batch, node · block
oscr:b:T8N4KCHJNSTK4-B· Report a mismatch - [7] § Conclusion and discussion ↔ training/loss/treewasserstein.py, lines 8 to 53 · score 0.56 · distance matrix, Wasserstein distance, CE loss, node, class · block
oscr:b:Z4ZJQVGRXEPJF-3· Report a mismatch - [8] § Results › Surgical HSI with sparse positive-only annotations ↔ segmentation_models_pytorch/metrics/functional.py, lines 722 to 799 · score 0.56 · Balanced Accuracy, F1 scores, IoU, metric, pixels, classes · block
oscr:b:659J44GFX1GXQ-C· Report a mismatch
Paper
Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
Python · 437 lines · 16 KB · Apache-2.0 · 2 matches
- #!/usr/bin/env python3
- """Generate subject-level WBP metrics from retained nnU-Net predictions."""
- from __future__ import annotations
- import argparse
- import concurrent.futures
- import csv
- import importlib
- import json
- import math
- from pathlib import Path
- from typing import Any
- import numpy as np
- MISSING_NIBABEL: ModuleNotFoundError | None = None
- MISSING_SURFACE_DISTANCE: ModuleNotFoundError | None = None
- nib: Any = None
- compute_surface_distances: Any = None
- compute_surface_dice_at_tolerance: Any = None
- try:
- nib = importlib.import_module("nibabel")
- except ModuleNotFoundError as exc:
- MISSING_NIBABEL = exc
- try:
- surface_distance: Any = importlib.import_module("surface_distance")
- compute_surface_distances = surface_distance.compute_surface_distances
- compute_surface_dice_at_tolerance = surface_distance.compute_surface_dice_at_tolerance
- except ModuleNotFoundError as exc:
- MISSING_SURFACE_DISTANCE = exc
- DATASETS = {
- "2154": "Dataset2154_mind_remap",
- "3062": "Dataset3062_mindaomic_remap",
- "3072": "Dataset3072_mindixi_remap",
- }
- REPO_ROOT = Path(__file__).resolve().parents[1]
- DEFAULT_NNUNET_ROOT = Path("/mnt/g/model_and_data_backup/nnunet/nnunet_data")
- DEFAULT_OUTPUT_DIR = REPO_ROOT / "outputs"
- TRAIN_LABELS = {
- "Dataset2154_mind_remap": "MB59",
- "Dataset3062_mindaomic_remap": "AOMIC",
- "Dataset3072_mindixi_remap": "IXI",
- }
- TEST_LABELS = {
- "Dataset2154_mind_remap": "MB42",
- "Dataset3062_mindaomic_remap": "AOMIC",
- "Dataset3072_mindixi_remap": "IXI",
- }
- TRAINER_ORDER = [
- "nnUNetTrainerBaselineLossNoMirroring",
- "nnUNetTrainerTreeWeightedCE_plus_DiceLoss_6LevelHierarchy_NoMirroring",
- "nnUNetTrainerWassersteinLoss_5LevelHierarchy_NoMirroring",
- ]
- KNOWN_TRAINER_ORDER = TRAINER_ORDER
- METHOD_LABELS = {
- "nnUNetTrainerBaselineLossNoMirroring": "L_seg",
- "nnUNetTrainerTreeWeightedCE_plus_DiceLoss_6LevelHierarchy_NoMirroring": "L_twce+seg",
- "nnUNetTrainerWassersteinLoss_5LevelHierarchy_NoMirroring": "L_wass+seg",
- }
- PLAN_SUFFIX = "__nnUNetPlans__3d_fullres"
- SMALL_CLASS_NAMES = [
- "5th-Ventricle",
- "non-WM-hypointensities",
- "Right-vessel",
- "Left-vessel",
- "Left-Inf-Lat-Vent",
- "Optic-Chiasm",
- "Right-Inf-Lat-Vent",
- "CC_Mid_Posterior",
- "CC_Central",
- "CC_Mid_Anterior",
- ]
- ORIGINAL_EVALUATOR_SPACING = [1.5, 1.5, 1.5]
- def parse_args() -> argparse.Namespace:
- parser = argparse.ArgumentParser(description=__doc__)
- parser.add_argument("--nnunet-root", default=str(DEFAULT_NNUNET_ROOT))
- parser.add_argument("--output-dir", default=str(DEFAULT_OUTPUT_DIR))
- parser.add_argument("--nsd-tolerance", type=float, default=3.0, help="NSD surface tolerance in millimetres.")
- parser.add_argument("--max-cases", type=int, default=None)
- parser.add_argument("--workers", type=int, default=1)
- return parser.parse_args()
- def load_json(path: Path) -> dict:
- with path.open("r", encoding="utf-8") as f:
- return json.load(f)
- def require_metric_dependencies() -> None:
- if MISSING_NIBABEL is not None:
- raise ModuleNotFoundError(
- f"missing Python dependency for subject metric generation: {MISSING_NIBABEL.name}. "
- "Run this script inside the nnU-Net environment."
- ) from MISSING_NIBABEL
- if MISSING_SURFACE_DISTANCE is not None:
- raise ModuleNotFoundError(
- "missing Python dependency for original NSD evaluation: surface-distance. "
- "Install it with `pip install surface-distance`."
- ) from MISSING_SURFACE_DISTANCE
- def read_score_file(path: Path) -> list[dict[str, float | str]]:
- rows: list[dict[str, float | str]] = []
- with path.open("r", encoding="utf-8") as f:
- for line in f:
- class_name, metric, score = line.split(" ")
- rows.append({"class_name": class_name, "metric": metric.rstrip(":"), "score": float(score)})
- return rows
- def mean_score(rows: list[dict[str, float | str]], metric: str, class_names: set[str] | None = None) -> float:
- values = [
- float(row["score"])
- for row in rows
- if row["metric"] == metric and (class_names is None or row["class_name"] in class_names)
- ]
- if not values:
- return float("nan")
- return float(np.mean(values) * 100.0)
- def case_id(path: Path) -> str:
- if path.name.endswith(".nii.gz"):
- return path.name.removesuffix(".nii.gz")
- return path.stem
- def label_mapping(dataset_json_path: Path) -> dict[str, int]:
- labels = load_json(dataset_json_path)["labels"]
- return {name: int(value) for name, value in labels.items()}
- def load_segmentation(path: Path) -> tuple[np.ndarray, tuple[float, ...]]:
- image = nib.load(str(path))
- data = image.get_fdata()
- spacing = tuple(float(value) for value in image.header.get_zooms()[: data.ndim])
- return data, spacing
- def dice_score(reference: np.ndarray, prediction: np.ndarray, label: int) -> float:
- ref_mask = reference == label
- pred_mask = prediction == label
- if not ref_mask.any():
- return float("nan")
- if not pred_mask.any():
- return 0.0
- intersection = float(np.sum(ref_mask * pred_mask))
- denominator = float(np.sum(ref_mask) + np.sum(pred_mask))
- return float((2 * intersection) / (denominator + 1e-6))
- def normalised_surface_dice(reference: np.ndarray, prediction: np.ndarray, label: int, tolerance: float) -> float:
- ref_mask = reference == label
- pred_mask = prediction == label
- if not ref_mask.any():
- return float("nan")
- if not pred_mask.any():
- return 0.0
- surface_distances = compute_surface_distances(ref_mask, pred_mask, ORIGINAL_EVALUATOR_SPACING)
- return float(compute_surface_dice_at_tolerance(surface_distances, tolerance))
- def nanmean(values: list[float]) -> float:
- valid = [value for value in values if not math.isnan(value)]
- if not valid:
- return float("nan")
- return float(np.mean(valid))
- def csv_value(value: float) -> str:
- if math.isnan(value):
- return "nan"
- return f"{value:.10g}"
- def find_score_file(nnunet_results: Path, test_dataset: str, trainer: str, train_id: str) -> Path:
- score_path = nnunet_results / test_dataset / f"{trainer}{PLAN_SUFFIX}" / f"score_{train_id}.txt"
- if not score_path.exists():
- raise FileNotFoundError(f"missing aggregate score file: {score_path}")
- return score_path
- def output_paths(output_dir: Path, seed_label: str) -> tuple[Path, Path, Path]:
- if seed_label == "single":
- suffix = ""
- else:
- suffix = f"_seed_{seed_label}"
- return (
- output_dir / f"wbp_subject_metrics{suffix}.csv",
- output_dir / f"wbp_subject_class_metrics{suffix}.csv",
- output_dir / f"wbp_subject_metric_validation{suffix}.csv",
- )
- def prediction_dir(dataset_dir: Path, train_id: str, trainer: str) -> Path:
- return dataset_dir / f"labelsTs_predicted_{train_id}" / trainer
- def validate_case_sets(label_dir: Path, prediction_dir: Path, max_cases: int | None = None) -> list[str]:
- cases = [case_id(path) for path in sorted(label_dir.glob("*.nii.gz"))]
- return cases[:max_cases] if max_cases is not None else cases
- def write_csv(path: Path, fields: list[str], rows: list[dict[str, str]]) -> None:
- with path.open("w", newline="", encoding="utf-8") as f:
- writer = csv.DictWriter(f, fieldnames=fields)
- writer.writeheader()
- writer.writerows(rows)
- def compute_subject_metric_rows(
- subject_id: str,
- label_path: Path,
- prediction_path: Path,
- labels: dict[str, int],
- small_classes: set[str],
- tolerance: float,
- ) -> tuple[list[tuple[str, float]], list[tuple[str, str, float]]]:
- reference, spacing = load_segmentation(label_path)
- prediction, _ = load_segmentation(prediction_path)
- if reference.shape != prediction.shape:
- raise ValueError(f"shape mismatch for {subject_id}: reference={reference.shape}, prediction={prediction.shape}")
- subject_dice: list[float] = []
- subject_nsd: list[float] = []
- subject_small_dice: list[float] = []
- subject_small_nsd: list[float] = []
- class_metric_rows: list[tuple[str, str, float]] = []
- for class_name, label in labels.items():
- dice = dice_score(reference, prediction, label)
- nsd = normalised_surface_dice(reference, prediction, label, tolerance)
- class_metric_rows.extend([(class_name, "Dice", dice), (class_name, "NSD", nsd)])
- subject_dice.append(dice)
- subject_nsd.append(nsd)
- if class_name in small_classes:
- subject_small_dice.append(dice)
- subject_small_nsd.append(nsd)
- subject_metric_rows = [
- ("Dice", nanmean(subject_dice)),
- ("NSD", nanmean(subject_nsd)),
- ("Dice_small", nanmean(subject_small_dice)),
- ("NSD_small", nanmean(subject_small_nsd)),
- ]
- return subject_metric_rows, class_metric_rows
- def compute_case_metrics(
- case_args: tuple[str, Path, Path, dict[str, int], set[str], float],
- ) -> tuple[str, list[tuple[str, float]], list[tuple[str, str, float]]]:
- subject_id, label_path, prediction_path, labels, small_classes, tolerance = case_args
- subject_metric_rows, class_metric_rows = compute_subject_metric_rows(
- subject_id=subject_id,
- label_path=label_path,
- prediction_path=prediction_path,
- labels=labels,
- small_classes=small_classes,
- tolerance=tolerance,
- )
- return subject_id, subject_metric_rows, class_metric_rows
- def write_subject_metrics(
- nnunet_raw: Path,
- nnunet_results: Path,
- output_dir: Path,
- tolerance: float,
- max_cases: int | None = None,
- workers: int = 1,
- seed_label: str = "single",
- ) -> tuple[Path, Path, Path]:
- require_metric_dependencies()
- output_dir.mkdir(parents=True, exist_ok=True)
- subject_csv, class_csv, validation_csv = output_paths(output_dir, seed_label)
- subject_rows: list[dict[str, str]] = []
- class_rows: list[dict[str, str]] = []
- validation_rows: list[dict[str, str]] = []
- small_classes = set(SMALL_CLASS_NAMES)
- for train_id, train_dataset in DATASETS.items():
- train_label = TRAIN_LABELS[train_dataset]
- for test_dataset, test_label in TEST_LABELS.items():
- dataset_dir = nnunet_raw / test_dataset
- label_dir = dataset_dir / "labelsTs"
- labels = label_mapping(dataset_dir / "dataset.json")
- class_names = list(labels)
- for trainer in TRAINER_ORDER:
- method = METHOD_LABELS[trainer]
- pred_dir = prediction_dir(dataset_dir, train_id, trainer)
- cases = validate_case_sets(label_dir, pred_dir, max_cases)
- print(
- f"computing subject metrics: train={train_label} test={test_label} "
- f"method={method} cases={len(cases)} workers={workers}",
- flush=True,
- )
- per_class_values: dict[str, dict[str, list[float]]] = {
- class_name: {"Dice": [], "NSD": []} for class_name in class_names
- }
- case_args = [
- (
- subject_id,
- label_dir / f"{subject_id}.nii.gz",
- pred_dir / f"{subject_id}.nii.gz",
- labels,
- small_classes,
- tolerance,
- )
- for subject_id in cases
- ]
- if workers == 1:
- case_results = [compute_case_metrics(args) for args in case_args]
- else:
- with concurrent.futures.ProcessPoolExecutor(max_workers=workers) as executor:
- case_results = list(executor.map(compute_case_metrics, case_args))
- for subject_id, subject_metric_values, class_metric_values in case_results:
- for class_name, metric, value in class_metric_values:
- per_class_values[class_name][metric].append(value)
- class_rows.append(
- {
- "train_dataset": train_label,
- "test_dataset": test_label,
- "subject_id": subject_id,
- "seed": seed_label,
- "method": method,
- "class_name": class_name,
- "metric": metric,
- "value": csv_value(value),
- }
- )
- for metric, value in subject_metric_values:
- subject_rows.append(
- {
- "train_dataset": train_label,
- "test_dataset": test_label,
- "subject_id": subject_id,
- "seed": seed_label,
- "method": method,
- "metric": metric,
- "value": csv_value(value),
- }
- )
- computed: dict[str, float] = {}
- computed["Dice"] = nanmean([nanmean(per_class_values[name]["Dice"]) for name in class_names]) * 100.0
- computed["NSD"] = nanmean([nanmean(per_class_values[name]["NSD"]) for name in class_names]) * 100.0
- computed["Dice_small"] = (
- nanmean([nanmean(per_class_values[name]["Dice"]) for name in class_names if name in small_classes])
- * 100.0
- )
- computed["NSD_small"] = (
- nanmean([nanmean(per_class_values[name]["NSD"]) for name in class_names if name in small_classes])
- * 100.0
- )
- score_rows = read_score_file(find_score_file(nnunet_results, test_dataset, trainer, train_id))
- expected = {
- "Dice": mean_score(score_rows, "dice"),
- "NSD": mean_score(score_rows, "surface_dice_3"),
- "Dice_small": mean_score(score_rows, "dice", small_classes),
- "NSD_small": mean_score(score_rows, "surface_dice_3", small_classes),
- }
- for metric in computed:
- validation_rows.append(
- {
- "train_dataset": train_label,
- "test_dataset": test_label,
- "method": method,
- "metric": metric,
- "computed_value": csv_value(computed[metric]),
- "score_file_value": csv_value(expected[metric]),
- "absolute_difference": csv_value(abs(computed[metric] - expected[metric])),
- }
- )
- write_csv(
- subject_csv,
- ["train_dataset", "test_dataset", "subject_id", "seed", "method", "metric", "value"],
- subject_rows,
- )
- write_csv(
- class_csv,
- ["train_dataset", "test_dataset", "subject_id", "seed", "method", "class_name", "metric", "value"],
- class_rows,
- )
- write_csv(
- validation_csv,
- ["train_dataset", "test_dataset", "method", "metric", "computed_value", "score_file_value", "absolute_difference"],
- validation_rows,
- )
- return subject_csv, class_csv, validation_csv
- def main() -> None:
- args = parse_args()
- root = Path(args.nnunet_root).expanduser()
- nnunet_raw = root / "nnUNet_raw"
- nnunet_results = root / "nnUNet_results"
- print(f"nnUNet_raw: {nnunet_raw}")
- print(f"nnUNet_results: {nnunet_results}")
- subject_csv, class_csv, validation_csv = write_subject_metrics(
- nnunet_raw=nnunet_raw,
- nnunet_results=nnunet_results,
- output_dir=Path(args.output_dir).expanduser(),
- tolerance=args.nsd_tolerance,
- max_cases=args.max_cases,
- workers=args.workers,
- )
- print(f"wrote {subject_csv}")
- print(f"wrote {class_csv}")
- print(f"wrote {validation_csv}")
- print("done")
- if __name__ == "__main__":
- main()
generate_wbp_subject_metrics.py at commit ecc75c0, under Apache-2.0 · at the source
Overview
- School of Biomedical Engineering and Imaging Sciences, King's College London, London, United Kingdom
- Department of Neurosurgery, King's College Hospital, London, United Kingdom
Abstract
Rich and accurate medical image segmentation is poised to underpin the next generation of AI-defined clinical practice by delineating critical anatomy for pre-operative planning, guiding real-time intra-operative navigation, and supporting precise post-operative assessment. However, commonly used learning methods for medical and surgical imaging segmentation tasks penalize all errors equivalently and thus fail to exploit any inter-class semantics in the label space. This becomes particularly problematic as the cardinality and richness of labels increases to include subtly different classes. In this work, we propose two tree-based semantic loss functions which take advantage of a hierarchical organization of the labels. We further incorporate our losses in a recently proposed approach for training with sparse, background-free annotations to extend the applicability of our proposed losses. Extensive experiments are reported on two medical and surgical imaging segmentation tasks, namely head MRI for whole brain parcellation with full supervision and neurosurgical hyperspectral imaging for scene understanding with sparse annotations. Results demonstrate consistent improvements over the evaluated task-specific baselines, with the strongest support for the Wasserstein-based compound loss in whole-brain parcellation and for hierarchy-weighted top-level supervision in the sparse hyperspectral imaging (HSI) setting.
Reproduced under the paper's license (CC BY), from the paper cited above.
Repositories
Its files are read in the Code ↔ Paper reader above, with 8 matches between paragraphs and lines of code.
cai4cai/nnunet-tree-semantic-extension
ecc75c06b0bb66d9bc73bafe6083ed852b0b2210, 18 May 2026Availability: 1 check, the latest on 27 September 2026: the link answers
- 27 September 2026: the link answers
20 files
- evaluation/
evaluate_leaf_nodes.py , Python, 87 lines - hierarchy/
__init__.py , Python, 1 line - hierarchy/
config.py , Python, 266 lines - hierarchy/
utils/ , Python, 1 line__init__.py - hierarchy/
utils/ , Python, 234 linesutils.py - scripts/
dgx/ , Shell, 22 linesmake_docker_image.sh - scripts/
dgx/ , Shell, 143 linesrun_cross_dataset_evalua tion.sh - scripts/
dgx/ , Shell, 265 linesrun_wbp_priority1_baseli nes.sh - scripts/
dgx/ , Shell, 21 linesrun_wbp_subject_metrics. sh - scripts/
dgx/ , Shell, 21 linessubmit.sh - scripts/
generate_wbp_paired_samp , Python, 253 linesle_tests.py - scripts/
generate_wbp_paper_asset , Python, 633 lines, 1 matchs.py - scripts/
generate_wbp_subject_met , Python, 437 lines, 2 matchesrics.py - training/
loss/ , Python, 190 linestreesemantic.py - training/
loss/ , Python, 75 lines, 2 matchestreewasserstein.py - training/
nnUNetTrainer/ , Python, 1 linenetwork_training/ __init__.py - training/
nnUNetTrainer/ , Python, 97 lines, 1 matchnetwork_training/ nnUNetTrainerTreeWeighte dCE_plus_DiceLoss.py - training/
nnUNetTrainer/ , Python, 144 lines, 1 matchnetwork_training/ nnUNetTrainerWasserstein Loss.py - LICENSE, License, 200 lines
- README.md, Text, 185 lines
qubvel/segmentation_models.pytorch
f5effcfce48b0e44e7e0c85015673547d364b4d3, 2 November 2026Availability: 2 checks, the latest on 2 November 2026: the link answers
- 2 November 2026: the link answers
- 27 September 2026: the link answers
140 files
- docs/
conf.py , Python, 133 lines - examples/
binary_segmentation_buil , Python, 498 linesdings.py - examples/
binary_segmentation_intr , Jupyter, 368 lineso.ipynb - examples/
camvid_segmentation_mult , Jupyter, 482 linesiclass.ipynb - examples/
cars segmentation (camvid).ipynb , Jupyter, 471 lines - examples/
convert_to_onnx.ipynb , Jupyter, 84 lines - examples/
dpt_inference_pretrained , Jupyter, 65 lines.ipynb - examples/
save_load_model_and_shar , Jupyter, 120 linese_with_hf_hub.ipynb - examples/
segformer_inference_pret , Jupyter, 66 linesrained.ipynb - examples/
upernet_inference_pretra , Jupyter, 67 linesined.ipynb - misc/
generate_table.py , Python, 45 lines - misc/
generate_table_timm.py , Python, 108 lines - misc/
generate_test_models.py , Python, 58 lines - scripts/
models-conversions/ , Python, 122 linesdpt-original-to-smp.py - scripts/
models-conversions/ , Python, 148 linessegformer-original-decod er-to-smp.py - scripts/
models-conversions/ , Python, 249 linesupernet-hf-to-smp.py - segmentation_models_pyto
rch/ , Python, 93 lines__init__.py - segmentation_models_pyto
rch/ , Python, 1 line__version__.py - segmentation_models_pyto
rch/ , Python, 13 linesbase/ __init__.py - segmentation_models_pyto
rch/ , Python, 35 linesbase/ heads.py - segmentation_models_pyto
rch/ , Python, 155 linesbase/ hub_mixin.py - segmentation_models_pyto
rch/ , Python, 28 linesbase/ initialization.py - segmentation_models_pyto
rch/ , Python, 210 linesbase/ model.py - segmentation_models_pyto
rch/ , Python, 197 linesbase/ modules.py - segmentation_models_pyto
rch/ , Python, 14 linesbase/ utils.py - segmentation_models_pyto
rch/ , Python, 3 linesdatasets/ __init__.py - segmentation_models_pyto
rch/ , Python, 149 linesdatasets/ oxford_pet.py - segmentation_models_pyto
rch/ , Python, 1 linedecoders/ __init__.py - segmentation_models_pyto
rch/ , Python, 3 linesdecoders/ deeplabv3/ __init__.py - segmentation_models_pyto
rch/ , Python, 255 linesdecoders/ deeplabv3/ decoder.py - segmentation_models_pyto
rch/ , Python, 244 linesdecoders/ deeplabv3/ model.py - segmentation_models_pyto
rch/ , Python, 3 linesdecoders/ dpt/ __init__.py - segmentation_models_pyto
rch/ , Python, 320 linesdecoders/ dpt/ decoder.py - segmentation_models_pyto
rch/ , Python, 168 linesdecoders/ dpt/ model.py - segmentation_models_pyto
rch/ , Python, 3 linesdecoders/ fpn/ __init__.py - segmentation_models_pyto
rch/ , Python, 146 linesdecoders/ fpn/ decoder.py - segmentation_models_pyto
rch/ , Python, 117 linesdecoders/ fpn/ model.py - segmentation_models_pyto
rch/ , Python, 3 linesdecoders/ linknet/ __init__.py - segmentation_models_pyto
rch/ , Python, 103 linesdecoders/ linknet/ decoder.py - segmentation_models_pyto
rch/ , Python, 129 linesdecoders/ linknet/ model.py - segmentation_models_pyto
rch/ , Python, 3 linesdecoders/ manet/ __init__.py - segmentation_models_pyto
rch/ , Python, 217 linesdecoders/ manet/ decoder.py - segmentation_models_pyto
rch/ , Python, 137 linesdecoders/ manet/ model.py - segmentation_models_pyto
rch/ , Python, 3 linesdecoders/ pan/ __init__.py - segmentation_models_pyto
rch/ , Python, 265 linesdecoders/ pan/ decoder.py - segmentation_models_pyto
rch/ , Python, 126 linesdecoders/ pan/ model.py - segmentation_models_pyto
rch/ , Python, 3 linesdecoders/ pspnet/ __init__.py - segmentation_models_pyto
rch/ , Python, 109 linesdecoders/ pspnet/ decoder.py - segmentation_models_pyto
rch/ , Python, 132 linesdecoders/ pspnet/ model.py - segmentation_models_pyto
rch/ , Python, 3 linesdecoders/ segformer/ __init__.py - segmentation_models_pyto
rch/ , Python, 73 linesdecoders/ segformer/ decoder.py - segmentation_models_pyto
rch/ , Python, 97 linesdecoders/ segformer/ model.py - segmentation_models_pyto
rch/ , Python, 3 linesdecoders/ unet/ __init__.py - segmentation_models_pyto
rch/ , Python, 170 linesdecoders/ unet/ decoder.py - segmentation_models_pyto
rch/ , Python, 169 linesdecoders/ unet/ model.py - segmentation_models_pyto
rch/ , Python, 3 linesdecoders/ unetplusplus/ __init__.py - segmentation_models_pyto
rch/ , Python, 185 linesdecoders/ unetplusplus/ decoder.py - segmentation_models_pyto
rch/ , Python, 143 linesdecoders/ unetplusplus/ model.py - segmentation_models_pyto
rch/ , Python, 3 linesdecoders/ upernet/ __init__.py - segmentation_models_pyto
rch/ , Python, 211 linesdecoders/ upernet/ decoder.py - segmentation_models_pyto
rch/ , Python, 116 linesdecoders/ upernet/ model.py - segmentation_models_pyto
rch/ , Python, 184 linesencoders/ __init__.py - segmentation_models_pyto
rch/ , Python, 61 linesencoders/ _base.py - segmentation_models_pyto
rch/ , Python, 364 linesencoders/ _dpn.py - segmentation_models_pyto
rch/ , Python, 883 linesencoders/ _efficientnet.py - segmentation_models_pyto
rch/ , Python, 301 linesencoders/ _inceptionresnetv2.py - segmentation_models_pyto
rch/ , Python, 291 linesencoders/ _inceptionv4.py - segmentation_models_pyto
rch/ , Python, 22 linesencoders/ _preprocessing.py - segmentation_models_pyto
rch/ , Python, 337 linesencoders/ _senet.py - segmentation_models_pyto
rch/ , Python, 57 linesencoders/ _utils.py - segmentation_models_pyto
rch/ , Python, 231 linesencoders/ _xception.py - segmentation_models_pyto
rch/ , Python, 174 linesencoders/ densenet.py - segmentation_models_pyto
rch/ , Python, 227 linesencoders/ dpn.py - segmentation_models_pyto
rch/ , Python, 241 linesencoders/ efficientnet.py - segmentation_models_pyto
rch/ , Python, 131 linesencoders/ inceptionresnetv2.py - segmentation_models_pyto
rch/ , Python, 115 linesencoders/ inceptionv4.py - segmentation_models_pyto
rch/ , Python, 727 linesencoders/ mix_transformer.py - segmentation_models_pyto
rch/ , Python, 94 linesencoders/ mobilenet.py - segmentation_models_pyto
rch/ , Python, 564 linesencoders/ mobileone.py - segmentation_models_pyto
rch/ , Python, 310 linesencoders/ resnet.py - segmentation_models_pyto
rch/ , Python, 231 linesencoders/ senet.py - segmentation_models_pyto
rch/ , Python, 532 linesencoders/ timm_efficientnet.py - segmentation_models_pyto
rch/ , Python, 121 linesencoders/ timm_sknet.py - segmentation_models_pyto
rch/ , Python, 247 linesencoders/ timm_universal.py - segmentation_models_pyto
rch/ , Python, 191 linesencoders/ timm_vit.py - segmentation_models_pyto
rch/ , Python, 313 linesencoders/ vgg.py - segmentation_models_pyto
rch/ , Python, 101 linesencoders/ xception.py - segmentation_models_pyto
rch/ , Python, 24 lineslosses/ __init__.py - segmentation_models_pyto
rch/ , Python, 289 lineslosses/ _functional.py - segmentation_models_pyto
rch/ , Python, 18 lineslosses/ constants.py - segmentation_models_pyto
rch/ , Python, 162 lineslosses/ dice.py - segmentation_models_pyto
rch/ , Python, 130 lineslosses/ focal.py - segmentation_models_pyto
rch/ , Python, 150 lineslosses/ jaccard.py - segmentation_models_pyto
rch/ , Python, 235 lineslosses/ lovasz.py - segmentation_models_pyto
rch/ , Python, 51 lineslosses/ mcc.py - segmentation_models_pyto
rch/ , Python, 83 lineslosses/ soft_bce.py - segmentation_models_pyto
rch/ , Python, 47 lineslosses/ soft_ce.py - segmentation_models_pyto
rch/ , Python, 87 lineslosses/ tversky.py - segmentation_models_pyto
rch/ , Python, 42 linesmetrics/ __init__.py - segmentation_models_pyto
rch/ , Python, 799 lines, 1 matchmetrics/ functional.py - segmentation_models_pyto
rch/ , Python, 12 linesutils/ __init__.py - segmentation_models_pyto
rch/ , Python, 67 linesutils/ base.py - segmentation_models_pyto
rch/ , Python, 132 linesutils/ functional.py - segmentation_models_pyto
rch/ , Python, 69 linesutils/ losses.py - segmentation_models_pyto
rch/ , Python, 61 linesutils/ meter.py - segmentation_models_pyto
rch/ , Python, 111 linesutils/ metrics.py - segmentation_models_pyto
rch/ , Python, 116 linesutils/ train.py - tests/
__init__.py , Python, 1 line - tests/
base/ , Python, 70 linestest_freeze_encoder.py - tests/
base/ , Python, 64 linestest_modules.py - tests/
conftest.py , Python, 16 lines - tests/
encoders/ , Python, 1 line__init__.py - tests/
encoders/ , Python, 284 linesbase.py - tests/
encoders/ , Python, 54 linestest_batchnorm_deprecati on.py - tests/
encoders/ , Python, 15 linestest_common.py - tests/
encoders/ , Python, 80 linestest_pretrainedmodels_en coders.py - tests/
encoders/ , Python, 64 linestest_smp_encoders.py - tests/
encoders/ , Python, 146 linestest_timm_ported_encoder s.py - tests/
encoders/ , Python, 40 linestest_timm_universal.py - tests/
encoders/ , Python, 236 linestest_timm_vit_encoders.p y - tests/
encoders/ , Python, 84 linestest_torchvision_encoder s.py - tests/
models/ , Python, 1 line__init__.py - tests/
models/ , Python, 298 linesbase.py - tests/
models/ , Python, 15 linestest_deeplab.py - tests/
models/ , Python, 60 linestest_dpt.py - tests/
models/ , Python, 29 linestest_fpn.py - tests/
models/ , Python, 18 linestest_linknet.py - tests/
models/ , Python, 27 linestest_manet.py - tests/
models/ , Python, 48 linestest_pan.py - tests/
models/ , Python, 8 linestest_psp.py - tests/
models/ , Python, 43 linestest_segformer.py - tests/
models/ , Python, 26 linestest_unet.py - tests/
models/ , Python, 44 linestest_unetplusplus.py - tests/
models/ , Python, 14 linestest_upernet.py - tests/
test_base.py , Python, 36 lines - tests/
test_losses.py , Python, 474 lines - tests/
test_preprocessing.py , Python, 52 lines - tests/
utils.py , Python, 89 lines - LICENSE, License, 21 lines
- README.md, Text, 235 lines
Tracing map
Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.
What the map holds:
- 2 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 156 scripts, each with its path and the digest of its content;
- 8 matches between paragraphs of the paper and lines of the code (method lexical-v1);
- neither the text of the paper nor the code itself.
Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.
Data
No dataset and no data link were found in the paper.
Data availability statement
The original contributions presented in the study are included in the article/
Reproduced under the paper's license (CC BY), from the paper cited above.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 2, 28 September 2026
- Funding: added National Institute for Health and Care Research: NIHR202114; Wellcome / EPSRC Centre for Interventional and Surgical Sciences
Version 1, 27 September 2026: the first record
Recorded: type, language, journal, volume, pages, dates, 6 authors, 5 keywords, 60 references.
Cite
This paper
Wang, J., MacCormac, O., Rochford, W., Kujawa, A., Shapey, J., & Vercauteren, T. (2026). Label tree semantic losses for rich multi-class medical image segmentation. Frontiers in artificial intelligence, 9, 1841639. https://
BibTeX
@article{wang2026label,
author = {Wang, Junwen and MacCormac, Oscar and Rochford, William and Kujawa, Aaron and Shapey, Jonathan and Vercauteren, Tom},
title = {{Label tree semantic losses for rich multi-class medical image segmentation}},
journal = {Frontiers in artificial intelligence},
year = {2026},
month = jun,
volume = {9},
pages = {1841639},
publisher = {Frontiers Media SA},
issn = {2624-8212},
doi = {10.3389/
url = {https://
pmid = {42382852},
pmcid = {PMC13315184}
}
RIS
TY - JOUR
AU - Wang, Junwen
AU - MacCormac, Oscar
AU - Rochford, William
AU - Kujawa, Aaron
AU - Shapey, Jonathan
AU - Vercauteren, Tom
TI - Label tree semantic losses for rich multi-class medical image segmentation
T2 - Frontiers in artificial intelligence
J2 - Front Artif Intell
PY - 2026
DA - 2026/
VL - 9
SP - 1841639
SN - 2624-8212
PB - Frontiers Media SA
DO - 10.3389/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.3389/
"type": "article-journal",
"title": "Label tree semantic losses for rich multi-class medical image segmentation",
"container-title": "Frontiers in artificial intelligence",
"author": [
{
"family": "Wang",
"given": "Junwen"
},
{
"family": "MacCormac",
"given": "Oscar"
},
{
"family": "Rochford",
"given": "William"
},
{
"family": "Kujawa",
"given": "Aaron"
},
{
"family": "Shapey",
"given": "Jonathan"
},
{
"family": "Vercauteren",
"given": "Tom"
}
],
"container-title-short":
"volume": "9",
"page": "1841639",
"DOI": "10.3389/
"PMID": "42382852",
"PMCID": "PMC13315184",
"ISSN": "2624-8212",
"publisher": "Frontiers Media SA",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
6,
16
]
]
}
}
The tracing map gets a citation of its own once an author has validated it and it has a DOI.
Similar papers
The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.
- [1] doi:10.1162/imag.a.960 [code]
- GOUHFI: A novel contrast- and resolution-agnostic segmentation tool for ultra-high-field MRI.Journal: Imaging neuroscience (Cambridge, Mass.)In common: nnU-Net, NiBabel, PyTorch, 5 other tools, 6 references
- [2] doi:10.1162/imag_a_00180 [code]
- VINNA for neonates: Orientation independence through latent augmentations.Journal: Imaging neuroscience (Cambridge, Mass.)In common: NiBabel, PyTorch, pandas, 3 other tools, 8 references
- [3] doi:10.1038/s41597-024-03073-x [code]
- Brain tumor segmentation using synthetic MR images - A comparison of GANs and diffusion models.Journal: Scientific dataIn common: nnU-Net, PyTorch Lightning, OpenCV, 8 other tools, 2 references
- [4] doi:10.21037/qims-2026-0792 [code]
- An nnU-Net-based framework with adaptive feature representation for 3D brain tumor segmentation.Journal: Quantitative imaging in medicine and surgeryIn common: nnU-Net, OpenCV, NiBabel, 6 other tools, 4 references
- [5] doi:10.3389/fnimg.2023.1252261 [code]
- Pseudo-Label Assisted nnU-Net enables automatic segmentation of 7T MRI from a single acquisition.Journal: Frontiers in neuroimagingIn common: nnU-Net, PyTorch Lightning, Pillow, 7 other tools, 3 references
- [6] doi:10.3390/s23073420 [code]
- High-Resolution Swin Transformer for Automatic Medical Image Segmentation.Journal: Sensors (Basel, Switzerland)In common: nnU-Net, OpenCV, Pillow, 5 other tools, 4 references
- [7] doi:10.1016/j.media.2023.102789 [code]
- SynthSeg: Segmentation of brain MRI scans of any contrast and resolution without retraining.Journal: Medical image analysisIn common: nnU-Net, OpenCV, Pillow, 7 other tools, 2 references
- [8] doi:10.1038/s41586-025-09708-2 [code]
- A probabilistic histological atlas of the human brain for MRI segmentation.Journal: NatureIn common: nnU-Net, OpenCV, Pillow, 6 other tools, 2 references
- [9] doi:10.1016/j.crmeth.2025.100989 [code]
- Efficient cell-wide mapping of mitochondria in electron microscopic volumes using webKnossos.Journal: Cell reports methodsIn common: nnU-Net, PyTorch Lightning, OpenCV, 7 other tools
- [10] doi:10.1186/s40478-025-02030-y [code]
- Operationalizing postmortem pathology-MRI association studies in Alzheimer's disease and related disorders with MRI-guided histology sampling.Journal: Acta neuropathologica communicationsIn common: nnU-Net, OpenCV, Pillow, 7 other tools, 1 reference
Contribute
The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.
Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 2 repositories of the authors' code, each at its verified commit and with its license, 156 scripts, and 8 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:f4ab206db90dc517…
Add the badge to the code's README
If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.
Markdown
<!-- oscr-badge:start -->
[](https://openscicode.org/badge/doi/10.3389/frai.2026.1841639)
<!-- oscr-badge:end -->reStructuredText
.. oscr-badge:start
.. image:: https://openscicode.org/badge/doi/10.3389/frai.2026.1841639.svg
:target: https://openscicode.org/badge/doi/10.3389/frai.2026.1841639
:alt: OSCR
.. oscr-badge:endHTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.3389/frai.2026.1841639"><img src="https://openscicode.org/badge/doi/10.3389/frai.2026.1841639.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->On GitHub, open the README, choose Edit (the pencil), paste the snippet under the title, then "Commit changes".
- cai4cai/nnunet-tree-semantic-extension: README.md on GitHub
- qubvel/segmentation_models.pytorch: README.md on GitHub
If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge page.
Request its removal
To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).
Discussion, reproductions, activity
Discussion: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.
Report a mismatch between the code and the paper · Report a code error (signed in)
Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.
Report a reproduction failure (signed in)
Versions of its code: the releases of its code tied to a version of this paper (the preprint, the accepted manuscript, the version of record…), each with the tracing map versioned with it.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
