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

[BUG] plotly in nilearn.surface.vol_to_surf opens two interactive windows #4376

Open
3 of 9 tasks
lilikapa opened this issue Apr 10, 2024 · 4 comments
Open
3 of 9 tasks
Labels
Bug for bug reports

Comments

@lilikapa
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Operating system

  • Linux
  • Mac
  • Windows

Operating system version

  • Mac OS Version 14.4 "Sonoma"

Python version

  • 3.12
  • 3.11
  • 3.10
  • 3.9
  • 3.8

nilearn version

0.10.3

Expected behavior

(see below)

Current behavior & error messages

Hi nilearn community,

Thank you very much for this very helpful tool. I am not really sure whether this is really a bug. However, since a warning and a request were stated in the documentation, I thought it might be useful to report the following behavior.

When selecting engine='plotly' as a parameter within the plot_surf_roi function in a JupyterNotebook (see snippet of my code below), an interactive window is open within my JupyterNotebook, but also another in my browser. I would have expected the interactive window to only open within the notebook. However, if this is the expected behavior, please ignore the issue. Other than that, the plotting seemed to work well.

best,
lya

Steps and code to reproduce bug

fig = plotting.plot_surf_roi(fsavg6['infl_left'], roi_map=roi_surf,
                             hemi='left', view='lateral', 
                             bg_map=fsavg6['sulc_left'], bg_on_data=True,  
                             cmap='Blues', 
                             colorbar=True, 
                             vmin=0, vmax=2,
                             engine='plotly',
                             title='title')
fig.show()
@lilikapa lilikapa added the Bug for bug reports label Apr 10, 2024
@Remi-Gau
Copy link
Collaborator

Remi-Gau commented Apr 10, 2024

I can reproduce this with the code below on Nilearn 0.10.4

from nilearn import datasets
from nilearn import plotting
import numpy as np
from nilearn import surface

stat_img = datasets.load_sample_motor_activation_image()

fsaverage = datasets.fetch_surf_fsaverage()

curv_right = surface.load_surf_data(fsaverage.curv_right)
curv_right_sign = np.sign(curv_right)

texture = surface.vol_to_surf(stat_img, fsaverage.pial_right)

engine="plotly"

fig = plotting.plot_surf_stat_map(
    fsaverage.infl_right, texture, hemi='right',
    title='Surface right hemisphere', colorbar=True,
    threshold=1., bg_map=curv_right_sign, bg_on_data=True,
    engine=engine
)
fig.show() 

@Remi-Gau
Copy link
Collaborator

no idea if this is the expected behavior or if this is a new thing
will quickly check with older versions of nilearn

@bthirion
Copy link
Member

OK, I would not expect this behavior (disclaimer: I rarely use NBs)

@Remi-Gau
Copy link
Collaborator

Note that a very basic example like this does not behave like this:

import plotly.express as px

fig = px.line(x=["a","b","c"], y=[1,3,2], title="sample figure")

fig.show()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug for bug reports
Projects
None yet
Development

No branches or pull requests

3 participants