Skip to content
Snippets Groups Projects
Unverified Commit a31143a6 authored by Michiel Cottaar's avatar Michiel Cottaar
Browse files

Allow BuildingBlock to start/end with non-zero gradient

This is to support Pulseq, where this behaviour is allowed.
parent c11198e8
No related branches found
No related tags found
1 merge request!3Add InstantPulse and InstantGradient pulseq extension support
......@@ -92,10 +92,18 @@ The gradient is linearly interpolated between these points (see [`waveform_seque
"""
function waveform(bb::BaseBuildingBlock)
ndim = ndim_grad(bb)
first_block = waveform_sequence(bb)[1][2]
if first_block isa NoGradient
first_grad = ndim == 3 ? zero(SVector{3, Float64}) : 0.
elseif first_block isa ConstantGradient
first_grad = first_block.gradient_strength
else
first_grad = first_block.gradient_strength_start
end
if ndim == 3
result = Tuple{VariableType, SVector{3, VariableType}}[(0., zero(SVector{3, Float64}))]
result = Tuple{VariableType, SVector{3, VariableType}}[(0., first_grad)]
elseif ndim == 1
result = Tuple{VariableType, VariableType}[(0., 0.)]
result = Tuple{VariableType, VariableType}[(0., first_grad)]
else
return []
end
......@@ -116,7 +124,6 @@ function waveform(bb::BaseBuildingBlock)
error("Unrecognised block type in BuildingBlock: $(typeof(bb)).")
end
end
@assert all(abs.(result[end][2]) .<= 1e-12) "$(typeof(bb)) does not end up with a gradient of zero. This is probably caused by an improper implementation of this BuildingBlock."
return result
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment