Skip to content

Grid and solid-harmonic basis ​

Grid belongs to HighOrderMRI itself. It stores the physical coordinates used by the encoding operators. Scanner geometry transforms are provided separately by MRIGeometry; do not assume that an encoding grid is already in the scanner's coordinate frame.

For a centred grid with metres as the length unit, a complete example is:

julia
using HighOrderMRI

grid = Grid(8, 8, 1, 1e-3, 1e-3, 5e-3)
basis = basisfunc_spha(grid.x, grid.y, grid.z, collect(1:9))
@assert size(basis) == (64, 9)
@assert all(basis[:, 1] .== 1)
metadata = SphericalHarmonics()
metadata.h4  # xy, with instantaneous field units T/m²

These polynomials are unnormalized real solid harmonics in Cartesian coordinates. basisfunc_spha supports 36 terms; the MRI constructors accept 9 or 16 coefficient rows. The display metadata cover the first 16. See the basis ordering, coordinate contract, and symbol definitions before supplying measured coefficients.

Grid API ​

Type ​

julia
Grid{T}

Physical Cartesian reconstruction grid with floating-point coordinates. Fields store the three axis sizes and spacings, flattened coordinate vectors, and matrixSize/resolution tuples. Use the dimension-and-spacing constructor for a centred grid. The keyword field constructor does not validate consistency between manually supplied coordinates and metadata.

Coordinates are in metres when used with phase coefficients in cycles/m^p. Low-rank NFFT execution requires the default centred Cartesian geometry on its active Fourier axes; changing x, y, or z alone does not change the NFFT plan. Explicit operators evaluate the supplied coordinates directly.

Source: src/Grid/Grid.jl

Centred grid ​

julia
Grid(nX::Int64,
    nY::Int64,
    nZ::Int64,
    Δx::T,
    Δy::T,
    Δz::T;
    exchange_xy::Bool = false,
    reverse_x::Bool = false,
    reverse_y::Bool = false,
    reverse_z::Bool = false) where T <: AbstractFloat

Create a centred Cartesian grid. All spacings must have the same floating-point precision T. Axis centres follow r[j] = (j - (N + 1)/2) * Δ; even sizes use half-voxel centres. The x index varies fastest in the flattened coordinate arrays.

exchange_xy swaps coordinate vectors; each reverse_* reverses that flattened coordinate vector. These switches do not permute image, mask, field-map or coil-map arrays and do not update grid dimensions/spacings. Supply all physical inputs in a consistent coordinate frame. For low-rank NFFT use the default untransformed active axes. Positive dimensions/spacings are caller requirements; the constructor does not enforce them.

Source: src/Grid/Grid.jl

Dictionary restoration ​

julia
Grid(d::AbstractDict;
    T::Type{<:AbstractFloat} = Float64)

Restore a grid from a dictionary using the fields written by struct_to_dict(grid): nX, nY, nZ, delta_x, delta_y, delta_z, x, y, and z. Scalars may also be one-element arrays. Coordinates and spacings are converted to the requested floating-point type T; size and resolution tuples are reconstructed from those scalar fields.

The dictionary must contain consistent full-length coordinate vectors. This constructor does not validate a schema version or the Cartesian NFFT geometry.

Source: src/Grid/Grid.jl

Basis evaluation API ​

Several terms ​

julia
basisfunc_spha(x::AbstractVector{T},
    y::AbstractVector{T},
    z::AbstractVector{T},
    terms::AbstractVector{Int}) where T <: AbstractFloat

Evaluate unnormalized real solid-harmonic polynomials at matching floating-point coordinate vectors. terms uses one-based indices 1:36 (orders zero through five); columns follow the requested order. Return a (length(x), length(terms)) matrix of element type T. A CuArray input x selects CUDA allocation; all coordinate arrays must be on a compatible device/backend.

Coordinates are physical lengths, so a polynomial of order p has units m^p when coordinates are in metres. These are Cartesian solid harmonics without angular or unit-sphere normalization. MRI encoding constructors currently use only the first 9 or 16 terms. See SphericalHarmonics for metadata through order three.

julia
x = [1.0, 2.0, 3.0]
y = [4.0, 5.0, 6.0]
z = [7.0, 8.0, 9.0]
basis = basisfunc_spha(x, y, z, [1, 2, 3, 4])

Source: src/SphericalHarmonics/basisfunction.jl

One term ​

julia
basisfunc_spha(x::AbstractVector{T},
    y::AbstractVector{T},
    z::AbstractVector{T},
    term::Int64) where T <: AbstractFloat

Evaluate one solid-harmonic term and return a vector with the same element type as the coordinate inputs. term uses the same one-based 1:36 ordering as the matrix overload. Terms 2, 3 and 4 return the input x, y and z vectors themselves, so those results alias their respective inputs.

Source: src/SphericalHarmonics/basisfunction.jl

Metadata API ​

julia
SphericalHarmonics()

Return metadata for the 16 unnormalized real solid-harmonic basis functions used by HighOrderMRI, including their names, instantaneous field units, time-integrated coefficient units, expressions, and plotting colours.

The numerical encoding basis is evaluated by basisfunc_spha.

Source: src/SphericalHarmonics/SphericalHarmonics.jl

Display arrays ​

spha_basis, spha_basis_latex, and spha_color are exported, mutable arrays of 16 polynomial labels, LaTeX labels and colour strings. Their ordering matches SphericalHarmonics(). They are display metadata, not numerical configuration; changing them does not change encoding or add supported terms.

HighOrderMRI.jl documentation · v0.1.1 · code 5d6ac72 · docs 5d6ac72