No project description provided
Project description
AxCorSRMRI
Self-Supervised Realistic Through-Plane MRI Super Resolution from Clinical 2D Axial and Coronal Acquisition.
Installation
pip install torch==2.3.1+cu118 torchvision --index-url https://download.pytorch.org/whl/cu118
pip install axcorsrmri
Manual install
git clone https://github.com/TechnionComputationalMRILab/AxCorSRMRI.git
cd AxCorSRMRI
pip install -e .
Instruction
A full example can be seen in sample.ipynb
.
- Organize your data: Start by making sure your Axial and Coronal files for each case share the same case ID at the beginning of their filenames. For instance, both Axial and Coronal files for a case numbered "001" should begin with "001". For example: 001_ax.nii.gz and 001_cor.nii.gz.
- Preprocess the data: For the model, the coronal data must be resampled isotropically.
from axcorsrmri import resample_cases
path_to_data_files = r"./data/"
resample_cases(path_dir = path_to_data_files)
- Create database: Creates a CSV file that acts as a database. This will include the file paths for the coronal, axial, and isotropic files.
from axcorsrmri import create_database
path_to_data_files = r"./data/"
create_database(
path_to_data_files,
train_frac=0.8,
test_frac=0.1,
num_folds=1
)
- Set the main framework and model hyperparameters. For a detailed explanation of each parameter, check the
parameter_dictionary.txt
file. The default training parameters are already established in setup_parser().
override_args = {
"path_to_set": r"./data/",
"path_to_results": r"./results/",
...
}
args = parser_setup(override_args)
- Prepare your data for training: To get your data ready for training your model, you will need to create three datasets:
- Training Set: This is the largest part of your data and is used to teach your model.
- Validation Set: This set helps you fine-tune your model's performance during training without overfitting.
- Test Set: After training, you'll use this set to check how well your model performs on new, unseen data.
from axcorsrmri import initialize_data
dl_train, dl_valid_lr, dl_valid_hr, dl_test_lr, dl_test_hr, result_dir, writer, config = initialize_data(args)
- Train, valid and test the model.
from axcorsrmri import training_validation_test
training_validation_test(dl_train , dl_valid_lr,dl_valid_hr,dl_test_lr,dl_test_hr,result_dir,writer,config)
- If you have a trained model and want to use it on all the files in a folder, making sure they're isotropically resampled
from axcorsrmri import test_parser_setup, reconstruct_SR_volumes_in_folder
override_args_test = {
"path_to_set": r"./data/",
"path_to_results": r"./results/",
...
}
test_args = test_parser_setup(override_args_test)
reconstruct_SR_volumes_in_folder(test_args)
- If you'd like to keep an eye on your training progress, you can use TensorBoard package.
tensorboard --logdir=r"./results/directory_to_trained_model/"
This model was trained using four Nvidia A100 40G cards. It took about 33 hours to train for 1000 epochs. So, if you're using just one GPU, it would likely take around 120 hours to train.
License
For this project, we incorporated code from the following sources-
[1] Lu, Z., Liu, H., Li, J., & Zhang, L. (2021). Efficient Transformer for Single Image Super-Resolution. ArXiv, abs/2108.11084.
[2] K. Prajapati et al., "Direct Unsupervised Super-Resolution Using Generative Adversarial Network (DUS-GAN) for Real-World Data," in IEEE Transactions on Image Processing, vol. 30, pp. 8251-8264, 2021, doi: 10.1109/TIP.2021.3113783. keywords: {Training;Degradation;Generative adversarial networks;Superresolution;Task analysis;Unsupervised learning;Quality assessment;Unsupervised learning;image quality;image enhancement;image reconstruction;spatial resolution;artificial neural networks;interpolation},
[3] FID and KID calculation are made by PIQ package - Kastryulin, Sergey & Zakirov, Jamil & Prokopenko, Denis & Dylov, Dmitry. (2022). PyTorch Image Quality: Metrics for Image Quality Assessment.
[4] InceptionV3 implementation is taken from https://github.com/mseitzer/pytorch-fid
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
File details
Details for the file axcorsrmri-0.0.5.tar.gz
.
File metadata
- Download URL: axcorsrmri-0.0.5.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46e0e3ac9f90d432e2dac07ca2fe3dbff022c4e369c12efd17a8b5557373bb88 |
|
MD5 | 0aafe940aa897dbd6e31f73e246bf29b |
|
BLAKE2b-256 | 3eb51efa3196f8f67e04d0fee996636188c562e5da76a1b11eec20952eadd335 |
File details
Details for the file axcorsrmri-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: axcorsrmri-0.0.5-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8afa78724ff5e9da617a48628b68bd01424160bbc52f07e90a7034364baea0f7 |
|
MD5 | f37d6ad2bbdf51e97a56920d768f12e2 |
|
BLAKE2b-256 | 587eaeff74ecba6af81462a06aa607930e7d9ce67632da6c2028079cd3a5ee14 |