This is the code for 'Performance Evaluation of Features Extracted from Pretrained Deep Networks on Radiomic Datasets'.
To run the code, first create a virtual environment and download a copy of mmpretrain
source /home/aydin/.anaconda3/etc/profile.d/conda.sh
conda create --name mmpretrain python=3.8 -y
conda activate mmpretrain
pip3 install torch torchvision torchaudio
git clone https://github.com/open-mmlab/mmpretrain.git
cd mmpretrain
pip install -U openmim
mim install -e .
For radimagenet we also need an older version of tensorflow:
pip3 install tensorflow==2.7
.
Then also install all requirements pip install -r requirements.txt
.
Customize your folder paths in parameters.py
. in the following we will
assume the base path is /data/data/radSSL
.
All data must be placed in /data/radDatabase
, e.g.
/data/radDatabase/HN-CHUS-057/Image.nii.gz
. The data is from WORC
or TCIA and can be downloaded there.
Then resample the scans by
python3 ./resampleScans.py
. This will make them 1x1x1 mm3.
Nearly all models come from mmPretrain. These will be downloaded automatically.
The networks trained on medical data need to be downloaded manually.
The pretrained models need to be put into /data/data/radSSL/pretrained
.
These models (both of them) do not properly work with GPU right now,
either because of batch size of 1 (for 3D networks all scans are get processed separately, so no batching with the current code), or because the batch isn't properly
processed (Keras thing...). For now, we ignore this problem. After all this has to be
computed only once.
These are 2D networks. The github repo is at https://github.com/BMEII-AI/RadImageNet
These are 3D networks. The github repo is at https://github.com/Tencent/MedicalNet
After all data is downloaded and resampled, 2D slices for the networks
are generated by ./extractSlices.py
. The slices will be at /data/data/radSSL/slices
.
Finally, the features from all networks (and generic models) are extracted
by extractFeatures.py
. This will take a long time. It tries to cache
the data across the cross-validation folds (which is ok since we do not train/finetune the networks).
After all feature sets are extracted, these will be used to train classifiers.
This training can be started by train.py
. This might take 1-2 days as well.
The results of the classifiers will be stored in /data/data/radSSL/results
Finally, the evaluation can be started by evaluate.py
. It will generate
results in ./results
and paper-ready plots in ./paper
.
All data is copyrighted by the corresponding licence holders.
The license for this code is MIT:
Copyright 2023, Aydin Demircioglu
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.