This package contains implementation of the simulation of MR images and MR diffusion signal attenuation. The basic pipeline is as follows:
This module contains functions for the computation of the ground truth fiber orientation distribution (FOD) from a collection of fibers.
Given a set of fibers, and a voxel size, compute the set of orientations on a subgrid with associated weights.
Parameters : | fibers : sequence, length (M, )
tangents : sequence, length (M, )
fiber_radii : array-like, shape (M, )
voxel_center : array-like shape (3, )
voxel_size : double
resolution : int
|
---|---|
Returns : | fod_samples : array-like, shape (P, 3)
fod_weights : array-like, shape (P, )
|
Computes fod from a discrete set of weighted samples, using kernel density estimation with a symmetric Von Mises-Fisher kernel.
Parameters : | fod_samples : array-like shape (P, 3)
fod_weights : array-like shape (P, )
dirs : array-like shape (M, 3)
kappa : double
sh : bool
order_sh : int
|
---|---|
Returns : | fod : array-like, shape (M, )
|
This module contains functions for MR image formation, such as random generation of T1/T2 relaxation time images, etc. In this regard, the mean and standard deviation of relaxation times of biological tissues, are taken from [R1].
[R1] | Wansapura, Janaka P., Scott K. Holland, R. Scott Dunn, and William S. Ball. “NMR relaxation times in the human brain at 3.0 tesla.” Journal of magnetic resonance imaging 9, no. 4 (1999): 531-538. |
Computes MR image, provided images of the WM, GM, CSF and background volume fractions.
Parameters : | wm_vf : array-like, shape (dim_x, dim_y, dim_z)
wm_t1 : array-like, shape (dim_x, dim_y, dim_z)
wm_t2 : array-like, shape (dim_x, dim_y, dim_z)
gm_vf : array-like, shape (dim_x, dim_y, dim_z)
gm_t1 : array-like, shape (dim_x, dim_y, dim_z)
gm_t2 : array-like, shape (dim_x, dim_y, dim_z)
csf_vf : array-like, shape (dim_x, dim_y, dim_z)
csf_t1 : array-like, shape (dim_x, dim_y, dim_z)
csf_t2 : array-like, shape (dim_x, dim_y, dim_z)
background_vf : array-like, shape (dim_x, dim_y, dim_z)
te : double
tr : double
|
---|---|
Returns : | image : array-like, shape (dim_x, dim_y, dim_z)
|
Return randomly generated images of t1 and t2 relaxation times, of desired shape, for the desired tissue type.
Parameters : | image_shape : tuple
tissue_type : ‘wm’, ‘gm’, ‘csf’
|
---|---|
Returns : | t1 : array-like, shape (dim_x, dim_y, dim_z)
t2 : array-like, shape (dim_x, dim_y, dim_z)
|
This module contains functions to compute partial volume effect, for fibers and other geometrical primitives.
Creates an affine matrix to compute real-world coordinates out of pixel coordinates. The convention is to return the coordinates of the center of the voxel.
Parameters : | voxel_size : double
image_size : double
|
---|---|
Returns : | affine : array-lie, shape (4, 4)
|
Computes the positions of voxel corners.
Parameters : | voxel_size : double
image_size : array-like (3,)
|
---|---|
Returns : | corner_positions : array-like, shape (dim_x+1, dim_y+1, dim_z+1, 3) |
Creates masks of the fibers. Voxels completely filled by the bundle are set to 2. Voxels which are intersected but not filled by the bundle are set to 1. Background is set to 0.
Parameters : | fibers : sequence, length (F, )
voxel_size : int
image_size : int
|
---|
Creates a mask of a list of spherical regions. Voxels completely filled by the region are set to 2. Voxels which are intersected by the region are set to 1. Background is set to 0.
Parameters : | centers : sequence of ndarray (3, )
radii : sequence
voxel_size : int
image_size : int
|
---|
Computes the volume fraction of background and of each tissue type, for a given resolution.
Parameters : | phantom_center : array-like, shape (3, ) phantom_radius : double gm_mask : array-like, shape (dim_x, dim_y, dim_z) fibers : sequence of phantomas.geometry.models.Fiber fiber_masks : array-like, shape (dim_x, dim_y, dim_z, nb_fibers) region_centers : sequence of array-like ragion_radii : sequence region_masks : array-like, shape (dim_x, dim_y, dim_z, nb_regions) voxel_size : double image_size : double |
---|---|
Returns : | background_volume_fraction : array-like, shape (dim_x, dim_y, dim_z) gm_volume_fraction : array-like, shape (dim_x, dim_y, dim_z) wm_volume_fraction : array-like, shape (dim_x, dim_y, dim_z) csf_volume_fraction : array-like, shape (dim_x, dim_y, dim_z) |
Given a set of fibers and a voxel, returns the volume fraction of each fiber, the volume fraction of free water and the volume fraction of gray matter. The voxel is subdivided into a grid.
Parameters : | fibers : a sequence of Fiber instances intersect_codes : a sequence of int (see Notes) voxel_center : ndarray, shape (3,) voxel_size : the voxel size in millimeter resolution : int
|
---|
Notes
intersect_codes[i] informs whether fiber i does not cross the voxel (0), simply intersects the voxel (1), or intersects the whole voxel (2).
Computes the volume fraction of a set of spherical regions.
Parameters : | centers : sequence of ndarray (3, ), centers of the spherical regions radii : sequence of radius of the spherical regions voxel_center : ndarray, shape (3,) voxel_size : the voxel size in millimeter resolution : int
|
---|
This module contains code to generate synthetic diffusion signal attenuation following several state-of-the-art model, including diffusion tensor [R2], stick model [R3], hindered diffusion in cylinder [R4], and mixture of the above. All the models described here have axial and antipodal symmetry, and we define an abstract class to serve as in interface.
[R2] | Peter J. Basser, James Mattiello, and Denis LeBihan. “MR diffusion tensor spectroscopy and imaging.” Biophysical journal 66, no. 1 (1994): 259-267 |
[R3] | T. E. J. Behrens, M. W. Woolrich, M. Jenkinson, H. Johansen-Berg, R. G. Nunes, S. Clare, P. M. Matthews, J. M. Brady, and S. M. Smith. “Characterization and propagation of uncertainty in diffusion-weighted MR Imaging.” Magnetic Resonance in Medicine 50, no. 5 (2003): 1077-1088. |
[R4] | Soderman, Olle, and Bengt Jonsson. “Restricted diffusion in cylindrical geometry.” Journal of Magnetic Resonance, Series A 117, no. 1 (1995): 94-97. |
This class is an abstract class which defines the interface for all the synthetic models in use in phantomas.
Methods
odf(thetas[, tau]) | Returns the ground truth ODF, when available. |
signal(qnorms, thetas[, tau]) | Returns the simulated signal attenuation. |
signal_convolution_sh(order, qnorm[, tau, ...]) | Returns the convolution operator in spherical harmonics basis, using |
Returns the ground truth ODF, when available.
Parameters : | thetas : array-like, shape (K, )
tau : double
|
---|
Returns the simulated signal attenuation. The angles thetas correspond to the angles between the sampling directions and the principal axis of the diffusion model. Must be implemented in subclasses.
Parameters : | qnorms : array-like shape (K, )
thetas : array-like, shape (K, )
tau : double
|
---|
Returns the convolution operator in spherical harmonics basis, using the Funk-Hecke theorem as described in [R5].
Parameters : | order : int
qnorm : double
tau : double
nb_samples : int
|
---|
References
[R5] | (1, 2) Descoteaux, Maxime. “High angular resolution diffusion MRI: from local estimation to segmentation and tractography.” PhD diss., Universite de Nice Sophia-Antipolis, France, 2010. |
Bases: phantomas.mr_simul.synthetic.AxiallySymmetricModel
This class models a Gaussian diffusion tensor wot axial symmetry. Typically, the eigenvalues of this tensors are .
Parameters : | lambda1 : double
lambda2 : double
|
---|
Methods
odf(thetas[, tau]) | Returns the ground truth ODF, when available. |
signal(qnorms, thetas[, tau]) | Returns the simulated signal attenuation, following the Stejskal |
signal_convolution_sh(order, qnorm[, tau, ...]) | Returns the convolution operator in spherical harmonics basis, using |
Returns the simulated signal attenuation, following the Stejskal and Tanner [1]_ equation. The angles thetas correspond to the angles between the sampling directions and the principal axis of the diffusion tensor.
Parameters : | qnorms : array-like shape (K, )
thetas : array-like, shape (K, )
tau : double
|
---|