Skip to content

Testing utilities

unimri.testing provides synthetic data with known ground truth and a brute-force reference transform. Nothing here is for production reconstruction.

Build one valid :class:MRIData for pattern with known ground truth.

A synthetic dataset and everything needed to score a reconstruction of it.

Sample image at k-space locations coords (shape (ndim, ...)).

Returns an array with the shape of coords[0].

Density-compensated adjoint: k-space samples -> image on grid shape.

Analytic phantoms with known ground truth.

Used to build synthetic datasets whose exact image is known, so a reconstruction's error can be measured rather than eyeballed.

ellipsoid_phantom(shape)

A simple 3-D phantom: a few nested/offset ellipsoids. Shape (nz, ny, nx).

shepp_logan(shape)

A 2-D Shepp-Logan phantom, values in roughly [0, 1], shape (ny, nx).

Analytic k-space trajectory generators for synthetic datasets.

All generators return coords in :class:~unimri.data.TrajectoryUnits.NORMALIZED units (one unit = one sample of the encoded matrix, Nyquist window [-N/2, N/2)) and, where a closed form exists, an analytic density compensation function.

Axis convention: coords row d corresponds to image axis d (NumPy order) -- (ky, kx) for a 2-D image (ny, nx), (kz, ky, kx) for a 3-D image (nz, ny, nx). See docs/data-model.md.

cartesian(matrix, n_dims=2)

A fully-sampled Cartesian grid expressed as a trajectory (for testing NUFFT==FFT).

radial_2d(matrix, n_spokes, *, golden_angle=True)

2-D radial spokes. Returns (coords (2, n_spokes, matrix), dcf (n_spokes, matrix)).

radial_3d(matrix, n_spokes, readout=None)

3-D center-out projections on a spiral-phyllotaxis sphere distribution.

Returns (coords (3, n_spokes, readout), dcf (n_spokes, readout)).

stack_of_stars(matrix, n_spokes, n_partitions)

Radial in-plane, Cartesian along z.

Returns (coords (3, n_spokes*n_partitions, matrix), dcf (n_spokes*n_partitions, matrix)).