Skip to content

Commit

Permalink
Add temporal time_shape_id property to Grad struct for debuging
Browse files Browse the repository at this point in the history
  • Loading branch information
beorostica committed Mar 27, 2024
1 parent c95e309 commit 83da9a5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions KomaMRIBase/src/datatypes/sequence/Grad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ mutable struct Grad
delay::Real
first
last
time_shape_id

This comment has been minimized.

Copy link
@cncastillo

cncastillo Mar 27, 2024

Member

Remove this.

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
Expand Down
9 changes: 8 additions & 1 deletion KomaMRIFiles/src/Sequence/Pulseq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion KomaMRIFiles/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 83da9a5

Please sign in to comment.