Skip to content

Commit

Permalink
KomaMRI/Plots performance improvements plots #364
Browse files Browse the repository at this point in the history
  • Loading branch information
cncastillo committed Apr 8, 2024
1 parent 26b8d50 commit d1573c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions KomaMRIPlots/src/ui/DisplayFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ Plots a sequence struct.
- `darkmode`: (`::Bool`, `=false`) boolean to indicate whether to display darkmode style
- `range`: (`::Vector{Real}`, `=[]`) time range to be displayed initially
- `title`: (`::String`, `=""`) plot title
- `gl`: (`::Bool`, `=false`) use `PlotlyJS.scattergl` backend (faster)
- `max_rf_samples`: (`::Integer`, `=100`) maximum number of RF samples
- `show_adc`: (`::Bool`, `=false`) plot ADC samples with markers
# Returns
- `p`: (`::PlotlyJS.SyncPlot`) plot of the Sequence struct
Expand Down Expand Up @@ -864,7 +866,8 @@ function plot_signal(
slider=true,
show_sim_blocks=false,
darkmode=false,
range=[]
range=[],
gl=false
)
not_Koma = raw.params["systemVendor"] != "KomaMRI.jl"
t = []
Expand Down Expand Up @@ -953,10 +956,11 @@ function plot_signal(
if width !== nothing
l.width = width
end
p = [scatter() for j=1:3]
scatter_fun = gl ? scattergl : scatter
p = [scatter_fun() for j=1:3]
p[1] = scatter(x=t,y=abs.(signal), name="|S(t)|",hovertemplate="(%{x:.4f} ms, %{y:.3f} a.u.)")
p[2] = scatter(x=t,y=real.(signal),name="Re{S(t)}",hovertemplate="(%{x:.4f} ms, %{y:.3f} a.u.)")
p[3] = scatter(x=t,y=imag.(signal),name="Im{S(t)}",hovertemplate="(%{x:.4f} ms, %{y:.3f} a.u.)")
p[2] = scatter_fun(x=t,y=real.(signal),name="Re{S(t)}",hovertemplate="(%{x:.4f} ms, %{y:.3f} a.u.)")
p[3] = scatter_fun(x=t,y=imag.(signal),name="Im{S(t)}",hovertemplate="(%{x:.4f} ms, %{y:.3f} a.u.)")
config = PlotConfig(
displaylogo=false,
toImageButtonOptions=attr(
Expand Down
2 changes: 1 addition & 1 deletion src/ui/ExportUIFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ function view_ui!(seq::Sequence, w::Window; type="sequence", darkmode=true)
# Add loading progress and then a plot to the UI depending on type of the plot
if type == "sequence"
display_loading!(w, "Plotting sequence ...")
long_seq = lenght(seq) > 1000
long_seq = length(seq) > 1000
widget_plot = plot_seq(seq; darkmode, range=[0 30], slider=!long_seq, gl=long_seq, show_adc=false)
content!(w, "div#content", dom"div"(widget_plot))
@js_ w document.getElementById("content").dataset.content = "sequence"
Expand Down

0 comments on commit d1573c2

Please sign in to comment.