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.

Release files for synthbold 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for synthbold 1.0.0
File Size Uploaded
synthbold-1.0.0.tar.gz 318.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for synthbold 1.0.0
File Interpreter ABI Platform
synthbold-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 402.2 kB

Release files / synthbold-1.0.0.tar.gz

Download URL synthbold-1.0.0.tar.gz
Size 318.2 kB
Tags Source
SHA-256 checksum
How to use checksums
41a1b7c8da18d9322ee194457cfbc429b818fd4561b15712700d5cc3741ea445
BLAKE2b-256 checksum
How to use checksums
1ae064b7ee79a7bc4081ba08295c709615f838504ff0776f4c353b1a44012740
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release files / synthbold-1.0.0-py3-none-any.whl

Download URL synthbold-1.0.0-py3-none-any.whl
Size 84.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
426c65c68fb3b38bf4c7d4c62be9ae8f9f69305ce866bea4c90226f8d078e7b8
BLAKE2b-256 checksum
How to use checksums
1f2eb5c764813dfe4b9c9bf18aa21461c2b81b27841a0e1c9fd838cf6f796af3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page