Skip to main content

A python tool to perform Bloch-McConnell (BMC) simulations.

Project description

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.

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

bmctool-1.0.3.tar.gz (47.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bmctool-1.0.3-py3-none-any.whl (34.9 kB view details)

Uploaded Python 3

File details

Details for the file bmctool-1.0.3.tar.gz.

File metadata

  • Download URL: bmctool-1.0.3.tar.gz
  • Upload date:
  • Size: 47.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bmctool-1.0.3.tar.gz
Algorithm Hash digest
SHA256 0809f4d265d740ccf7302ad021a9f79b0406c25dd68ec08b20c9c3cd508d854e
MD5 0f790214a6c9f2f9f5958677aad233d7
BLAKE2b-256 523805e4f6ab5d413b9ed35d07e3bc15285b003ecbadfd58b38486fbfd7858ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for bmctool-1.0.3.tar.gz:

Publisher: publish-to-pypi.yml on schuenke/BMCTool

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bmctool-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: bmctool-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 34.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bmctool-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 358c4795fd89145a9568d8519038ab5be705c692758bc62ade0c36bfd29d7f13
MD5 3a49a4240f8439e4b164a7a57d25f8b1
BLAKE2b-256 b20ceb22afdb7b069912e9a5bbbe079f01071e6f1039ba70352035d9d8ed3b57

See more details on using hashes here.

Provenance

The following attestation bundles were made for bmctool-1.0.3-py3-none-any.whl:

Publisher: publish-to-pypi.yml on schuenke/BMCTool

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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