This is the repository to "Closing the loop for AI-ready Radiology". The models are trained on private and public rsna data in order to detect pulmonary embolism (PE).
Please cite the following paper to reference:
Fuchs M, Gonzalez C, Frisch Y et al. Closing the loop for AI- ready radiology. Fortschr Röntgenstr 2023; DOI 10.1055/ a-2124-1958
This project was financed by the Bundesministerium für Gesundheit(BMG) with the grant [ZMVI1–2520DAT03A]: https://www.bundesgesundheitsministerium.de/ministerium/ressortforschung/handlungsfelder/forschungsschwerpunkte/digitale-innovation/modul-3-smarte-algorithmen-und-expertensysteme/eva-ki.html
The Project is structured into five different sections. The first sections deals with the test, train and evaluation data split (process_input). In the second section a lung segmenter is trained. The segmenter detects the lung and saves the position in bounding boxes (lung_localization). After that, another model is trained for extracting features (seresnext50). Those features are then used to train another model in order to detect pulmonary embolism. Lastly, those results can be visualized by further extracting the raw image and the attention maps.
Each of the previously mentioned sections contains a config.py file. There, all necessary base input and output paths are noted, as well as the hyperparameters if necessary. Make sure, to adapt each necessary parameter. Each config file contains several dictionaries. The dictionary is named after the schema filename_config.
Install all necessary packages by running
pip install -r requirements.txt After that, make sure to adapt all conf.py files for all in- and output paths. Note, that the first section creates the output folders for the following data
-
series_dict.pickle
-
image_dict.pickle
-
series_list_train.pickle
-
image_list_train.pickle
-
series_list_valid.pickle
-
image_list_valid.pickle
-
series_list_test.pickle
-
image_list_test.pickle
After installing the necessary packages and adapting the config files, there are several ways to run this framework.
On the top folder you can find a file called run.sh. You can simply run it, as it starts all subsequent shell files. Make sure to adapt all the output paths from the shell files in the subfolders.
Another way of running the framework is to go into each subfolder and then run all shell files in the following order:
- process_input (run.sh)
- lung_localization (run.sh)
- serexnext50 (run.sh)
- 2nd_level (run.sh)
- seresnext50 (run_inference.sh)
Make sure to adapt the output paths in each shell file, if necessary.
-
Go to process_input and run the following commands to split the data
python process_input_split2.pypython process_input_test.py
-
Now go to lung_localization\split2 and start the following files to train the lung segmenter and save its outputs:
python train.pypython valid.pypython save_bbox_train.pypython save_bbox_valid.pypython save_bbox_test.py
-
Step into the seresnext50 folder and run the following commands to train a feature extractor and to save the features:
python train.pypython valid.pypython save_valid_features.pypython save_train_features.pypython save_test_features.py
-
Step into 2nd_level. There, run either (or both) the files from 1class or 2class
python 1class/seresnext50_256_1class.pypython 1class/validation50_256_1class.pyorpython 2class/seresnext50_128_2class.pypython 2class/validation50_128_2class.py
-
Go back to seresnext50 to run the inference
python extract_raw_image.pypython extract_test_attention_maps.py