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 combining radiofrequency (RF) coil spatial information with frequency sampling information.

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

Installation

Package biasgen can be installed using pip:

pip install biasgen

A CUDA accelerated version of biasgen is also available:

pip install biasgen[gpu]

Usage

To start biasgen requires the user to define a set of coil positions and sampling frequencies. Coil positioning can be initialized through a sequence of CoilSegment objects or by using the predefined coil constructor routine cage_constructor. An example of how to use cage_constructor is provided below:

import biasgen

# Shepp-Logan phantom example
ph = biasgen.phantom3d(n=128)

# returns a sequence of CoilSegment objects
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)

Function view_coil_positioning provides a top-down view of CoilSegment sequences which can be useful when arranging coil cages. Next step 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))

Inputting the sampling information and coil sequence into compute_sensitivity will return the sensitivity maps of each coils:

# biasgen.use_gpu(True) # Uncomment if GPU is available

# first axis will index each coil contribution 
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 for computation. The simulated sensitivity maps can be viewed using the function view_center_axes:

# mask for view_center_axes
ph_mask = ph > 0

# visualization requires that a mask is provided
biasgen.view_center_axes(abs(sens), ph_mask, ['Z-slice','Y-slice','X-slice'])

Finally we construct the measured bias field through a sum-of-squares procedure:

bias = biasgen.bias_sum_of_squares(sens)

# scalar product application of bias to Shepp-Logan phantom
biasgen.view_center_axes(bias*ph, ph_mask, ['Z-slice','Y-slice','X-slice'])

More detailed examples of sensitivity simualtions and visualizaitons 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. Vinas L and Sudhyadhom A. Sinusoidal Sensitivity Calculation for Line Segment Geometries. arXiv.org:2208.03059 [physics.med-ph], Aug. 2022.

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.2.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

biasgen-0.1.2-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: biasgen-0.1.2.tar.gz
  • Upload date:
  • Size: 18.6 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.2.tar.gz
Algorithm Hash digest
SHA256 562e3ceac4010a12a52f5eee30cd8b2d02799e4799b702214f6f1db9ce066584
MD5 dc9fef36375a32b72d63146f5a88b5a5
BLAKE2b-256 060304e291c9e1bc6cbcb6001a645c5247c0d775b2779d9a21d3afd2de23caf9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: biasgen-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 19.5 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 775b75b857ec9b1a05455d60d7f8a727f51127749eb2fdc6cd0aed0ed6c7fe54
MD5 d01ec676b39d8442cdc4647b9a646896
BLAKE2b-256 3579db9094f1407b4fd931517f797613f3c4270a4482aba6785b5b46f955d72a

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