@@ -66,8 +66,8 @@ function run_spin_precession!(
6666 Mxy = prealloc. M. xy
6767 ΔBz = prealloc. ΔBz
6868 fill! (ϕ, zero (T))
69- @. Bz_old = x[:, 1 ] * seq . Gx[ 1 ] + y[:, 1 ] * seq . Gy[ 1 ] + z[:, 1 ] * seq . Gz[ 1 ] + ΔBz
70-
69+ Bz_old = get_Bz (seq, x, y, z, 1 ) + ΔBz
70+
7171 # Fill sig[1] if needed
7272 ADC_idx = 1
7373 if (seq. ADC[1 ])
@@ -81,7 +81,7 @@ function run_spin_precession!(
8181 t_seq += seq. Δt[seq_idx- 1 ]
8282
8383 # Effective Field
84- @. Bz_new = x * seq. Gx[seq_idx] + y * seq . Gy[seq_idx] + z * seq . Gz[ seq_idx] + ΔBz
84+ Bz_new = get_Bz ( seq, x, y, z, seq_idx) + ΔBz
8585
8686 # Rotation
8787 @. ϕ += (Bz_old + Bz_new) * T (- π * γ) * seq. Δt[seq_idx- 1 ]
@@ -136,24 +136,24 @@ function run_spin_excitation!(
136136 Maux_z = prealloc. M. z
137137
138138 # Simulation
139- for s in seq # This iterates over seq, "s = seq[i,:]"
139+ for i in eachindex ( seq. Δt)
140140 # Motion
141- x, y, z = get_spin_coords (p. motion, p. x, p. y, p. z, s . t )
141+ x, y, z = get_spin_coords (p. motion, p. x, p. y, p. z, seq . t[i] )
142142 # Effective field
143- @. Bz = (s . Gx * x + s . Gy * y + s . Gz * z) + ΔBz - s . Δf / T (γ) # ΔB_0 = (B_0 - ω_rf/γ), Need to add a component here to model scanner's dB0(x,y,z)
144- @. B = sqrt (abs (s . B1)^ 2 + abs (Bz)^ 2 )
143+ Bz . = get_Bz (seq, x, y, z, i) . + ΔBz .- seq . Δf[i] / T (γ) # ΔB_0 = (B_0 - ω_rf/γ), Need to add a component here to model scanner's dB0(x,y,z)
144+ @. B = sqrt (abs (seq . B1[i] )^ 2 + abs (Bz)^ 2 )
145145 @. B[B == 0 ] = eps (T)
146146 # Spinor Rotation
147- @. φ = T (- π * γ) * (B * s . Δt) # TODO : Use trapezoidal integration here (?), this is just Forward Euler
147+ @. φ = T (- π * γ) * (B * seq . Δt[i] ) # TODO : Use trapezoidal integration here (?), this is just Forward Euler
148148 @. α = cos (φ) - Complex {T} (im) * (Bz / B) * sin (φ)
149- @. β = - Complex {T} (im) * (s . B1 / B) * sin (φ)
149+ @. β = - Complex {T} (im) * (seq . B1[i] / B) * sin (φ)
150150 mul! (Spinor (α, β), M, Maux_xy, Maux_z)
151151 # Relaxation
152- @. M. xy = M. xy * exp (- s . Δt / p. T2)
153- @. M. z = M. z * exp (- s . Δt / p. T1) + p. ρ * (T (1 ) - exp (- s . Δt / p. T1))
152+ @. M. xy = M. xy * exp (- seq . Δt[i] / p. T2)
153+ @. M. z = M. z * exp (- seq . Δt[i] / p. T1) + p. ρ * (T (1 ) - exp (- seq . Δt[i] / p. T1))
154154
155155 # Reset Spin-State (Magnetization). Only for FlowPath
156- outflow_spin_reset! (M, s . t , p. motion; replace_by= p. ρ)
156+ outflow_spin_reset! (M, seq . t[i + 1 , :] , p. motion; replace_by= p. ρ)
157157 end
158158 # Acquired signal
159159 # sig .= -1.4im #<-- This was to test if an ADC point was inside an RF block
0 commit comments