From 83da9a5ddaff9830abc2e62623012be9835c7ec1 Mon Sep 17 00:00:00 2001 From: beorostica-asusFX505GT-win Date: Wed, 27 Mar 2024 11:24:38 -0300 Subject: [PATCH] Add temporal time_shape_id property to Grad struct for debuging --- KomaMRIBase/src/datatypes/sequence/Grad.jl | 1 + KomaMRIFiles/src/Sequence/Pulseq.jl | 9 ++++++++- KomaMRIFiles/test/runtests.jl | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/KomaMRIBase/src/datatypes/sequence/Grad.jl b/KomaMRIBase/src/datatypes/sequence/Grad.jl index 0bf6554ce..f4f22f13e 100644 --- a/KomaMRIBase/src/datatypes/sequence/Grad.jl +++ b/KomaMRIBase/src/datatypes/sequence/Grad.jl @@ -76,6 +76,7 @@ mutable struct Grad delay::Real first last + time_shape_id function Grad(A, T, rise, fall, delay) all(T .< 0) || rise < 0 || fall < 0 || delay < 0 ? error("Gradient timings must be positive.") : new(A, T, rise, fall, delay) end diff --git a/KomaMRIFiles/src/Sequence/Pulseq.jl b/KomaMRIFiles/src/Sequence/Pulseq.jl index f4417004d..cbec969b7 100644 --- a/KomaMRIFiles/src/Sequence/Pulseq.jl +++ b/KomaMRIFiles/src/Sequence/Pulseq.jl @@ -450,7 +450,7 @@ function read_seq(filename) grad_prev_last = 0 end seq.GR[gi, bi].first = grad_prev_last - if length(gr.T) > 1 # this is for time-shaped case (I assume it is the extended trapezoid case) + if length(gr.T) > 1 || (isdefined(gr, :time_shape_id) && gr.time_shape_id != 0) # this is for time-shaped case (I assume it is the extended trapezoid case) seq.GR[gi, bi].last = gr.A[end] #I need to check this or [end-1] else odd_step1 = [seq.GR[gi, bi].first; 2 * gr.A] @@ -524,6 +524,9 @@ function read_Grad(gradLibrary, shapeLibrary, Δt_gr, i) delay = g[4] #Amplitude gA = amplitude * decompress_shape(shapeLibrary[amp_shape_id]...) + if length(gA) == 1 + gA = gA[1] + end Nrf = length(gA) - 1 #Creating timings if time_shape_id == 0 #no time waveform @@ -533,8 +536,12 @@ function read_Grad(gradLibrary, shapeLibrary, Δt_gr, i) else gt = decompress_shape(shapeLibrary[time_shape_id]...) gT = (gt[2:end] .- gt[1:end-1]) * Δt_gr + if length(gT) == 1 + gT = gT[1] + end G = Grad(gA,gT,0,0,delay) end + G.time_shape_id = time_shape_id end G end diff --git a/KomaMRIFiles/test/runtests.jl b/KomaMRIFiles/test/runtests.jl index dba7504f7..4ad1247d9 100644 --- a/KomaMRIFiles/test/runtests.jl +++ b/KomaMRIFiles/test/runtests.jl @@ -91,7 +91,7 @@ end if Namp == 1 && Ntim == 1 return 1e-3*γ*KomaMRIBase.get_theo_A(gr; off_val=0) elseif Namp > 1 && Ntim == 1 - return 1e-3*γ*[KomaMRIBase.get_theo_A(gr; off_val=0)[2:end-1]; gr.last] + return 1e-3*γ*[gr.first; KomaMRIBase.get_theo_A(gr; off_val=0)[3:end-1]; gr.last] elseif Namp > 1 && Ntim > 1 return 1e-3*γ*KomaMRIBase.get_theo_A(gr; off_val=0)[2:end] end