GithubHelp home page GithubHelp logo

aopsmath99 / mimmri Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 1.0 1.54 MB

Attempts at using masked image modeling for MRI reconstruction. This repository makes use of modified SimMIM code and ViT and Swin encoder architectures. It also includes an unimplemented SwinRec encoder.

License: MIT License

Python 100.00%

mimmri's Introduction

MIMMRI

Welcome to Masked Image Modeling MRI Reconstruction Imaging (MIMMRI)! This respository contain code that evaluates and modifies basline code for masked image modeling. Specifically, this code was used for the purpose of evaluating masked image modeling for MRI reconstruction. To get started with this repository, follow the below instructions.

Research Paper

Introduction

This study follows the use of Masked Image Modeling (MIM). It primarily uses code from the baseline SimMIM model (https://github.com/microsoft/SimMIM), which has been modified for reconstruction purposes. The model uses two primary encoders: The Swin Transformer and the Vision Transformer. Some changes were made to the overall algorithm of these models, consisting largely of removing extraneous methods and adding additional masking functions to simulate undersampling. The primary changes made were to hyperparameters and implementation, as well as the addition of new encoders like the SwinRecNet. It is important to note that, so far, this model only produces a reconstructed k-space, and the model is currently being worked on to produce the actual MRI image (still working out specifics). The basic Inverse Fourier transform is not applicable in this case since the image loses its complex dimension when saves as a PNG file.

Dataset

This study makes use of Facebook's fastmri dataset (https://fastmri.org/). Specifically, this study uses only the validation set for knee-MRI images, split 80/20 for train/test. The data is downloaded as an h5 file, and each h5 file contains approximately 35* images of k-space and MR images *(30-40 per file). This data was saved as a .png files before being passed thorugh the model, and augmented only by resizing (mostly centercrop) to keep details.

Setup

Run the following commands to obtain the necessary setup requirements:

#clone apex repo
git clone https://github.com/NVIDIA/apex
cd apex

#install apex
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
cd ..

#clone repo
git clone https://github.com/Aopsmath99/MIMMRI
cd MIMMRI

#install requirements
pip install -r requirements.txt

The model that found the most success can be trained and run below:

Train given model and evaluate

torchrun simmim_main.py --cfg=swin100epwin6.yaml --amp-opt-level='O0' --local_rank=1

Config.py contain several other valuable configs, and other encoders can be found in the models folder along with the main SimMIM folder. Each of these encoders were modified by me for the purpose of reconstruction (and formatting for the SimMIM baseline model), but improvements are always needed and greatly welcome. This project was conducted over a brief 6-week time period, meaning there is much room for improvement. This repo will likely continue to be updated thorughout the next year with improvements.

This repository contains dozens of useful implementations that are not all used in the above code. Feel free to use any implementation found in this repository for any use.

Results

In current state run of the above command, the model achieved structural similarity values of over 99.5% and loss values of less than 0.01 during validation, with training loss values dipping below 0.005. Full Dataset

Acknowledgements:

I would like to thank Arghya Pal, PhD and Kevin Cho, PhD from the Psychiatry Neuroimaging lab at the Harvard Medical School for helping me setup up this repository and project, and for answering the multitude of questions I asked while I worked.

mimmri's People

Contributors

aopsmath99 avatar

Stargazers

wenkui.hou avatar Devansh Khandekar avatar  avatar Kang Ik Kevin Cho avatar

Watchers

Kostas Georgiou avatar  avatar

Forkers

alexlogo

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.