Skip to content
Snippets Groups Projects
Verified Commit 60a999bd authored by Michiel Cottaar's avatar Michiel Cottaar
Browse files

Add visual regression tests for more sequences

parent 2e7fd09d
No related branches found
No related tags found
No related merge requests found
Pipeline #23590 failed
......@@ -2,7 +2,7 @@ module MakieMRIBuilder
using Makie
import MakieCore
import MakieCore: @recipe, theme, generic_plot_attributes!, Attributes, automatic
import MRIBuilder.Plot: SequenceDiagram, range_line, normalise, plot_sequence
import MRIBuilder.Plot: SequenceDiagram, range_full, normalise, plot_sequence
import MRIBuilder: BaseSequence, BaseBuildingBlock, duration
@recipe(Plot_Sequence, sequence) do scene
......@@ -42,7 +42,7 @@ function Makie.plot!(scene:: Plot_Sequence)
current_y = 0.
for label in (:ADC, :Gz, :Gy, :Gx, :G, :RFy, :RFx)
line = getproperty(sequence_diagram, label)
(lower, upper) = range_line(line)
(lower, upper) = range_full(line)
if !(lower upper)
shift = current_y - lower
Makie.text!(scene, string(label) * " "; position=(0., shift), align=(:right, :center), text_kwargs..., kwargs...)
......
......@@ -70,6 +70,15 @@ range_event(spl::SinglePlotLine) = (
maximum(spl.event_amplitudes; init=0.),
)
function range_full(spl::SinglePlotLine)
(l1, u1) = range_line(spl)
(l2, u2) = range_event(spl)
return (
min(l1, l2),
max(u1, u2),
)
end
normalise(spl::SinglePlotLine, line_value, event_value) = SinglePlotLine(
spl.times, iszero(line_value) ? spl.amplitudes : (spl.amplitudes ./ line_value),
spl.event_times, iszero(event_value) ? spl.event_amplitudes : (spl.event_amplitudes ./ event_value)
......
test/plots/finite_rf.png

42.1 KiB

test/plots/grad_dwi.png

22.2 KiB

test/plots/perfect_dwi.png

15.6 KiB

......@@ -39,9 +39,7 @@ using Gtk
InstantPulse(flip_angle=120., phase=0.),
)
end
f = Figure()
Axis(f[1, 1])
plot_sequence(sequence)
f = plot_sequence(sequence)
CairoMakie.save(fname, f)
end
......@@ -50,15 +48,12 @@ using Gtk
@testset "Finite gradients" begin
function plot_finite_dwi(fname, single_gradient=false)
sequence = DWI(bval=2., TE=80, TR=100, orientation=[0, -1, 1], scanner=Siemens_Prisma)
f = Figure()
Axis(f[1, 1])
plot!(sequence; single_gradient=single_gradient)
sequence = DWI(bval=2., TE=:min, TR=100, slice_thickness=2., scanner=Siemens_Prisma)
f = plot_sequence(sequence)
CairoMakie.save(fname, f)
end
@visualtest fn->plot_finite_dwi(fn, true) "$dir/single_grad_dwi.png" !isCI
@visualtest fn->plot_finite_dwi(fn, false) "$dir/multi_grad_dwi.png" !isCI
@visualtest fn->plot_finite_dwi(fn, true) "$dir/plots/grad_dwi.png" !isCI
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