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

Correctly normalise negative gradient pulses

parent ecb521aa
No related branches found
No related tags found
1 merge request!17Compressed pulseq
......@@ -177,12 +177,13 @@ function PulseqBlock(block::BaseBuildingBlock; BlockDurationRaster, AdcRasterTim
times = [t for (t, _) in waveform(block)]
for dim in 1:3
amplitudes = [g[dim] for (_, g) in waveform(block)]
if iszero(maximum(abs.(amplitudes); init=0.))
max_ampl = maximum(abs.(amplitudes); init=0.)
if iszero(max_ampl)
push!(grads, nothing)
else
push!(grads, PulseqGradient(
maximum(amplitudes) * 1e3,
PulseqShape(amplitudes ./ maximum(amplitudes)),
max_ampl * 1e3,
PulseqShape(amplitudes ./ max_ampl),
PulseqShape(times .* 1e-3),
0.,
))
......
......@@ -94,6 +94,7 @@ function gen_section(comp:: PulseqComponents, ::Val{:shapes})
res = PulseqSection{:shapes}(String[])
for index in sort([keys(comp.shapes)...])
shape = compress(comp.shapes[index])
@assert all(isfinite.(shape.samples))
append!(res.content, [
"",
"shape_id $index",
......
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