Skip to main content

MRI simulation toolkit

Project description

Sycomore — an MRI simulation toolkit

PyPI - Wheel Conda Version

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

Sycomore is free software, released under the MIT license, and its source code is available on GitHub.

A sample web application, using Sycomore paired with Bokeh is available on Heroku: it presents classical MRI experiments (RARE, RF-spoiling, slice profile with a selective sinc pulse), using the different simulation models of Sycomore.

Installation

Packaged versions of Sycomore are available on pypi and Anaconda for Linux, macOS and Windows.

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, xsimd 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 using regular EPG 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-1.3.2.tar.gz (605.6 kB view hashes)

Uploaded Source

Built Distributions

sycomore-1.3.2-cp310-cp310-win_amd64.whl (956.1 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

sycomore-1.3.2-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (353.8 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.12+ x86-64

sycomore-1.3.2-cp310-cp310-macosx_10_9_universal2.whl (369.5 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64)

sycomore-1.3.2-cp39-cp39-win_amd64.whl (956.3 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

sycomore-1.3.2-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (354.0 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

sycomore-1.3.2-cp39-cp39-macosx_10_9_universal2.whl (369.6 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)

sycomore-1.3.2-cp38-cp38-win_amd64.whl (953.8 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

sycomore-1.3.2-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (353.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

sycomore-1.3.2-cp38-cp38-macosx_10_9_x86_64.whl (369.5 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

sycomore-1.3.2-cp37-cp37m-win_amd64.whl (949.1 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

sycomore-1.3.2-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (368.6 kB view hashes)

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

sycomore-1.3.2-cp37-cp37m-macosx_10_9_x86_64.whl (358.4 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

sycomore-1.3.2-cp36-cp36m-win_amd64.whl (949.4 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

sycomore-1.3.2-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (369.1 kB view hashes)

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

sycomore-1.3.2-cp36-cp36m-macosx_10_9_x86_64.whl (358.3 kB view hashes)

Uploaded CPython 3.6m 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