Code Monkey home page Code Monkey logo

active-mri-acquisition's Introduction

CircleCI License: MIT

Reinforcement learning environment for Active MRI Acquisition

A Reinforcement learning environment to facilitate research on active MRI acquisition. The goal of active-mri-acquisition is to provide a convenient gym-like interface to test the use of reinforcement learning and planning algorithms for subject-specific acquisition sequences of MRI scans.

This repository also contains scripts to replicate the experiments performed in:

Luis Pineda, Sumana Basu, Adriana Romero, Roberto Calandra, Michal Drozdzal, "Active MR k-space Sampling with Reinforcement Learning". MICCAI 2020.

The data to produce the plot in Figure 4 can also be found at this link. Once extracted, the folder structure should be easy to understand, corresponding to acceleration case, policy, and metric, and one file per folder. The file has a dictionary on which doing loaded_dict[time_step]["all"][image_idx] gives you the results for the policy at the time step and image index indicated.

See also

fastMRI repository

fastMRI dataset

Getting started

Installation

active-mri-acquisition is a Python 3.7+ library. We suggest creating a new Python environment for this project, for example by running

    conda create --name activemri python=3.7

Also, make sure your Python environment has PyTorch installed with the appropriate CUDA configuration for your system (we have tested it using CUDA 9.2 and 10.1).

Then, to install active-mri-acquisition, clone this repository, then run

    cd active-mri-acquisition
    pip install -e .

If you also want the developer tools for contributing, run

    pip install -e ".[dev]"

To test your installation, run

    python -m pytest tests/core

Configuring the environment

To run the fastMRI environments, you need to configure a couple of things. If you try to run any of the default environments for the first time (for example, see our intro notebook), you will see a message asking you to add some entries to the defaults.json file. This file will be created automatically the first time you run it, located at $USER_HOME/.activemri/defaults.json. It will look like this:

{
  "data_location": "",
  "saved_models_dir": ""
}

To run the environments, you need to fill these two entries. Entry "data_location" must point to the root folder in which you will store the fastMRI dataset (for instructions on how to download the dataset, please visit https://fastmri.med.nyu.edu/). Entry "saved_models_dir" indicates the folder where the environment will look for the checkpoints of reconstruction models.

Documentation

For instructions on how to run the environment, evaluating baselines, and adding your own reconstruction models, please see our documentation.

Running baselines from MICCAI'20 paper

To run evaluation of the algorithms considered in the paper, please take a look at the example scripts.

Citing

@inproceedings{pineda2020activemri,
    author = {Luis Pineda and Sumana Basu and Adriana Romero and Roberto Calandra and Michal Drozdzal},
    title = {{Active MR k-space Sampling with Reinforcement Learning}},
    booktitle = {{International Conference on Medical Image Computing and Computer-Assisted
Intervention}},
    year = {2020},
    publisher="Springer International Publishing",
}

License

active-mri-acquisition is MIT licensed, as found in the LICENSE file.

active-mri-acquisition's People

Contributors

luisenp avatar zihuiwu 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

active-mri-acquisition's Issues

Functions in fft_utils.py does not match version of torch>=1.8

Thanks for this repository.

In the file activemri/experimental/cvpr19_models/models/fft_utils.py, the functions of torch.fft, torch.ifft and torch.rfft of torch<=1.7 are used for the implementation of the Fast Fourier Transform. However, these functions are dropped in the new version of torch>=1.8 and replaced with torch.fft.fft, torch.fft.ifft and torch.fft.rfft. What's more, the packages this code depends on include fastmri which depends on torch>=1.8. The above problems will lead to a bug when running the intro notebook

It would be nice to update fft_utils.py to the new version.

Thanks,
Pu Yang

Shape mismatch issue in FTPASGANRAWModel for raw data

Shape mismatch issue in FTPASGANRAWModel for raw data
https://github.com/fairinternal/Active_Acquisition/blob/master/models/ft_pasganraw_model.py#L56

Traceback (most recent call last):
  File "/private/home/sumanab/.pycharm_helpers/pydev/pydevd.py", line 1741, in <module>
    main()
  File "/private/home/sumanab/.pycharm_helpers/pydev/pydevd.py", line 1735, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/private/home/sumanab/.pycharm_helpers/pydev/pydevd.py", line 1135, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/private/home/sumanab/.pycharm_helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/private/home/sumanab/code/fastMRI/train.py", line 39, in <module>
    model.optimize_parameters()
  File "/private/home/sumanab/code/fastMRI/models/ft_pasganraw_model.py", line 471, in optimize_parameters
    self.backward_D()
  File "/private/home/sumanab/code/fastMRI/models/ft_pasganraw_model.py", line 452, in backward_D
    self.loss_D_fake = self.criterionGAN(pred_fake, False, self.mask, degree=degree, pred_gt=(fake,self.real_B.permute(0,3,1,2)))
  File "/private/home/sumanab/code/fastMRI/models/ft_pasganraw_model.py", line 73, in __call__
    target_tensor = self.get_target_tensor(input, target_is_real, degree, mask, pred_gt)
  File "/private/home/sumanab/code/fastMRI/models/ft_pasganraw_model.py", line 62, in get_target_tensor
    target_tensor[:] = energy
RuntimeError: expand(torch.cuda.FloatTensor{[2, 640]}, size=[1280]): the number of sizes provided (1) must be greater or equal to the number of dimensions in the tensor (2)

Process finished with exit code 1

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.