Giter Club home page Giter Club logo

pymrstrain's Introduction

PyMRStrain

PyMRStrain is a open source generator of synthetic Complementary SPAMM and DENSE images.

Get started

To generate CSPAMM images, in Python simply do

from PyMRStrain import *
import numpy as np

# Parameters
p = Parameters(time_steps=18)

# Encoding frequency
ke = 0.07               # encoding frequency [cycles/mm]
ke = 1000*2*np.pi*ke    # encoding frequency [rad/m]

# Create complimentary image
I = CSPAMMImage(FOV=np.array([0.2, 0.2, 0.04]),
          center=np.array([0.0,0.0,0.03]),
          resolution=np.array([100, 100, 1]),
          encoding_frequency=np.array([ke,ke,0]),
          T1=0.85,
          flip_angle=15*np.pi/180,
          encoding_angle=90*np.pi/180,
          off_resonance=phi,
          kspace_factor=15,
          slice_thickness=0.008,
          oversampling_factor=2,
          phase_profiles=50)

# Spins
spins = Spins(Nb_samples=1000000, parameters=p)

# Create phantom object
phantom = Phantom(spins, p, patient=False, write_vtk=False)

# EPI acquisiton object
artifact = EPI(receiver_bw=128*1000,
               echo_train_length=10,
               off_resonance=200,
               acq_matrix=I.acq_matrix,
               spatial_shift='top-down')

# Generate images
kspace_0, kspace_1, kspace_in, mask = I.generate(artifact, phantom, p)

# Complementary images
u = u0 - u1

# Plots
if MPI_rank==0:
    multi_slice_viewer(np.abs(u[:,:,0,0,:]))
    multi_slice_viewer(np.abs(u[:,:,0,1,:]))
    multi_slice_viewer(np.abs(kspace_0.k[:,:,0,0,:]))
    multi_slice_viewer(np.abs(kspace_0.k[:,:,0,1,:]))

and run from a terminal with

mpirun -n nb_proc python3 foo.py

Resulting images look like this:

CSPAMM image with epi-like artifacts CSPAMM kspace with epi-like artifacts
CSPAMM image CSPAMM image

Installation

git clone https://github.com/hernanmella/pymrstrain
cd pymrstrain
python3 setup.py install

Installation with Docker

To build the docker image run the following instruction in the command line:

docker build --rm . -t pymrstrain

Once the building process has finished, run the following to start the PyMRStrain Docker container:

docker run -ti -v "path/to/folder":"/home/pymrstrain" pymrstrain

If you wish to run the container with plotting support, i.e., allowing to the container to show images, first run:

sudo apt-get install x11-xserver-utils && xhost +

and finally, use the following instruction to start the container:

docker run --rm -it \
   --user="pymrstrain" \
   --env="DISPLAY" \
   --volume="/etc/group:/etc/group:ro" \
   --volume="/etc/passwd:/etc/passwd:ro" \
   --volume="/etc/shadow:/etc/shadow:ro" \
   --volume="/etc/sudoers.d:/etc/sudoers.d:ro" \
   --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
   -v "/home/hernan/Git/pymrstrain/demo":"/home/pymrstrain" pymrstrain

Dependencies

The dependencies of the project are listed in the files install_dependencies.sh and Dockerfile.

pymrstrain's People

Contributors

hmella avatar

Stargazers

laozinan avatar

Watchers

James Cloos avatar Francisco Sahli Costabal avatar  avatar laozinan avatar

Forkers

aldapla

pymrstrain's Issues

Images are not properly generated when resolution is even

When the resolution is even, the generated images at the first cardiac phase seems to be noisy. To reproduce the issue consider running the demo/demo_EXACT_2D.py using resolutions of [33,33] and [32,32], which give the following results:
drawing svg.

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.