// A digital phantom: a cloud of spins, each with a position (metres) and // tissue properties. Matches the fields of a KomaMRI `.phantom` file // (see ../KomaMRI.jl Phantom.jl): position group x/y/z, contrast group // rho/T1/T2/T2s/dw. export interface Phantom { name: string /** Number of spins */ ns: number /** Spin x position, metres */ x: Float32Array /** Spin y position, metres */ y: Float32Array /** Spin z position, metres */ z: Float32Array /** Proton density (equilibrium magnetisation), arbitrary units */ rho: Float32Array /** Longitudinal relaxation time, seconds */ t1: Float32Array /** Transverse relaxation time, seconds */ t2: Float32Array /** T2* relaxation time, seconds */ t2s: Float32Array /** Off-resonance, rad/s */ dw: Float32Array } /** Axis-aligned bounding box of a phantom's spins, metres. */ export interface PhantomExtent { min: [number, number, number] max: [number, number, number] } export function phantomExtent(p: Phantom): PhantomExtent { const min: [number, number, number] = [Infinity, Infinity, Infinity] const max: [number, number, number] = [-Infinity, -Infinity, -Infinity] const axes = [p.x, p.y, p.z] for (let a = 0; a < 3; a++) { const arr = axes[a] for (let i = 0; i < arr.length; i++) { if (arr[i] < min[a]) min[a] = arr[i] if (arr[i] > max[a]) max[a] = arr[i] } } return { min, max } }