/ concept-collection / mri-scanner
Sign in
concept-collection / mri-scanner
mri-scanner / src / phantom / phantomTypes.ts
46 lines · 1.4 KBCodeBlameHistory
5f2d2b3mri-scanner: in-browser Bloch simulation of pulseq sequencesJeremy Magland 1// A digital phantom: a cloud of spins, each with a position (metres) and
2// tissue properties. Matches the fields of a KomaMRI `.phantom` file
3// (see ../KomaMRI.jl Phantom.jl): position group x/y/z, contrast group
4// rho/T1/T2/T2s/dw.
6export interface Phantom {
7 name: string
8 /** Number of spins */
9 ns: number
10 /** Spin x position, metres */
11 x: Float32Array
12 /** Spin y position, metres */
13 y: Float32Array
14 /** Spin z position, metres */
15 z: Float32Array
16 /** Proton density (equilibrium magnetisation), arbitrary units */
17 rho: Float32Array
18 /** Longitudinal relaxation time, seconds */
19 t1: Float32Array
20 /** Transverse relaxation time, seconds */
21 t2: Float32Array
22 /** T2* relaxation time, seconds */
23 t2s: Float32Array
24 /** Off-resonance, rad/s */
25 dw: Float32Array
28/** Axis-aligned bounding box of a phantom's spins, metres. */
29export interface PhantomExtent {
30 min: [number, number, number]
31 max: [number, number, number]
34export function phantomExtent(p: Phantom): PhantomExtent {
35 const min: [number, number, number] = [Infinity, Infinity, Infinity]
36 const max: [number, number, number] = [-Infinity, -Infinity, -Infinity]
37 const axes = [p.x, p.y, p.z]
38 for (let a = 0; a < 3; a++) {
39 const arr = axes[a]
40 for (let i = 0; i < arr.length; i++) {
41 if (arr[i] < min[a]) min[a] = arr[i]
42 if (arr[i] > max[a]) max[a] = arr[i]
43 }
44 }
45 return { min, max }
moveopenescclose