Skip to main content

Utility functions to produce and visualize simulated bias fields generated according to Kern et. al's sinusoidal sensitivity model.

Project description

biasgen

biasgen is a Python package which simulates magnetic resonance (MR) non-uniformities. This package allows users to generate custom bias fields by providing radiofrequency (RF) coil spatial information as well as frequency sampling information.

Bias fields are constructed from a sum-of-squares approach using sensitivity maps which follow the sinusoidal model of Kern et. al. Direct computation of sinusoidal sensitivities are done using the closed form solution of segment sources derived by Vinas and Sudhyadhom.

Installation

Package biasgen can be installed using pip:

pip install biasgen

A CUDA accelerated version of biasgen is also provided and can be installed with:

pip install biasgen[gpu]

Usage

biasgen requires a set of coil positions and sampling frequencies in order to work. Coil positioning can be initialized using several CoilSegment objects or through the predefined constructor routine cage_constructor. An example using cage_constructor is provided below:

import biasgen

ph = biasgen.phantom3d(n=128)
coils = biasgen.cage_constructor(n_coils=2, center=(64,64,64), coil_height=128,
                                 length_to_space_ratio=0.35, ellip_axes=(90,65))
biasgen.view_coil_positioning(ph, coils)

Here function view_coil_positioning provides a top-down view of the coils defined by our cage constructor. Next is to define a sampling grid for the sinusoidal sensitivity model:

sens_settings = biasgen.SensitivitySettings(grid_lengths=(5,5,5), grid_spacings=(1,1,1))

These sampling settings can be used in conjunction to the coils to produce a set of sensitivity maps:

# biasgen.use_gpu(True) # Uncomment if GPU is available
sens = biasgen.compute_sensitivity(coils, sens_settings, ph.shape, batch_sz=1, scale_fctr=0.5)

Arguments "batch_sz" and "scale_fctr" can be helpful for memory-limited devices. "batch_sz" determines how many segments are loaded into memory while "scale_fctr" provides a temporary spatial downsampling during computation. The sensitivity maps can be viewed using function view_center_axes and a boolean mask:

ph_mask = ph > 0
biasgen.view_center_axes(abs(sens), ph_mask, ['Z-slice','Y-slice','X-slice'])

Finally the bias field is constructed through a sum-of-squares procedure:

bias = biasgen.bias_sum_of_squares(sens)
biasgen.view_center_axes(bias*ph, ph_mask, ['Z-slice','Y-slice','X-slice'])

More detailed examples can be found in the examples/bias.ipynb notebook.

References

  1. Guerquin-Kern M, Lejeune L, Pruessmann KP, Unser M. Realistic Analytical Phantoms for Parallel Magnetic Resonance Imaging. IEEE Transactions on Medical Imaging. 2012;31(3):626-636.
  2. TBD

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

biasgen-0.1.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

biasgen-0.1.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file biasgen-0.1.0.tar.gz.

File metadata

  • Download URL: biasgen-0.1.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for biasgen-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fb909e5e3320df4f0161a1af1ca87a9e594ba54d9e7bafbde4f86148fd280da7
MD5 20090595168fdbc4adda89f825da5602
BLAKE2b-256 5f49517f2ec821d75d26b503fc3c9e2fcd04cc2b43f3c83f462a719965627cf1

See more details on using hashes here.

File details

Details for the file biasgen-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: biasgen-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for biasgen-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ece887558c39cda9f326ad562c8550a03f4d92bc1a6de65ddc8c85c08bf4b6a3
MD5 1ed3600c51c1ce73c00bec577e6d7bc7
BLAKE2b-256 d684288ae116d77943e903664fb3e62f34c894fb91883b3941b77ded33543bb4

See more details on using hashes here.

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