Skip to content

schuenke/BMCTool

Repository files navigation

Bloch-McConnell (BMC) Simulation Tool

Python License Coverage Badge

This repository contains a purely Python-based Bloch-McConnell (BMC) simulation tool that can be used to simulate the evolution of magnetization in various (exchanging) magnetic environments ('pools') with arbitrary radio-frequency (RF) irradiation schemes. The tool was developed to simulate Chemical Exchange Saturation Transfer (CEST) or related spectra but can be used for many other MR simulations as well.

The BMCTool utilizes the pulseq open file format to define and store all events (RF pulses, gradients, delays, ADCs) to be simulated. The scanner settings (e.g., field strength, B0 inhomogeneity) and characteristic properties of the magnetic environments (e.g., relaxation times, pool size fractions, exchange rates) are defined and stored in configuration files in the YAML file format.

Every simulation requires exactly one Pulseq sequence file (containing all events) and at least one configuration file.

Installation

The BMCTool is available on PyPi and can be installed using pip install bmctool.

Alternatively, if Git is available on your system, you can directly install BMCTool from GitHub using pip install git+https://github.com/schuenke/bmctool@main. You can change the @main to any desired branch.

Initial Test

To make sure that the installation was successful, you can run an example simulation that is provided with both the pip and GitHub installations. To run an example simulation, simply execute the following code:

from bmctool.simulation import sim_example

sim_example()

The sim_example function uses the WASABI.seq and config_1pool.yaml example files.

Running a Simulation

All simulations using the BMCTool require at least one config file (in the YAML format) that includes all simulation settings and exactly one Pulseq sequence file (in the seq format), which defines the events to be simulated. An example seq-file and an example yaml file can be found in the library subfolder. For more information about configuration files and sequence files as well as about the Pulseq-CEST library, where both types of files can be shared, please read the Pulseq-CEST Library section below.

If you created your own files or downloaded them from the Pulseq-CEST library, you can start the simulation by running the following code:

from bmctool.simulate import simulate

config_path = '<path_to_your_config>'  # can be a str or a Path
seq_path = '<path_to_your_sequence>'  # can be a str or a Path
sim = simulate(config_file=config_path, seq_file=seq_path, show_plot=True)

The simulate function accepts several additional keyword arguments (**kwargs) that allow adjusting the plot. These include normalize (bool: toggle normalization), norm_threshold (value/list/array: threshold for normalization offsets), offsets (list/array: manually defined x-values), invert_ax (bool: toggle invert axis), plot_mtr_asym (bool: toggle plot MTR_asym), and title, x_label, y_label to control the labels.

Pulseq-CEST Project

The BMCTool was developed in parallel to the Pulseq-CEST project, which aims to provide published and approved CEST saturation blocks in the Pulseq open file format to enable an exact comparison of CEST saturation blocks with newly developed or adapted saturation blocks for reproducible research. The Pulseq-CEST project also provides a MATLAB implementation.

Pulseq-CEST Library

You will find several pre-defined and approved CEST pre-saturation schemes and simulation configs in the Pulseq-CEST library on GitHub. You can clone the library using git clone https://github.com/kherz/pulseq-cest-library.git or download the latest version as a ZIP file.

About

Python Bloch-McConnell (BMC) simulation tool

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages