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
-
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.
-
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
Built Distribution
File details
Details for the file biasgen-0.1.3.tar.gz
.
File metadata
- Download URL: biasgen-0.1.3.tar.gz
- Upload date:
- Size: 17.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca33fb65dd41468e7dee8972e1e2878fa52c9a8b1ef1d0784ccdde3dfce5f778 |
|
MD5 | 79132f873b14fa378d32b72260d061ca |
|
BLAKE2b-256 | 76ee895bc68775fdf81d5c50b81ab40667484964615916b158967010b9d9cb3e |
File details
Details for the file biasgen-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: biasgen-0.1.3-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f151578994853973fa1a3f0e57feae1e6a56f78760aa4799a2687ec7dc95d78 |
|
MD5 | 0f4bc76e0ba537e88084587044495e4e |
|
BLAKE2b-256 | b5763aac78efde9841d8fdd7ef057d2edc3a2c4c5bb6cb22202a058ce7f3104d |