Skip to main content

synthBOLD

Python License Test and formatting Docs codecov DOI

synth batch example

synthbold is a Python package for synthesizing BOLD fMRI data with controllable macrovascular contributions and corresponding ground-truth labels. The generated datasets can be used to develop, validate, and benchmark fMRI analysis methods without requiring labeled in vivo data.

In particular, it was developed to facilitate methods for identifying and mitigating macrovascular contributions in BOLD fMRI, by providing simulated data with known ground truth for evaluating such methods.

Each BOLD fMRI sample is built from a biophysical forward model of the BOLD signal: randomly placed vascular geometries (vessels and other perturbing structures) are assigned magnetic susceptibility values that generate a surrounding field perturbation (ΔBz), and the complex MRI signal is computed under the static dephasing regime [1], i.e., the intra-voxel signal decay caused by static, susceptibility-induced field inhomogeneities around vessels, following the classic vessel-based BOLD simulation framework of [2].

All generative parameters (vessel geometry, size, orientation, susceptibility, decay rates, echo time, magnetic field strength, etc.) are generated with weak priors and high variance sampling rather than tuned to match any specific real dataset. This domain-randomization strategy (cf. [3, 4]) aims to generate a much broader data distribution than any finite set of real fMRI data acquisitions could provide, so that models trained on synthetic data alone generalize to real fMRI data at test time.

Installation

synthbold can be installed from pypi via

pip install synthbold

Optionally, synthbold.splines exposes a thin wrapper for spline-based vessel generation that relies on synthspline. The dependency is not installed by default. If you need this feature, install it separately from GitHub:

pip install git+https://github.com/haenelt/synthspline.git@main

Usage

To generate a batch of synthetic BOLD data with macrovascular contributions, the synthbold command can be called from the command line as follows:

synthbold --output <output_dir> --n-sample <n_samples> --batch-size <batch_size> --config <config.yaml>

See synthbold --help for the full list of options.

Python API

synthbold can also be used as a library. SynthPipeline is the main entry point. Calling it returns a batch of synthetic BOLD data with macrovascular contributions: magnitude/phase images together with their ground-truth tissue and vessel maps.

from synthbold.config import Config
from synthbold.pipeline import SynthPipeline

config = Config()
pipeline = SynthPipeline(dirname="output", n_samples=100, config=config)
sample, _, params = pipeline(batch_size=4)

Examples

Example code can be found as Jupyter notebooks in the notebooks subfolder.

Contact

If you have questions, problems or suggestions regarding the synthbold package, please feel free to contact me.

References

  1. Yablonskiy, D. A., & Haacke, E. M. (1994). Theory of NMR signal behavior in magnetically inhomogeneous tissues: the static dephasing regime. Magnetic Resonance in Medicine, 32, 749–763.
  2. Boxerman, J. L., et al. (1995). MR contrast due to intravascular magnetic susceptibility perturbations. Magnetic Resonance in Medicine, 34, 555–566.
  3. Tobin, J., et al. (2017). Domain randomization for transferring deep neural networks from simulation to the real world. IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS).
  4. Billot, B., et al. (2023). SynthSeg: Segmentation of brain MRI scans of any contrast and resolution without retraining. Medical Image Analysis, 86, 102789.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

synthbold-1.0.0.tar.gz (318.2 kB view details)

Uploaded Source

Built Distribution

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

synthbold-1.0.0-py3-none-any.whl (84.0 kB view details)

Uploaded Python 3

File details

Details for the file synthbold-1.0.0.tar.gz.

File metadata

  • Download URL: synthbold-1.0.0.tar.gz
  • Upload date:
  • Size: 318.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.13

File hashes

Hashes for synthbold-1.0.0.tar.gz
Algorithm Hash digest
SHA256 41a1b7c8da18d9322ee194457cfbc429b818fd4561b15712700d5cc3741ea445
MD5 a1560b3bdaba963cd817ca25eeb48adb
BLAKE2b-256 1ae064b7ee79a7bc4081ba08295c709615f838504ff0776f4c353b1a44012740

See more details on using hashes here.

File details

Details for the file synthbold-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: synthbold-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 84.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.13

File hashes

Hashes for synthbold-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 426c65c68fb3b38bf4c7d4c62be9ae8f9f69305ce866bea4c90226f8d078e7b8
MD5 780ecbf21698838a21b30b5d84550760
BLAKE2b-256 1f2eb5c764813dfe4b9c9bf18aa21461c2b81b27841a0e1c9fd838cf6f796af3

See more details on using hashes here.

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