This project presents a novel weakly supervised anomaly detection (WSAD) algorithm for CT scans, which reduces the annotation workload while providing better performance than conventional methods.
The proposed WSAD algorithm is trained based on scan-wise normal and anomalous annotations, unlike slice-level annotations required in conventional supervised learning. The methodology is motivated by video anomaly detection tasks.
- Python 3.9
- PyTorch 1.13.0
- Cuda 11.7
- Pytorch Image Models (timm)
- Pydicom
- OpenCV
- pandas
- scikit-learn
Download the following dataasets. Both of them are publicly availablle.
- RSNA brain hemorrhage dataset: Brain CT dataset collected from patients with intracranial hemorrhages. The data named "stage_2_train" are only required as they contain both training and testing samples.
- COVID-CTset: Lung CT dataset collected from patients with COVID-19.
Place downloaded data in a local directory, then run the following six scripts one by one for pre-processing downloaded data. Make sure to change /path_to/rsna-intracranial-hemorrhage-detection in each script depenging on where downloaded images are saved.
- 01_dcm2png.py conversts dcm to png files.
- 02_renamepng.py organizes png files to several directories.
- 03_makelabelfile.py creates csv file specifiying groundtruth labels.
- 04_brainextract.py perfomrs skull stipping and segments brain regions.
- 05_makemaskimg.py: creates mask images based on extracted brain regions.
- 06_feature_extractor.py extract features from pretrained models.
Place downloaded data in a local directory, then run the following five scripts one by one for pre-processing downloaded data. Make sure to change /path_to/COVID-CTset in each script depenging on where downloaded images are saved.
- 01_renamepng.py renames downloaded files in an organized manner.
- 02_makelabelfile.py creates csv file specifiying groundtruth labels.
- 03_lungextract.py segments lung regions.
- 04_makemaskimg.py creates mask images based on extracted lung regions.
- 05_feature_extractor.py extract features from pretrained models.
-
Set parameters at parameters.py
-
Run run_train.py
-
Run run_test.py
-
A performance report will be generated.