Task-based evaluation toolkit for Metal Artifact Reduction (MAR) in CT imaging (Annex GG Framework)
Project description
mar-eval
Toolkit for the Objective Evaluation of Metal Artifact Reduction (MAR) in CT Imaging
What is this?
mar-eval is an open-source Python toolkit that implements the analysis framework described in Annex GG of the proposed IEC 60601-2-44 Ed. 4. It enables objective evaluation of Metal Artifact Reduction (MAR) in CT imaging using the Channelized Hotelling Observer (CHO), AUC-based detectability metrics, and bias assessment between MAR and Filtered-Back Projection (FBP) reconstructions.
The toolkit focuses on the type test use case, i.e., premarket evaluation on representative systems and validated phantoms or realistic simulation outputs.
Example Notebook
A full demo notebook is available at:
notebooks/annex_gg_full_demo.ipynb
This notebook reproduces the workflow described in Annex GG, from ROI extraction to AUC computation and bias evaluation.
Install
pip install mar-eval
# for notebook demo & plots you may also want:
pip install matplotlib jupyterlab pyyaml
Python ≥ 3.9 is supported.
Quick start (synthetic)
import numpy as np
from mareval import (
generate_synthetic_study, extract_roi, batch_extract_rois,
build_pca_channels, cho_template, cho_decision_values,
compute_auc_ci
)
cfg = dict(image_shape=(64,64), doses=3, contrasts=3, realizations=4, rng_seed=0)
study = generate_synthetic_study(cfg)
images = study["images"]
centers = [(32, 24)]
roi_size = (17,17)
# simple training set for channels
train_imgs = [images[(0,0,0,'FBP','absent')], images[(2,2,0,'MAR','present')]]
train_rois = batch_extract_rois(train_imgs, centers, roi_size)
U = build_pca_channels(train_rois, n_channels=8)
# one cell AUC (FBP)
pos = []; neg = []
for r in range(cfg['realizations']):
pos.append(extract_roi(images[(0,0,r,'FBP','present')], centers[0], roi_size).ravel())
neg.append(extract_roi(images[(0,0,r,'FBP','absent')], centers[0], roi_size).ravel())
import numpy as np
pos = np.asarray(pos); neg = np.asarray(neg)
ch_pos = (pos - pos.mean(0)) @ U
ch_neg = (neg - neg.mean(0)) @ U
w = cho_template(ch_pos, ch_neg, lambda_reg=1e-3)
s = np.concatenate([ch_pos @ w, ch_neg @ w])
y = np.array([1]*len(ch_pos) + [0]*len(ch_neg))
res = compute_auc_ci(s, y, n_bootstrap=1000)
print(res) # {'auc': ..., 'ci': (..., ...), 'n_bootstrap': 1000}
Annex GG “adult chest / spinal rod” example
- Config:
configs/adult_chest_spinal_rod.yaml - Notebook:
notebooks/annex_gg_full_demo.ipynb
The notebook executes the full flow:
- Load config and generate synthetic images approximating an adult chest with a 6 mm titanium rod and a 5 mm lesion adjacent to the rod centerline.
- Preview grid counts and an example slice.
- ROI extraction and channel learning (PCA).
- CHO template + AUC per (dose, contrast) for both FBP and MAR.
- Paired one‑tailed t‑test and ΔAUC bias assessment.
- Heatmaps for AUC and ΔAUC.
- CSV tables (Annex‑GG‑style) in
outputs/.
The synthetic generator produces realistic streak‑like artifacts and dose‑dependent noise; MAR reduces streak amplitude and introduces mild smoothing.
API Highlights
from mareval import (
build_pca_channels, cho_template, cho_decision_values,
compute_auc, compute_auc_ci, paired_ttest_one_tailed, delta_auc_bias_assessment,
generate_synthetic_study, extract_roi, batch_extract_rois,
make_parameter_grid, save_auc_table_csv, save_delta_auc_table_csv
)
- CHO
build_pca_channels(rois, n_channels=16, whiten=True)cho_template(ch_pos, ch_neg, lambda_reg=1e-3)cho_decision_values(ch_samples, w)
- AUC & Stats
compute_auc(values, labels) -> floatcompute_auc_ci(values, labels, n_bootstrap=2000) -> dictpaired_ttest_one_tailed(a, b) -> (delta_mean, p_one)delta_auc_bias_assessment(auc_fb, auc_mar) -> dict
- Simulator flow
generate_synthetic_study(cfg_dict)extract_roi(img, center, size)/batch_extract_rois([...], centers, size)make_parameter_grid(...)save_auc_table_csv(...),save_delta_auc_table_csv(...)
---
## Tests / CI
A light **smoke test** covers the end‑to‑end pipeline on a tiny synthetic set:
pytest -q
GitHub Actions runs the tests across 3.9–3.12.
---
## Citation
If you use `mar-eval` in your research, please cite:
> C.D. Cocchiaraley, *Annex GG — Objective evaluation of Metal Artifact Reduction algorithms in CT imaging*, Proposed addition to IEC 60601-2-44 Ed. 4 (2025).
---
## Versioning
- This update introduces **v0.3.0** with simulator workflow, unified Annex‑GG notebook, and reporting/visualization helpers.
- Version tags are used to align releases with document snapshots (e.g., Annex‑GG draft refs).
---
## License
MIT
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
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 mar_eval-0.3.0.tar.gz.
File metadata
- Download URL: mar_eval-0.3.0.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bdd81f6519645a0c344b893080c42e539b0a6f10a541708a23a14ccfaa54877
|
|
| MD5 |
ab114f4e10d8eca2d75d33325c810fae
|
|
| BLAKE2b-256 |
989002744b74628953766ddfb06c48048df42c97775ca4dc5c8e9a8a8c08631b
|
File details
Details for the file mar_eval-0.3.0-py3-none-any.whl.
File metadata
- Download URL: mar_eval-0.3.0-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0085a58f17015b354e3ae148fcdf6838954258529106bd64231e5ec0e885488
|
|
| MD5 |
91afd01437305a1f8e18ae7644cb9240
|
|
| BLAKE2b-256 |
778b6479980b84e826c31bfcff437b418b1cc76343c4962f364cd55920a6f942
|