KomaMRI.jl icon indicating copy to clipboard operation
KomaMRI.jl copied to clipboard

Use the same functions to sample RFs in the simulation than for plotting sequence

Open cncastillo opened this issue 1 year ago • 0 comments

We are currently using a different function to sample the RFs. In Sequence.jl:

get_rfs(seq::Sequence, t) = begin
	#Amplitude
	A  = seq.RF.A
	Δf = seq.RF.Δf
	#Timings
	T = seq.RF.T
	delay = seq.RF.delay
	T0 = cumsum([0; durs(seq)], dims=1)
	(sum([⏢(A[1,i], t.-T0[i],sum(T[i]).-2EPS,EPS,EPS,delay[i]) for i=1:length(seq)]),
	 sum([⏢(Δf[1,i],t.-T0[i],sum(T[i]).-2EPS,EPS,EPS,delay[i]) for i=1:length(seq)])
	)
end

while the gradients use

function get_grads(seq, t::Vector)
    gx = get_theo_Gi(seq, 1)
    gy = get_theo_Gi(seq, 2)
    gz = get_theo_Gi(seq, 3)
    Gx = linear_interpolation(gx..., extrapolation_bc=0)(t)
    Gy = linear_interpolation(gy..., extrapolation_bc=0)(t)
    Gz = linear_interpolation(gz..., extrapolation_bc=0)(t)
    (Gx, Gy, Gz)
end

and the get_theo_Gi are the same functions used in plot_seq, besides the interpolation (that it would be nice to remove as well :smile:).

This does not generate any simulation inaccuracies (that we know of), but it would be nice to be sure that what we see in plot_seq is the same as the simulated sequence.

cncastillo avatar May 13 '23 17:05 cncastillo