Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KomaUI Plotting] obj_ui[] does not draw on first time updated. Need to press :rho or other option. #407

Closed
curtcorum opened this issue Jun 13, 2024 · 9 comments · Fixed by #413 or #490
Labels
bug Something isn't working

Comments

@curtcorum
Copy link
Contributor

What happened?

obj_ui[] does not draw on first time updated:
obj_ui_first_update

Need to press :rho or other button option:
push_rho

Environment

OS x86_64-linux-gnu
Julia 1.10.4
KomaMRIPlots 0.8.3
KomaMRIFiles 0.8.2
KomaMRI 0.8.2
KomaMRICore 0.8.3
KomaMRIBase 0.8.4
@curtcorum curtcorum added the bug Something isn't working label Jun 13, 2024
@curtcorum
Copy link
Contributor Author

obj_ui[]=brain_phantom2D();

Has same behavior. No draw the first time.

@curtcorum
Copy link
Contributor Author

obj_ui[]=pelvis_phantom2D()

Also does the same thing, so consistent. Same code or same code called?

@cncastillo
Copy link
Member

cncastillo commented Jun 16, 2024

I will need to look into this, in KomaUI.jl we define the callbacks as follows:

    on((obj) -> view_ui!(obj, w, seq_ui[], widgets_button_obj; key=, darkmode), obj_ui)

    for (widget_button, key) in zip(widgets_button_obj, fieldnames_obj)
        on((cnt) -> view_ui!(cnt, w, obj_ui[], seq_ui[], widgets_button_obj; key, darkmode), widget_button)
    end

So, for example, the first one means that each time obj_ui changes the view_ui! function is triggered. I believe the problem are the buttons, I am fixing this locally.

@cncastillo
Copy link
Member

cncastillo commented Jun 16, 2024

After looking into it, that wasn't the problem. There are two things that I didn't realize:

  • plot_phantom_map was changed to use Plot instead of the backend-agnostic plot_koma, and that generates this problem.
  • If view_2D=true, the plot uses scatter instead of scattergl, which is very slow.

@pvillacorta could you fix this?

@cncastillo
Copy link
Member

@pvillacorta Also, it seems that plotting a phantom with too many spins shows fewer spins, with no warning telling the user that it is happening.

@curtcorum
Copy link
Contributor Author

@pvillacorta @cncastillo

It does seem to do the warning the first time only, which is probably related to the calling issues mentioned in: #407 (comment)

julia> obj_ui[]=brain_phantom3D(;ss=2)
┌ Warning: For performance reasons, the number of displayed spins was capped to `max_spins`=100000.
└ @ KomaMRIPlots ~/src/KomaMRI/KomaMRIPlots/src/ui/DisplayFunctions.jl:1080

@pvillacorta
Copy link
Collaborator

See maxlog=1 in line 1080 of 592b85f. That is why the message only displays once

@pvillacorta
Copy link
Collaborator

  • plot_phantom_map was changed to use Plot instead of the backend-agnostic plot_koma, and that generates this problem.

The solution is not as easy as using plot_koma again, since PlotlyJS.plot (which is called by plot_koma when using the Plotly backend) does not support frames for animations. It looks like a bug from PlotlyJS. See:


  • If view_2D=true, the plot uses scatter instead of scattergl, which is very slow.

Solved in #413, as well as the maxlog issue

@pvillacorta
Copy link
Collaborator

#413 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants