MIDL 2024 paper: Efficiently correcting patch-based segmentation errors to control image-level performance in retinal images
Project description
Efficiently correcting patch-based segmentation errors to control image-level performance
Experiments for MIDL 2024 paper.
Installation
Requires Python >= 3.9
Development setup with uv (recommended)
Clone the repository:
git clone https://github.com/berenslab/MIDL24-segmentation_quality_control.git
cd MIDL24-segmentation_quality_control
uv sync --extra dev
source .venv/bin/activate # Windows: .venv\Scripts\activate
Development setup without uv
Alternatively, use Python's built-in venv:
git clone https://github.com/berenslab/MIDL24-segmentation_quality_control.git
cd MIDL24-segmentation_quality_control
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
From PyPI (recommended for use as a dependency)
Install the released package:
pip install segmentation_quality_control
PyPI wheels include the Python code only. Ensemble checkpoints (~360 MB) are not bundled; see Model weights below.
From GitHub (development version)
Install the latest development version without cloning:
pip install git+https://github.com/berenslab/MIDL24-segmentation_quality_control
Model weights
The FR-UNet ensemble uses five checkpoints: FRUNet_0.pth, ..., FRUNet_4.pth.
Where weights are resolved
When loading models, the package resolves the checkpoint directory in this order:
- Custom path: pass
models_dir=...toensure_models_dir(). - Local development checkout: if all five files are present in the repository's
trained/folder, that directory is used. This applies to editable installs (pip install -e .) and cloned repositories. - User cache (OS default for PyPI and other installs):
| OS | Default cache directory |
|---|---|
| Linux | ~/.cache/segmentation_quality_control/trained/ |
| macOS | ~/Library/Caches/segmentation_quality_control/trained/ |
| Windows | %LOCALAPPDATA%\segmentation_quality_control\trained\ |
Automatic download
If weights are missing from the resolved location (such as when using as a pypi dependency), they are downloaded over HTTPS from GitHub (trained/) into the cache directory:
from segmentation_quality_control.utils import ensure_models_dir
models_dir = ensure_models_dir() # downloads on first call if needed
If Python's https-download mechanism fails, the package falls back to using git when it is available on PATH.
Manual download
If the automatic download fails, fetch the files directly:
mkdir -p ~/.cache/segmentation_quality_control/trained
wget -O ~/.cache/segmentation_quality_control/trained/FRUNet_0.pth \
https://raw.githubusercontent.com/berenslab/MIDL24-segmentation_quality_control/main/trained/FRUNet_0.pth
# repeat for FRUNet_1.pth … FRUNet_4.pth, or use curl -L -o ...
Alternatively, use a sparse git checkout:
git clone --depth 1 --filter=blob:none --sparse \
https://github.com/berenslab/MIDL24-segmentation_quality_control.git \
~/tmp/segmentation_weights
cd ~/tmp/segmentation_weights
git sparse-checkout set trained
git checkout main
# then copy trained/FRUNet_*.pth into your cache or repo trained/ directory
Checkpoint format
- Weights are plain PyTorch checkpoints (not bundled in PyPI wheels).
- Keys:
arch,epoch,state_dict,optimizer,config - Loading no longer requires the legacy
bunchpackage. - To save new checkpoints after retraining, use
segmentation_quality_control.utils.checkpoint.save_checkpoint, to store them in thebunch-less format.
Reproduce the paper results
Instructions to reproduce the experiments (development setup):
- Install the package as above (
uv sync --extra devorpip install -e ".[dev]"). - Download the FIVES dataset (Jin et al., 2022) and register its path in
paths.yaml. - Execute
0_pass_forward.ipynbto pass the data through the ensemble and log the outputs. In a cloned repository, weights are read fromtrained/. - Calibrate with temperature scaling on the validation set with
1_calibrate.ipynb. - Compute $\widehat{DSC}$ and $\widehat{DSC}_{\text{corr}}$ in
2_estimate_DSC.ipynb. - Reproduce figures with the respective scripts.
References
Jin, Kai, et al. "Fives: A fundus image dataset for artificial Intelligence based vessel segmentation." Scientific Data 9.1 (2022): 475.
Paper and Citation
The paper (MIDL 2024 oral):
- Köhler et al., Efficiently correcting patch-based segmentation errors to control image-level performance in retinal images (2024)
- PDF at OpenReview
Citation:
@inproceedings{
koehler2024efficiently,
title={Efficiently correcting patch-based segmentation errors to control image-level performance in retinal images},
author={Patrick K{\"o}hler and Jeremiah Fadugba and Philipp Berens and Lisa M. Koch},
booktitle={Medical Imaging with Deep Learning},
year={2024},
url={https://openreview.net/forum?id=DDHRGHfwji}
}
Note
This package has been bundled into the Fundus Image Toolbox for convenient application next to other useful retinal fundus imaging tools.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file segmentation_quality_control-0.1.1.tar.gz.
File metadata
- Download URL: segmentation_quality_control-0.1.1.tar.gz
- Upload date:
- Size: 22.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff4fe167ed0e5c6788fadfbc60975718e0dcac19bb15707549adeda320bd30dd
|
|
| MD5 |
e9614674554f8f433769679ce5a4adec
|
|
| BLAKE2b-256 |
298f7da16391d15daa304684bc8058572b324cfb786ce17383e786364a06a26a
|
Provenance
The following attestation bundles were made for segmentation_quality_control-0.1.1.tar.gz:
Publisher:
python-publish.yml on berenslab/MIDL24-segmentation_quality_control
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
segmentation_quality_control-0.1.1.tar.gz -
Subject digest:
ff4fe167ed0e5c6788fadfbc60975718e0dcac19bb15707549adeda320bd30dd - Sigstore transparency entry: 1667780550
- Sigstore integration time:
-
Permalink:
berenslab/MIDL24-segmentation_quality_control@53824ccf13a89154848219a6d014e43ad1a1fd03 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/berenslab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@53824ccf13a89154848219a6d014e43ad1a1fd03 -
Trigger Event:
release
-
Statement type:
File details
Details for the file segmentation_quality_control-0.1.1-py3-none-any.whl.
File metadata
- Download URL: segmentation_quality_control-0.1.1-py3-none-any.whl
- Upload date:
- Size: 26.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3613705cae087b71fc6d454d705336d88e966b4a5393fcfc8a680a29337a6867
|
|
| MD5 |
68ba59ad452fbf8c579243f4cc08accc
|
|
| BLAKE2b-256 |
3d5c461df476c6276f78ea64934b0e5c6b90292da566707432fee80a08d67e37
|
Provenance
The following attestation bundles were made for segmentation_quality_control-0.1.1-py3-none-any.whl:
Publisher:
python-publish.yml on berenslab/MIDL24-segmentation_quality_control
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
segmentation_quality_control-0.1.1-py3-none-any.whl -
Subject digest:
3613705cae087b71fc6d454d705336d88e966b4a5393fcfc8a680a29337a6867 - Sigstore transparency entry: 1667780698
- Sigstore integration time:
-
Permalink:
berenslab/MIDL24-segmentation_quality_control@53824ccf13a89154848219a6d014e43ad1a1fd03 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/berenslab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@53824ccf13a89154848219a6d014e43ad1a1fd03 -
Trigger Event:
release
-
Statement type: