Skip to content

This repository contains the implementation of the paper "Anomaly Detection in Thoracic CT - A Public Benchmark based on CT-RATE" published at BVM 2026.

License

Notifications You must be signed in to change notification settings

franziskaweber/CT-RATE-AD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anomaly Detection in Thoracic CT - A Public Benchmark Based on CT-RATE

This repository contains the implementation of the paper Anomaly Detection in Thoracic CT - A Public Benchmark based on CT-RATE published at BVM 2026.

Installation

The implementation was done in Python 3.12. The required packages and versions are listed in requirements.txt.

Dataset

In the paper, the dataset CT-RATE-AD for anomaly detection in thoracic CT is curated based on the public dataset CT-RATE. CT-RATE-AD consists of:

  • training set of 3565 healthy samples (listed in data/data_csv/train_healthy.csv)
  • validation set of 500 healthy samples (listed in data/data_csv/valid_healthy.csv)
  • test set of 500 healthy and 500 unhealthy samples (listed in data/data_csv/test_healthy.csv and data/data_csv/test_unhealthy.csv)

Download the samples from CT-RATE and put them into data/dataset/ distributed in the subdirectories train/healthy, valid/healthy, test/healthy, and test/unhealthy.

Then resample the data to 0.75 mm spacing in $x$- and $y$- and 1.5 mm spacing in $z$-direction with data/resample.py. The resampled scans will be stored in data/preprocessed_dataset.

Methods

To establish a baseline on CT-RATE-AD, various anomaly detection methods are evaluated in the paper. The following results were obtained:

Method AUROC AP Specificity @ 95% Sensitivity
Voxel Intensity 0.5830 0.5672 0.0714
CT-FM 0.5707 0.5871 0.0500
2D VAE 0.6463 0.6212 0.1567
3D VAE 0.6455 0.6138 0.1486
CP + nnU-Net 2d 0.5389 0.5410 0.0000
CP + nnU-Net 3d_lr 0.5315 0.5100 0.0653
CP + nnU-Net 3d_fr 0.5623 0.5266 0.1586

Voxel Intensity

The voxel-intensity-based methods can be run with methods/voxel_intensity.py. The resulting AUROC, AP, and specificity at 95% sensitivity are printed to the terminal.

CT-FM

  1. Compute the CT-FM embeddings of the volumes with methods/ct-fm/compute_embeddings.py. The resulting embeddings are stored as pkl files in methods/ct-fm/embeddings.
  2. Fit a GMM on the embeddings with methods/ct-fm/fit_GMM.py. The resulting GMM is stored as methods/ct-fm/gmm.joblib.
  3. Get the metrics of this method with methods/ct-fm/evaluate.py.

VAE

  1. Train the VAE with methods/vae/train.py specifying the dimensionality (2 or 3) via the command line parameter --spatial_dims. The trained model is saved as vae2d_best_val_30.pth or vae3d_best_val_30.pth.
  2. Get the metrics of this method with methods/vae/evaluate.py specifying the dimensionality via --spatial_dims.
  3. The reconstruction of a specific volume can be obtained with methods/vae/inference.py specifying the dimensionality via --spatial_dims and the path to the volume via --vol_path. The reconstructed volume is saved in methods/vae/recon_2d or methods/vae/recon_3d.

Cut-Paste

  1. Insert synthetic anomalies into the training and validation volumes with methods/cp/insert_anomalies.py. The modified volumes are stored in methods/cp/nnUNet/nnUNet_raw/Dataset001_CT-RATE_CP/imagesTr and the binary masks of the inserted anomalies in methods/cp/nnUNet/nnUNet_raw/Dataset001_CT-RATE_CP/labelsTr.
  2. Train an nnU-Net on the segmentation of the synthetic anomalies.
    1. Set the environment variables:
      export nnUNet_raw="methods/cp/nnUNet/nnUNet_raw"
      export nnUNet_preprocessed="/methods/cp/nnUNet/nnUNet_preprocessed"
      export nnUNet_results="/methods/cp/nnUNet/nnUNet/nnUNet_results"
      
    2. Run the planning and preprocessing with nnUNetv2_plan_and_preprocess -d 1.
    3. Train the different configurations of the nnU-Net with nnUNetv2_train 1 UNET_CONFIGURATION FOLD --npz with
      • UNET_CONFIGURATION in {2d, 3d_fullres, 3d_lowres}
      • FOLD in {0, ..., 4} for each configuration
    4. Copy the healthy and unhealthy test samples into nnUNet/nnUNet_raw/Dataset001_CT-RATE_CP/imagesTs and insert _0000 before .nii.gz into the file names.
    5. Get the inference and postprocessing commands for each configuration with nnUNetv2_find_best_configuration 1 -c UNET_CONFIGURATION with UNET_CONFIGURATION in {2d, 3d_fullres, 3d_lowres}.
    6. Execute the obtained inference and postprocessing instructions for each configuration specifying nnUNet/nnUNet_raw/Dataset001_CT-RATE_CP/imagesTs as input directory and /nnUNet/nnUNet_results/Dataset001_CT-RATE_CP/nnUNetTrainer__nnUNetPlans__{CONF}/test_results with CONF in {2d, 3d_fullres, 3d_lowres} as output directory.
  3. Get the metrics of this method with methods/cp/evaluate.py.

Contact

In case of any questions, please contact me at franziska.fw.weber@fau.de.

About

This repository contains the implementation of the paper "Anomaly Detection in Thoracic CT - A Public Benchmark based on CT-RATE" published at BVM 2026.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages