Code Monkey home page Code Monkey logo

fastmri's Introduction

fastMRI

LICENSE Build and Test

Website | Dataset | GitHub | Publications

Accelerating Magnetic Resonance Imaging (MRI) by acquiring fewer measurements has the potential to reduce medical costs, minimize stress to patients and make MR imaging possible in applications where it is currently prohibitively slow or expensive.

fastMRI is a collaborative research project from Facebook AI Research (FAIR) and NYU Langone Health to investigate the use of AI to make MRI scans faster. NYU Langone Health has released fully anonymized knee and brain MRI datasets that can be downloaded from the fastMRI dataset page. Publications associated with the fastMRI project can be found at the end of this README.

This repository contains convenient PyTorch data loaders, subsampling functions, evaluation metrics, and reference implementations of simple baseline methods. It also contains implementations for methods in some of the publications of the fastMRI project.

Documentation

The fastMRI Dataset

There are multiple publications describing different subcomponents of the data (e.g., brain vs. knee) and associated baselines. All of the fastMRI data can be downloaded from the fastMRI dataset page.

Code Repository

For code documentation, most functions and classes have accompanying docstrings that you can access via the help function in IPython. For example:

from fastmri.data import SliceDataset

help(SliceDataset)

Dependencies and Installation

Note: Contributions to the code are continuously tested via GitHub actions. If you encounter an issue, the best first thing to do is to try to match the tests environment in setup.cfg, e.g., pip install --editable ".[tests]" when installing from source.

Note: As documented in Issue 215, there is currently a memory leak when using h5py installed from pip and converting to a torch.Tensor. To avoid the leak, you need to use h5py with a version of HDF5 before 1.12.1. As of February 16, 2022, the conda version of h5py 3.6.0 used HDF5 1.10.6, which avoids the leak.

First install PyTorch according to the directions at the PyTorch Website for your operating system and CUDA setup. Then, run

pip install fastmri

pip will handle all package dependencies. After this you should be able to run most of the code in the repository.

Installing Directly from Source

If you want to install directly from the GitHub source, clone the repository, navigate to the fastmri root directory and run

pip install -e .

Package Structure & Usage

The repository is centered around the fastmri module. The following breaks down the basic structure:

fastmri: Contains a number of basic tools for complex number math, coil combinations, etc.

  • fastmri.data: Contains data utility functions from original data folder that can be used to create sampling masks and submission files.
  • fastmri.models: Contains reconstruction models, such as the U-Net and VarNet.
  • fastmri.pl_modules: PyTorch Lightning modules for data loading, training, and logging.

Examples and Reproducibility

The fastmri_examples and banding_removal folders include code for reproducibility. The baseline models were used in the arXiv paper.

A brief summary of implementions based on papers with links to code follows. For completeness we also mention work on active acquisition, which is hosted in another repository.

Testing

Run pytest tests. By default integration tests that use the fastMRI data are skipped. If you would like to run these tests, set SKIP_INTEGRATIONS to False in the conftest.

Training a model

The data README has a bare-bones example for how to load data and incorporate data transforms. This jupyter notebook contains a simple tutorial explaining how to get started working with the data.

Please look at this U-Net demo script for an example of how to train a model using the PyTorch Lightning framework.

Submitting to the Leaderboard

NOTICE: As documented in Discussion 293, the fastmri.org domain was transferred from Meta ownership to NYU ownership on 2023-04-17, and NYU has not yet rebuilt the site. Until the site and leaderbaords are rebuilt by NYU, leaderboards will be unavailable. Mitigations are presented in Discussion 293.

License

fastMRI is MIT licensed, as found in the LICENSE file.

Cite

If you use the fastMRI data or code in your project, please cite the arXiv paper:

@misc{zbontar2018fastMRI,
    title={{fastMRI}: An Open Dataset and Benchmarks for Accelerated {MRI}},
    author={Jure Zbontar and Florian Knoll and Anuroop Sriram and Tullie Murrell and Zhengnan Huang and Matthew J. Muckley and Aaron Defazio and Ruben Stern and Patricia Johnson and Mary Bruno and Marc Parente and Krzysztof J. Geras and Joe Katsnelson and Hersh Chandarana and Zizhao Zhang and Michal Drozdzal and Adriana Romero and Michael Rabbat and Pascal Vincent and Nafissa Yakubova and James Pinkerton and Duo Wang and Erich Owens and C. Lawrence Zitnick and Michael P. Recht and Daniel K. Sodickson and Yvonne W. Lui},
    journal = {ArXiv e-prints},
    archivePrefix = "arXiv",
    eprint = {1811.08839},
    year={2018}
}

If you use the fastMRI prostate data or code in your project, please cite that paper:

@misc{tibrewala2023fastmri,
  title={{FastMRI Prostate}: A Publicly Available, Biparametric {MRI} Dataset to Advance Machine Learning for Prostate Cancer Imaging},
  author={Tibrewala, Radhika and Dutt, Tarun and Tong, Angela and Ginocchio, Luke and Keerthivasan, Mahesh B and Baete, Steven H and Chopra, Sumit and Lui, Yvonne W and Sodickson, Daniel K and Chandarana, Hersh and Johnson, Patricia M},
  journal = {ArXiv e-prints},
  archivePrefix = "arXiv",
  eprint={2304.09254},
  year={2023}
}

List of Papers

The following lists titles of papers from the fastMRI project. The corresponding abstracts, as well as links to preprints and code can be found here.

  1. Zbontar, J.*, Knoll, F.*, Sriram, A.*, Murrell, T., Huang, Z., Muckley, M. J., ... & Lui, Y. W. (2018). fastMRI: An Open Dataset and Benchmarks for Accelerated MRI. arXiv preprint arXiv:1811.08839.
  2. Zhang, Z., Romero, A., Muckley, M. J., Vincent, P., Yang, L., & Drozdzal, M. (2019). Reducing uncertainty in undersampled MRI reconstruction with active acquisition. In CVPR, pages 2049-2058.
  3. Defazio, A. (2019). Offset Sampling Improves Deep Learning based Accelerated MRI Reconstructions by Exploiting Symmetry. arXiv preprint, arXiv:1912.01101.
  4. Knoll, F.*, Zbontar, J.*, Sriram, A., Muckley, M. J., Bruno, M., Defazio, A., ... & Lui, Y. W. (2020). fastMRI: A Publicly Available Raw k-Space and DICOM Dataset of Knee Images for Accelerated MR Image Reconstruction Using Machine Learning. Radiology: Artificial Intelligence, 2(1), page e190007.
  5. Knoll, F.*, Murrell, T.*, Sriram, A.*, Yakubova, N., Zbontar, J., Rabbat, M., ... & Recht, M. P. (2020). Advancing machine learning for MR image reconstruction with an open competition: Overview of the 2019 fastMRI challenge. Magnetic Resonance in Medicine, 84(6), pages 3054-3070.
  6. Sriram, A., Zbontar, J., Murrell, T., Zitnick, C. L., Defazio, A., & Sodickson, D. K. (2020). GrappaNet: Combining parallel imaging with deep learning for multi-coil MRI reconstruction. In CVPR, pages 14315-14322.
  7. Recht, M. P., Zbontar, J., Sodickson, D. K., Knoll, F., Yakubova, N., Sriram, A., ... & Zitnick, C. L. (2020). Using Deep Learning to Accelerate Knee MRI at 3T: Results of an Interchangeability Study. American Journal of Roentgenology, 215(6), pages 1421-1429.
  8. Pineda, L., Basu, S., Romero, A., Calandra, R., & Drozdzal, M. (2020). Active MR k-space Sampling with Reinforcement Learning. In MICCAI, pages 23-33.
  9. Sriram, A.*, Zbontar, J.*, Murrell, T., Defazio, A., Zitnick, C. L., Yakubova, N., ... & Johnson, P. (2020). End-to-End Variational Networks for Accelerated MRI Reconstruction. In MICCAI, pages 64-73.
  10. Defazio, A., Murrell, T., & Recht, M. P. (2020). MRI Banding Removal via Adversarial Training. In Advances in Neural Information Processing Systems, 33, pages 7660-7670.
  11. Muckley, M. J.*, Riemenschneider, B.*, Radmanesh, A., Kim, S., Jeong, G., Ko, J., ... & Knoll, F. (2021). Results of the 2020 fastMRI Challenge for Machine Learning MR Image Reconstruction. IEEE Transactions on Medical Imaging, 40(9), pages 2306-2317.
  12. Johnson, P. M., Jeong, G., Hammernik, K., Schlemper, J., Qin, C., Duan, J., ..., & Knoll, F. (2021). Evaluation of the Robustness of Learned MR Image Reconstruction to Systematic Deviations Between Training and Test Data for the Models from the fastMRI Challenge. In MICCAI MLMIR Workshop, pages 25–34,
  13. Bakker, T., Muckley, M.J., Romero-Soriano, A., Drozdzal, M. & Pineda, L. (2022). On learning adaptive acquisition policies for undersampled multi-coil MRI reconstruction. In MIDL, pages 63-85.
  14. Radmanesh, A.*, Muckley, M. J.*, Murrell, T., Lindsey, E., Sriram, A., Knoll, F., ... & Lui, Y. W. (2022). Exploring the Acceleration Limits of Deep Learning VarNet-based Two-dimensional Brain MRI. Radiology: Artificial Intelligence, 4(6), page e210313.
  15. Johnson, P.M., Lin, D.J., Zbontar, J., Zitnick, C.L., Sriram, A., Muckley, M., Babb, J.S., Kline, M., Ciavarra, G., Alaia, E., ..., & Knoll, F. (2023). Deep Learning Reconstruction Enables Prospectively Accelerated Clinical Knee MRI. Radiology, 307(2), page e220425.
  16. Tibrewala, R., Dutt, T., Tong, A., Ginocchio, L., Keerthivasan, M.B., Baete, S.H., Lui, Y.W., Sodickson, D.K., Chandarana, H., Johnson, P.M. (2023). FastMRI Prostate: A Publicly Available, Biparametric MRI Dataset to Advance Machine Learning for Prostate Cancer Imaging. arXiv preprint, arXiv:2034.09254.

fastmri's People

Contributors

ad12 avatar adefazio avatar alexslee avatar ant0nsc avatar anuroopsriram avatar arunsathiya avatar dependabot[bot] avatar gabrielziegler3 avatar gaskell-1206 avatar gregbruss avatar gyusang avatar hasibzunair avatar kapoor1992 avatar luisenp avatar mmuckley avatar nikolasmorshuis avatar pjohnson519 avatar sbhadra2020 avatar timsey avatar tullie avatar yuyangxueed avatar z-fabian avatar zaccharieramzi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fastmri's Issues

Varnet training default parameters

Hello, I have been training the e2e varnet on 1 GPU with all the arguments set as default, except the sample rate is changed to 0.2. While the model performs quite well on the validation set (around 0.95 SSIM), it performs quite poorly on the public leaderboard for brain data (SSIM of 0.86 for 4x acceleration and 0.76 for 8x), and the images produced have lots of artifacts. My guess is that this occurs because the default acceleration rate is 4x and I should change it to either 8x or [4, 8], but I feel like there is more to this issue.

Apart from the sample and acceleration rate, are there any other potential reasons that might cause this issue?

No such directory created : experiments/unet

Hello there,

I could only see experiments/lightning_logs directory after running the unet singlecoil baseline for 50 epochs. Where should I find the checkpoints for testing? Another important points is that in lightning_logs directory I can see 4 more directories which are version_0, version_1, version_2 and version_3. Only version_3/checkpoints contain a model checkpoint but I can't find the experiments/unet directory which is mentioned in README. Any ideas please?

Average loss calculation

Thanks for posting the fastMRI code. Would like to know if there is any specific reason for choosing the following weighting scheme for computing the average loss.

avg_loss = 0.99 * avg_loss + 0.01 * loss.item() if iter > 0 else loss.item()

Thanks in advance for your reply.

Regularization Weights

Can someone explain to me what are the acceleration and regularization weights in the metric table of single coil baseline? I want to retrieve my own table for these metrics.

UNET model appears to be incorrect

Hello. I have noticed that the unet model in the code is slightly different from the model used in the arxiv paper (p.17).

The model in the paper has only 1 convolution at the bottom block, whereas the model in the code has two of them.

Although I have found that having this extra convolution increases performance significantly, it may be worth fixing either the code or the paper.

ssim score for unet model

Hello, I am training the baseline unet model on the provided singlecoil data but even after 40 epochs, the ssim score remains relatively unchanged at around 0.667 (same with the nmse which is roughly around 0.033). Is this the expected result? The results of the paper distinguish between PD and PDFS, and different acceleration factors, but I assume that the singlecoil training data includes all of these differences and aggregates the results.

Varnet Demo failing after one epoch

Hi,

I tried running train_varnet_demo.py, with default parameter.
The training runs fine for the epoch 0 and I also get the checkpoint for this zeroth epoch.

However for the epoch 1, the training fails in validation step with 'Out of memory error'.
First, I thought it is an error due to GPU memory (but this should not happen after finishing one epoch).
I tried to change the number of cascade to 4, but still get the same error. I am using GPU with 16 GB RAM.

I tried to figure out, it appears that the dataloader is failing, as I get the following error:
RuntimeError: DataLoader worker (pid 34801) is killed by signal: Killed.
Is there anything happening in dataloader which may cause this issue?

The error happens only when I am running this on the full brain dataset.
When I use a relatively small (Just a few h5 files) subset of brain dataset, I do not get any error and it runs fine for all the epoch?

training blocked when using bn layer

Hi, Thanks for the great project.

I am recently tuning the code. However, I found that the training is blocked at the validation of the first epoch when changing instancenorm layers to bachnorm layers. The same thing happens when I use a SSIM loss instead the L1 loss. Have you met the same problem before? and why do this happens from your opinion?

Ground truth for precomputed sensitivity map

For one of my experiment, I need to run varnet with precomputed sensitivity data. But when I try doing that loss is not getting reduced, instead, it's oscillating. I think the problem is due to the difference between rss of multi channels and rss of multi channels obtained by expansion through sensitivity maps. I also made couple of zero-filled submissions for both these scenarios, rss of multi channels was giving better metrics compared to latter one.

In the varnet paper, it was mentioned that experiments have also been conducted with precomputed sensitivity maps. Is there any trick involved in making the code work for precomputed sensitivity maps? Am I missing something ?

PS: I use bart tool to obtain sensitivity map

VarNet paper knee SSIM results

I am trying to reproduce results for the multicoil knee data using VarNet. I am a bit confused by the discrepancy between the SSIM reported in Table 2 for 8x acceleration with random mask (0.878) and the leaderboard SSIM for the same acceleration in Table 3 (0.890).

Based on the paper's description and the code base I found the following differences between the two experiments:

  • Table 2 result is trained on training data only, Table 3 is trained on training + val data
  • Table 2 result is trained for 50 epochs, Table 3 result for 100 epochs
  • it is not completely clear from the paper, but I assume Table 2 is reported on the validation set and Table 3 on the test set

My understanding is that knee test data also uses random masks and not equispaced.
I don't think these differences only may completely account for the discrepancy. Is there anything else I missed?

Submission not working.

Hello. I recently tried to add some extra submissions on EvalAI.
However, they are still "Running" after several days.
Moreover, the fact that they are running prevents me from making extra submissions.
I have raised this issue on the EvalAI forum but I think that raising it here would be faster.
Could anyone please tell me what has happened with my submission?

h5py file open error

OSError: Unable to open file (file read failed).

In the dataloader init ( I am opening the h5 file and finding the no of slices) and forming a tuple.

In the dataloader iterator ( I am opening the h5 file again with file name and slice no).

I am getting the above mentioned error randomly. What might be the issue ?

EquispacedMaskFunc doesn't generate equidistant masks

Hi,

In the fastMRI paper, we can see that:

For brain, after a random offset from the start, the remaining lines are sampled equidistant from each other with a spacing that achieves the desired acceleration factor.

However, when looking at the masks we have in the data, we can see that the remaining lines are actually not sampled equidistant from each other.
If we look for example at file_brain_AXFLAIR_200_6002441, which has an acceleration factor of 8.
We can see that the lines outside the autocalibration region are actually spaced either by 10 or by 11, and therefore are not equidistant from each other.

I think this is due to the implementation that can be found here. You can see on this line that the rounding might not (and in fact will probably not for acceleration factors that are not integers) preserve the equidistant spacing.

For example, with an acceleration factor of 4 (a center proportion of 8%), with 372 lines to subsample (seed 0), we have the first 4 lines remaining as:

4.,   9.42857143,  14.85714286,  20.28571429

They are perfectly equispaced by the adjusted acceleration factor (5.428571428571429).
After the rounding we have:

4,   9,  15,  20

Now the spacing is either 5 or 6.

I think the problem is that for a given integer acceleration factor, you are not going to have equidistant spacing for all the shapes.

What I did in my implementation (before noticing that the test masks were not following that rule), was to actually fix a number of remaining lines that needed to be placed and determined the spacing between them from that number. However, that means that my acceleration factor is no longer exactly 4, but sometimes lower, sometimes higher.

I am filing this as an issue since the EquispacedMaskFunc class doesn't respect the documentation (or the paper) from what I understand, but I am happy to discuss it in the forum.

is mkl-random 1.0.1 necessary & error in requrement.txt

Hi all,
When I try pip install -r requirement.txt, there are some errors happening.
What I know is that pytorch 0.4.0 cannot be intalled by pip directly. But, mkl-random is incompatible with intel-numpy according to this requirement.txt. there is no mkl-random used in this code, I would like to ask is mkl-random 1.0.1 necessary in this repo?

ERROR: mkl-random 1.0.1 has requirement intel-numpy<1.15,>=1.14, but you'll have intel-numpy 1.15.1 which is incompatible.

Choice of SummaryWriter

I have a question regarding the choice of SummaryWriter. Why did you chose to use tensorboardX rather than torch.utils.tensorboard for it?

Is there some efficiency reason? Or just legacy?

Multi-GPU VarNet training and batch size

My understanding is that the current VarNet training code uses batch size of 1 per GPU. Therefore in the multi-GPU training scenario the effective batch size would be num_gpus * batch_size = num_gpus as the gradients are averaged between GPUs after the backward pass.

According to the paper (and what I can also see in the code) the learning rate is set to 0.0003, but there is no mention of the (effective) batch size used in the experiment. Since the learning rate typically has to be adjusted to the batch size it would be good to know what batch size was used in the experiments (that is how many GPUs used). I expect changes in final SSIM on validation/test set with varying number of GPUs if the learning rate is kept at 0.0003.

ValueError: when running VarNet

I get the following ValueError when I attempt to run the VarNet. Any idea why? I am using the NYU multi-coil knee dataset but just limited (10 training h5py files). I have in my environment pytorch-lightning 0.6.0 and torch 1.3.1 with torchvision 0.4.2.

This is what I am using to train:

python models/varnet/varnet.py --resolution 320 --mode train --challenge multicoil --exp var_net --mask-type random --data-path /media/iva19/multicoil_train/

and that's the error:

INFO:root:gpu available: True, used: True
INFO:root:VISIBLE GPUS: 0
Traceback (most recent call last):
  File "models/varnet/varnet.py", line 374, in <module>
    main()
  File "models/varnet/varnet.py", line 371, in main
    run(args)
  File "models/varnet/varnet.py", line 342, in run
    trainer.fit(model)
  File "/home/iva19/usr/local/miniconda3/envs/fastMRI/lib/python3.6/site-packages/pytorch_lightning/trainer/trainer.py", line 687, in fit
    mp.spawn(self.ddp_train, nprocs=self.num_gpus, args=(model,))
  File "/home/iva19/usr/local/miniconda3/envs/fastMRI/lib/python3.6/site-packages/torch/multiprocessing/spawn.py", line 171, in spawn
    while not spawn_context.join():
  File "/home/iva19/usr/local/miniconda3/envs/fastMRI/lib/python3.6/site-packages/torch/multiprocessing/spawn.py", line 118, in join
    raise Exception(msg)
Exception: 

-- Process 0 terminated with the following error:
Traceback (most recent call last):
  File "/home/iva19/usr/local/miniconda3/envs/fastMRI/lib/python3.6/site-packages/torch/multiprocessing/spawn.py", line 19, in _wrap
    fn(i, *args)
  File "/home/iva19/usr/local/miniconda3/envs/fastMRI/lib/python3.6/site-packages/pytorch_lightning/trainer/distrib_data_parallel.py", line 331, in ddp_train
    self.run_pretrain_routine(model)
  File "/home/iva19/usr/local/miniconda3/envs/fastMRI/lib/python3.6/site-packages/pytorch_lightning/trainer/trainer.py", line 757, in run_pretrain_routine
    self.logger.log_hyperparams(ref_model.hparams)
  File "/home/iva19/usr/local/miniconda3/envs/fastMRI/lib/python3.6/site-packages/pytorch_lightning/logging/base.py", line 14, in wrapped_fn
    fn(self, *args, **kwargs)
  File "/home/iva19/usr/local/miniconda3/envs/fastMRI/lib/python3.6/site-packages/pytorch_lightning/logging/tensorboard.py", line 88, in log_hyperparams
    self.experiment.add_hparams(hparam_dict=params, metric_dict={})
  File "/home/iva19/usr/local/miniconda3/envs/fastMRI/lib/python3.6/site-packages/torch/utils/tensorboard/writer.py", line 292, in add_hparams
    exp, ssi, sei = hparams(hparam_dict, metric_dict)
  File "/home/iva19/usr/local/miniconda3/envs/fastMRI/lib/python3.6/site-packages/torch/utils/tensorboard/summary.py", line 156, in hparams
    raise ValueError('value should be one of int, float, str, bool, or torch.Tensor')
ValueError: value should be one of int, float, str, bool, or torch.Tensor

Bug in MaskFunc (very big bug)

Hello. I would like to point out a bug I found in the code for mask generation.

In the class MaskFunc, I found that "Samples are drawn along the second last dimension".

However, the data is shaped NxHxW, where H, the height, is the frequency encoding dimension and W, the width appears to be the phase encoding dimension.

The current code appears to make down-sampled rows, not down-sampled columns.

If the current mask function is used as-is, this would make a down-sampling along the height dimension, which would be incorrect.

Down-sampling should occur along the phase encoding dimension (the last dimension for this data).

I have found that the test-set data is structured properly.
Down-sampling was done along the phase-encoding dimension (the last dimension in this case).

I would like to request that this bug be fixed so that proper masks are generated along the last dimension of the k-space data.

It might be best to have a new parameter, "ds_axis" (for down-sampling axis) and set -1 as its default.

trouble in run_bart_test.py or run_bart_val.py

When I run run_bart_test.py or run_bart_val.py, the script could not finish normally.
It seems that the child process (bart) was stalled.

To tackle this problem, I modified the run_bart_test.py or run_bart_val.py, and multiprocessing was disabled.
Then, run_bart_test.py or run_bart_val.py could finish normally.

Please create the option for enabling/disabling multiprocessing.

train_unet

hallo,
Im a master-student and I was trying to use Unet model to train a model for mri Reconstruction.
I have an h5 dataet that has my Kspace Information.
I tried to use the model as it is, but there was always the same error raised, that the path mydata.h5//muticoil.val couldnt be found.
I tried to creat data_loader before I train the model to give a defined dataloader for my trainer. The same Issue came that the path mydata.h5//multicoil.train couldn't be found. The error is being raised in the class SliceData() in the file mri_data at the line 40.
Basically, I assumed that the datatransformer has the goal to change the dataset I am using, but it doesnt do the work, so I thought the problem might be in my data, I even used data from mridata.org but still the same error is being raised.
can anyone help me please ?
Thank you
Majd

Packageify fastMRI

This post is intended to both introduce the issue and be modified to keep track of progress.

The fastMRI repository was originally designed for wholly self-contained experiments. This was good for readability as it kept all experimental parameters, models, and training scripts in a single file. At the time, the only deep learning model in the repository was a U-Net, and so having modules or reusable components wasn't as much of a priority.

Since then we've introduced a number of new components to the repository, including the end-to-end variational network and new mask sampling. We've also added PyTorch Lightning. As a result, modular components could be more useful now, but we've generally kept the old structure. Moving towards a more modular structure would help compartmentalize things a bit more, helping users mix modules and samplers into their projects. We could also clearly separate experimental parameters that we've run for leaderboard submissions with exact hyperparameters and keep these experiments frozen in time.

Toward this I'd like to propose to "packageify" fastMRI. This will largely be a code refactor with a few new areas. Essentially, I'm thinking of the following structure:

.
├── fastmri
│   ├── data
│   │   ├── dataset.py
│   │   ├── subsample.py
│   │   ├── transforms.py
│   │   └── volume_sampler.py
│   ├── models
│   │   ├── unet.py
│   │   └── varnet.py
│   ├── evaluate.py
│   ├── recon.py
│   └── mri_module.py
├── experimental
│   ├── cs
│   │   └── run_bart.py
│   ├── unet
│   │   ├── train_unet_demo.py
│   │   ├── unet_brain_challenge_submission_YYYY-MM-DD.py
│   │   └── unet_module.py
│   ├── varnet
│   │   ├── train_varnet_demo.py
│   │   ├── varnet_brain_challenge_submission_YYYY-MM-DD.py
│   │   └── varnet_module.py
│   ├── zero_filled
│   │   └── run_zero_filled.py

The files in experimental would import training_module, update it with their own model and training parameters, and these would be committed to the GitHub to make reproducibility more obvious.

Task list for completing this issue:

  • Refactor basic fastMRI models (unet, varnet, zero_fill, cs) into the framework outlined in this issue.
  • Run new experiments and test leaderboard submissions.
  • Update all PyTorch Lightning training modules to the current version. PTL often breaks backwards compatibility, but hopefully this will be less of a problem going forward.
  • Formatting: apply black and Google comment style formatting consistently throughout package.
  • Update requirements.txt to more up-to-date packages and use >= rather than ==.
  • (Optional) refactor all tests to a tests directory at the top level.
  • (Optional) Distribute on PyPI.

Making these changes should not require modifications to existing working code. Once they're done we can decide about deprecating and removing old folders.

Update fastMRI for PyTorch Lightning 1.0.0

PyTorch Lightning has recently been updated 1.0.0. This means at long last we can expect a bit of stability from the API. In light of this, we should do one more update to the package to bring things up to speed here. Hopefully after this the code will run stably through future updates to both PyTorch Lightning and PyTorch.

This issue will be used to track the last update. I'm also open for comments from people for fix requests throughout the process. This might be the last time the package gets a major update for awhile, depending on community contributions.

If community members could use the latest members of the package and also report issues here, that will help us update things for the future.

Package Updates

  • Add a proper setup.py
  • Move training modules into new fastmri.training_modules.
  • Remove deprecated folders.
  • Remove hyphens from dated files.
  • Add type annotations.
  • Add CircleCI (optional)

PyTorch Lightning Updates

  • Update metrics calculation to comply with current metrics API.
  • Update validation return statements to only return metrics (e.g. here). This should make distributed training more robust and reduce silent NCCL errors.
  • Remove exp_dir variable and have everything based on Lightning default_root_dir.
  • Move all data loaders to main client script to comply with current PTL recommended practice (e.g., here).

PyTorch Updates

  • torch.fft is deprecated in favor of torch.fft.fft operations for future versions of PyTorch. See here. We can have a PR ready for when 1.7 is officially out.
  • Make all models/modules scriptable.

Error submitting to EvalAI (No examples/example_submission.json exists.)

I am currently having a great deal of difficulty uploading my files to EvalAI.

The submission guidelines (See http://fastmri.org/submission_guidelines)
mention "examples/example_submission.json"
for an example of what the submission file to EvalAI should look like.

However, no such file exists on this repo.

Also, the guidelines simply say that the files should be zipped, they do not mention exactly how.

I have currently made a .json file whose contents are identical to the .txt file here.
submission.txt

However, whenever I try to upload my results, it always results in a Status: "Failed" state with the stderr file with the message "Submission file cannot be unzipped".

I have stored my files in Google drive with a student account with shared reading/writing privileges.

I have tried .zip, .tar, .tar.gz files and I have tried having the unzipped file containing a folder and directly opening the .h5 files.

I notice that there are no publicly visible submissions on EvalAI and suspect that several others have had difficulties in uploading/evaluating their files.

I would be most grateful for more detailed instructions and examples of how to submit to the leaderboard.

Many thanks in advance to those who can help out.

Test reconstructions using varnet.py

In the script varnet.py, the test_step function as defined under the class VariationalNetworkModel(MRIModel) seems to be copied from the train_unet.py function and I had to edit it to be consistent with the train_step and validation_step functions in varnet.py. The else branch under def run(args) is also missing model.hparams=args. These created some issues for me while testing the reconstructions and I wanted to verify if these are indeed errors or if I'm missing something. Thanks!

fastwri_dirs.yaml file

Hello, I have a problem here, where can I download this file fastwri_dirs.yaml, thank you so much!

gpus >1 with VarNet, parallel

Hello, I am trying to train the knee datasets by running VarNet with multiple GPUs. Everytime when it finishes the first epoch and is about to enter the second epoch, it gets stuck. However, VarNet with 1 gpu works fine. Can you please help to fix this?

FYI, Unet is OK in my tests with 1 gpu or multi gpus.

isADirectoryError

Hi,
When I was trying to run the model on test data, it shows the isADirectoryError:

~/fastMRI-master$ python models/unet/train_unet.py --mode test --challenge singlecoil --data-path DATA --exp unet --out-dir reconstructions --checkpoint /home/fastMRI-master/experiments/lightning_logs/version_12/checkpoints/

...
...
return _open_file(name_or_buffer, mode)
File "/home/anaconda3/lib/python3.8/site-packages/torch/serialization.py", line 210, in init
super(_open_file, self).init(open(name, mode))
IsADirectoryError: [Errno 21] Is a directory: '/home/fastMRI-master/experiments/lightning_logs/version_12/checkpoints/'

Providing smaller sample data

Hello I've been struggling to get enough space on my laptop for all the training examples. Have we considered create a single data example download available so that one can follow the example provided without downloading the full dataset.

On a related note, I'm curious what's the standard procedure for working with this big of a dataset? Do you use a dev server with a lot of TB of storage on something like AWS or hook up an external hard-drive with sufficient storage?

Thanks!

Regarding dowloading the data

Can I download the uncompressed data ? I am thinking of using aws, since the data is in S3 bucket can I directly get the uncompressed data to my storage ?

Otherwise I have to download the zip file extract it, which consumes twice the memory.

Any suggestions on how to go about this ?

Issues with torch.fft

I tried running some sample code in the provided Jupyter notebook, but keep getting an error "RuntimeError: fft: ATen not compiled with MKL support" on the torch.fft operator.

A GPU is visible to torch (torch.cuda.current_device() = 0). The requirements.txt file had issues finding the appropriate mkl-fft package (both using pip and conda install) and some relevant packages in my virtual environment are:

cudnn = 7.6.0
mkl = 2019.4
mkl_fft = 1.0.12
mkl_random = 1.0.2
python = 3.6.9
torchvision = 0.2.1

Any help would be much appreciated!

Bug in EvalAI Leaderboard

Hello. I recently found a slight bug in the Leaderboard for the fastMRI webpage.

In the photos below, if you look at the detailed view for the PSNR in a submission, the SSIM values are shown instead.

I have checked the EvalAI page and the results there appear to be accurate.

I believe that this is a problem with the webpage.

I hope that this helps with the challenge.

singlecoil


multicoil

What exactly is being called in train_demo:: Possible multi-echo, multi contrast reconstruction

Hi, I'm wondering if someone can clarify exactly what is being called in the train_unet_demo.py. The overall structure is

Main Training Routine:

  1. INIT lightning model
  2. INIT trainer
  3. Start training (or test), followed by build and training + model configuration arguments.

But where does the data transform happen? How is it related to the train_unet.py script where the DataTransform class is defined?

I am attempting to get the U-Net working on "simulated" multi-echo data, first by seeing if I can reconstruct the same image but as a stack of 4 (duplicating the same image and concatenating along some dimension) . Essentially, I want to feed in 4 corrupted images, and get out 4 corrected images. This is just to sanity check that the network is able to handle the dimensions before switching to true multi-echo data, where it could reconstruct multiple echoes at the same time, but where each echo leads to an image of the same underlying anatomy but with a different contrast.

Unable to access .h5 files

I am trying to train the program using the commands mentioned in fastMRI/models/unet/, where I have passed the necessary arguments. I am faced with the following error;

" File "/Users/user./PycharmProjects/fastMRI/fastMRI/data/mri_data.py", line 49, in init
data = h5py.File(fname, 'r')
File "/Users/user/PycharmProjects/fastMRI/venv/lib/python3.7/site-packages/h5py/_hl/files.py", line 408, in init swmr=swmr)
File "/Users/user/PycharmProjects/fastMRI/venv/lib/python3.7/site-packages/h5py/_hl/files.py", line 173, in make_fid

fid = h5f.open(name, flags, fapl=fapl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5f.pyx", line 88, in h5py.h5f.open
OSError: Unable to open file (file signature not found)
"
After some online searches, I found that this error occurs only if the .h5 files are corrupted during download or that the files in specified path are not of .h5 type. But in my case, the files are fine because I can access them when I try from a new script.

I kindly request you to provide your insight into what could be the issue. Thanks in advance.

Submission not approved

I recently submitted a reconstruction to the fastMRI website, but it didn't go through for some reason. This is the feedback I have so far (the icon is not clickable):

image

Is there a way to know why the submission was not approved?

No example json file available in repository

This issue is already present but in closed state. Refer #7.
When can we expect the example json file to be available ?
I wanted to do a submission but there is not example json available.

About acquisitions

Hey,

As in discription, there are two kinds of acquisitions in the single coil data. Are they in pairs? Like one PD data has a corresponding PDFS data? If so, How can I get them by pairs? Thanks a lot.

pretrained model

Is there anyway I can get the pretrained U-net model to download and run?
Thanks in advance.

single GPU memory

I hope to test the VarNet model in terms of replacing the U-net in each cascade by a shallower residual block (RB), which is composed of Conv2D, ReLu, and cat operations.

From the weight-summary reports, the model with U-net has around 30 million parameters, while the one with RB only has 1-2 million. However, the model with RB seems to consume more GPU memory than the one with U-net (sometimes OOM), which somehow looks strange as I would expect the occupied GPU should largely scale with the parameter size of the network.

I was unable to figure it out for a while, and would like to hear your opinion on this issue. Thank you.

A qusetion about the shape of kspace data

The class DataTransform in the models.unet takes the kspace array of shape (rows, cols, 2) for single coil data as input, but the kspace data has shape (rows,cols). How dose the 2 channels come?

Looking forward replying. Thanks.

Running small dataset on CPU

hello, I am running into some issues when I attempt to run the train_unet script on a small dataset on my local environment (which does not have any GPU capabilities).

When I run the script with the --gpus argument set to 0, I get the following error message:
File "/Users/abhinavsaksena/mri/fastMRI/env/lib/python3.7/site-packages/torch/utils/tensorboard/summary.py", line 156, in hparams raise ValueError('value should be one of int, float, str, bool, or torch.Tensor') ValueError: value should be one of int, float, str, bool, or torch.Tensor

If I try to change the --gpu arg to 1, I get the following message:
File "/Users/abhinavsaksena/mri/fastMRI/env/lib/python3.7/site-packages/pytorch_lightning/trainer/distrib_parts.py", line 533, in sanitize_gpu_ids raise MisconfigurationException(message) pytorch_lightning.utilities.debugging.MisconfigurationException: You requested GPUs: [0] But your machine only has: []

How might I go about fixing these issues and run the code on my CPU? Here are some similar issues I found online for reference:
https://github.com/PyTorchLightning/pytorch-lightning/pull/609
https://github.com/PyTorchLightning/pytorch-lightning/issues/899

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.