snake.core.phantom.shepp_logan#

Shepp-Logan phantom generation.

Module Contents#

Functions#

mr_shepp_logan

Generate a Shepp-Logan phantom with MR tissue parameters.

mr_ellipsoid_parameters

Return parameters of ellipsoids.

_mr_relaxation_parameters

Return MR relaxation parameters for certain tissues.

idx_in_ellipse

Return array of index who fit in the ellipsoid.

API#

snake.core.phantom.shepp_logan.mr_shepp_logan(N: int | tuple[int, int, int], E: numpy.ndarray | None = None, B0: float = 3, zlims: tuple[float, float] = (-1, 1)) tuple[numpy.typing.NDArray, ...][source]#

Generate a Shepp-Logan phantom with MR tissue parameters.

Parameters:
  • N (int or array_like) – Matrix size, (N, N, N), or (L, M, N).

  • E (array_like, optional) –

    ex13 numeric matrix defining e ellipses. The columns of E are:

    • x-coordinate of the center of the ellipsoid (in [-1, 1])

    • y-coordinate of the center of the ellipsoid (in [-1, 1])

    • z-coordinate of the center of the ellipsoid (in [-1, 1])

    • x principal axis of the ellipsoid

    • y principal axis of the ellipsoid

    • z principal axis of the ellipsoid

    • Angle of the ellipsoid (in rad)

    • spin density, M0

    • Parameter A for T1 determination

    • Parameter C for T1 determination

    • Explicit T1 value (in sec, or np.nan if model is used)

    • T2 value (in sec)

    • chi (change in magnetic susceptibility)

    If spin density is negative, M0, T1, and T2 will be subtracted instead of cummulatively added.

  • B0 (float, optimal) – Field strength (in Tesla).

  • zlims (tuple, optional) – Only for 3D. Specify bounds along z. Often we only want the middle portion of a 3D phantom, e.g., zlim=(-.5, .5).

Returns:

  • M0 (array_like) – The proton density.

  • T1 (array_like) – The T1 values.

  • T2 (array_like) – The T2 values.

  • T2star (array_like) – The T2 star values. The T2star values are calculated using magnetic susceptibility and T2.

  • labels (array_like) – An integer-labelled partition of the phantom.

Notes

Implements the phantoms described in [1]_.

If parameters A, C are given and T1 is None, T1 is determined according to the equation:

T1 = A*B0^C

The original source code [2]_

References

snake.core.phantom.shepp_logan.mr_ellipsoid_parameters() numpy.ndarray[source]#

Return parameters of ellipsoids.

Returns:

E – Parameters for the ellipsoids used to construct the phantom.

Return type:

array_like

snake.core.phantom.shepp_logan._mr_relaxation_parameters() dict[source]#

Return MR relaxation parameters for certain tissues.

Returns:

params – Gives entries as [A, C, (t1), t2, chi]

Return type:

dict

Notes

If t1 is None, the model T1 = A*B0^C will be used. If t1 is not np.nan, then specified t1 will be used.

snake.core.phantom.shepp_logan.idx_in_ellipse(E: numpy.ndarray, shape: tuple[int, int, int]) numpy.ndarray[source]#

Return array of index who fit in the ellipsoid.

Parameters:
  • E (np.array) – 1d array defining the coordinate and size of the ellipsoid.

  • shape (tuple) – shape of the complete volume.

Returns:

A boolean mask of index which are in the ellipse.

Return type:

np.ndarray