From ba42455efbcc8031a6442ff90ccf519997ed9325 Mon Sep 17 00:00:00 2001
From: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk>
Date: Mon, 8 Apr 2024 14:21:25 +0100
Subject: [PATCH] Adjust gradient reading for new shape interface

---
 src/sequence_io/pulseq.jl | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/sequence_io/pulseq.jl b/src/sequence_io/pulseq.jl
index 556c786..09c4319 100644
--- a/src/sequence_io/pulseq.jl
+++ b/src/sequence_io/pulseq.jl
@@ -234,7 +234,6 @@ function build_sequence(; scanner=nothing, B0=3., TR=nothing, definitions, versi
                 phase_size = rad2deg.(phase_shape) .+ phase_times .* (proc.freq * 1e-3 * 360) .+ rad2deg(proc.phase)
             end
             if version != v"1.3.1" && !iszero(proc.time_id)
-                @show shapes
                 (num, _, time_shape) = shapes[proc.time_id]
                 times = time_shape .* rf_raster
                 ampl = ampl_size
@@ -260,15 +259,16 @@ function build_sequence(; scanner=nothing, B0=3., TR=nothing, definitions, versi
             if !isnothing(gradients) && grad_id in keys(gradients)
                 proc = gradients[grad_id]
                 start_time = proc.delay * 1e-3
-                (num, grad_shape) = shapes[proc.shape_id]
+                (num, grad_time, grad_shape) = shapes[proc.shape_id]
 
                 if version != v"1.3.1" && !iszero(proc.time_id)
-                    (num, time_shape) = shapes[proc.time_id]
-                    times = time_shape.amplitudes .* gradient_raster .+ start_time
+                    (num, _, time_shape) = shapes[proc.time_id]
+                    times = time_shape .* gradient_raster .+ start_time
+                    @assert length(times) == length(grad_shape)
                 else
-                    times = grad_shape.times .* (num * gradient_raster) .+ start_time
+                    times = grad_time .* (num * gradient_raster) .+ start_time
                 end
-                push!(grad_shapes, (times, grad_shape.amplitudes .* (proc.amp * 1e-9)))
+                push!(grad_shapes, (times, grad_shape .* (proc.amp * 1e-9)))
                 block_duration = max(start_time + num * gradient_raster, block_duration)
             elseif !isnothing(trap) && grad_id in keys(trap)
                 proc = trap[grad_id]
-- 
GitLab