Skip to main content

MRI simulation toolkit

Project description

Sycomore — an MRI simulation toolkit

Travis Build Status Appveyor Build status PyPI - Wheel Conda Version

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

Packaged versions of Sycomore are available on pypi and Anaconda for Linux, macOS and Windows. The following table summarizes the availability of packages according to the version of the Python interpreter.

Operating system conda-forge PyPI
Linux 3.6, 3.7 3.5, 3.6, 3.7
macOS (≥ 9) 3.6, 3.7 3.6, 3.7
Windows not available 3.5, 3.6, 3.7

To install from Anaconda, type conda install -c conda-forge sycomore. To install from pypi, type pip3 install sycomore (or pip install sycomore). If you are installing from pypi and no pre-compiled version is available for your platform, pip will try to install from the source archive.

If you need to install Sycomore from source, you will need a C++11 compiler, CMake_ and pybind11_ to successfully build Sycomore. If you want to validate your build of Sycomore, you should run the unit tests, which require Boost.Test.

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.8.tar.gz (581.1 kB view hashes)

Uploaded Source

Built Distributions

sycomore-0.6.8-cp37-cp37m-win_amd64.whl (887.4 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

sycomore-0.6.8-cp37-cp37m-manylinux1_x86_64.whl (313.8 kB view hashes)

Uploaded CPython 3.7m

sycomore-0.6.8-cp37-cp37m-macosx_10_9_x86_64.whl (300.9 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

sycomore-0.6.8-cp36-cp36m-win_amd64.whl (887.1 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

sycomore-0.6.8-cp36-cp36m-manylinux1_x86_64.whl (314.7 kB view hashes)

Uploaded CPython 3.6m

sycomore-0.6.8-cp36-cp36m-macosx_10_9_x86_64.whl (300.9 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

sycomore-0.6.8-cp35-cp35m-win_amd64.whl (887.0 kB view hashes)

Uploaded CPython 3.5m Windows x86-64

sycomore-0.6.8-cp35-cp35m-manylinux1_x86_64.whl (314.7 kB view hashes)

Uploaded CPython 3.5m

sycomore-0.6.8-cp27-cp27mu-manylinux1_x86_64.whl (314.1 kB view hashes)

Uploaded CPython 2.7mu

sycomore-0.6.8-cp27-cp27m-macosx_10_9_x86_64.whl (301.5 kB view hashes)

Uploaded CPython 2.7m macOS 10.9+ 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