diff --git a/KomaMRIFiles/src/Sequence/Pulseq.jl b/KomaMRIFiles/src/Sequence/Pulseq.jl index 5c82f8b02..99ce93a85 100644 --- a/KomaMRIFiles/src/Sequence/Pulseq.jl +++ b/KomaMRIFiles/src/Sequence/Pulseq.jl @@ -476,11 +476,17 @@ Reads the gradient. It is used internally by [`get_block`](@ref). """ function read_Grad(gradLibrary, shapeLibrary, Δt_gr, i) G = Grad(0,0) - if gradLibrary[i]["type"] == 't' #if trapezoidal gradient + if i==0 + #No gradient in this block, i==0 is reserved for this case + return G + elseif isempty(gradLibrary) #isempty(gradLibrary) checked first or error below + #No gradient shapes defined in seq file, set G to zero from above + @error "No gradients defined in seq file [GRADIENTS] or [TRAP] sections, but id $i used in [BLOCKS]." + elseif gradLibrary[i]["type"] == 't' #if trapezoidal gradient #(1)amplitude (2)rise (3)flat (4)fall (5)delay g_A, g_rise, g_T, g_fall, g_delay = gradLibrary[i]["data"] G = Grad(g_A,g_T,g_rise,g_fall,g_delay) - elseif gradLibrary[i]["type"] == 'g' #Arbitrary gradient waveform + elseif gradLibrary[i]["type"] == 'g' #Arbitrary gradient waveform, fix from https://github.com/JuliaHealth/KomaMRI.jl/discussions/311#discussion-6251011 #(1)amplitude (2)amp_shape_id (3)time_shape_id (4)delay g = gradLibrary[i]["data"] amplitude = g[1]