Skip to main content

MRI simulation toolkit

Project description

Sycomore — an MRI simulation toolkit

Sycomore is an MRI simulation toolkit providing Bloch simulation, Extended Phase Graphs (EPG) (both regular and discrete, including 3D), and Configuration Models. Sycomore is a Python packge in which all computationnaly-intensive operations are run by a C++ backend, providing a very fast runtime and further acceleration through OpenMP.

Installation

Sycomore requires a C++11 compiler, Python (≥ 3.5) and pybind11. To take full advantage of your CPU, OpenMP is strongly recommended. If you want to validate your build of Sycomore, you should run the unit tests, which require Boost.Test. Sycomore uses CMake, so the simplest way to build it would be to create a build directory inside the source directory, run cmake, then run make:

mkdir build
cd build
cmake ..
make

Additional details are provided in the documentation.

Usage

The following code simulates a single repetition of a simple RARE sequence and plots the transverse magnetization of each echo.

import matplotlib.pyplot
import numpy
import sycomore
from sycomore.units import *

species = sycomore.Species(1000*ms, 100*ms, 1*um**2/ms)
TE = 4*ms
train_length = 40

model = sycomore.epg.Regular(species)
data = numpy.zeros(train_length, dtype=[("time", sycomore.Quantity), ("signal", complex)])

model.apply_pulse(90*deg)
for echo in range(train_length):
    model.apply_time_interval(TE/2)
    model.apply_pulse(180*deg)
    model.apply_time_interval(TE/2)

    data[echo] = (((1+echo)*TE), model.echo)

times = [x.convert_to(ms) for x in data["time"]]
magnitude = numpy.abs(data["signal"])
matplotlib.pyplot.plot(times, magnitude, ".", label="Simulated")
matplotlib.pyplot.plot(
    times, [numpy.exp(-(x*species.R2).magnitude) for x in data["time"]],
    label="$T_2$ decay")

matplotlib.pyplot.ylim(0,1)
matplotlib.pyplot.xlabel("Time (ms)")
matplotlib.pyplot.ylabel("Magnitude")
matplotlib.pyplot.legend()
matplotlib.pyplot.show()

T2 decay in RARE

The features and data structures are described in the documentation:

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

sycomore-0.6.3.tar.gz (562.1 kB view hashes)

Uploaded Source

Built Distributions

sycomore-0.6.3-cp37-cp37m-manylinux2010_x86_64.whl (484.7 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

sycomore-0.6.3-cp37-cp37m-macosx_10_12_x86_64.whl (815.8 kB view hashes)

Uploaded CPython 3.7m macOS 10.12+ x86-64

sycomore-0.6.3-cp36-cp36m-manylinux2010_x86_64.whl (484.5 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

sycomore-0.6.3-cp36-cp36m-macosx_10_12_x86_64.whl (815.7 kB view hashes)

Uploaded CPython 3.6m macOS 10.12+ x86-64

sycomore-0.6.3-cp35-cp35m-manylinux2010_x86_64.whl (484.6 kB view hashes)

Uploaded CPython 3.5m manylinux: glibc 2.12+ x86-64

sycomore-0.6.3-cp35-cp35m-macosx_10_12_x86_64.whl (815.7 kB view hashes)

Uploaded CPython 3.5m macOS 10.12+ x86-64

sycomore-0.6.3-cp34-cp34m-manylinux2010_x86_64.whl (484.7 kB view hashes)

Uploaded CPython 3.4m manylinux: glibc 2.12+ x86-64

sycomore-0.6.3-cp34-cp34m-macosx_10_12_x86_64.whl (815.6 kB view hashes)

Uploaded CPython 3.4m macOS 10.12+ x86-64

sycomore-0.6.3-cp27-cp27mu-manylinux2010_x86_64.whl (485.9 kB view hashes)

Uploaded CPython 2.7mu manylinux: glibc 2.12+ x86-64

sycomore-0.6.3-cp27-cp27m-manylinux2010_x86_64.whl (485.9 kB view hashes)

Uploaded CPython 2.7m manylinux: glibc 2.12+ x86-64

sycomore-0.6.3-cp27-cp27m-macosx_10_12_x86_64.whl (816.3 kB view hashes)

Uploaded CPython 2.7m macOS 10.12+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page