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

plotting surfaces in jupyter notebook tutorial broken #177

Open
binarybottle opened this issue Jun 10, 2019 · 14 comments
Open

plotting surfaces in jupyter notebook tutorial broken #177

binarybottle opened this issue Jun 10, 2019 · 14 comments

Comments

@binarybottle
Copy link
Member

Screen Shot 2019-06-10 at 8 19 16 AM

@binarybottle
Copy link
Member Author

@binarybottle binarybottle changed the title nbpapaya not displaying in jupyter notebook tutorial nbpapaya not plotting surfaces in jupyter notebook tutorial Jun 10, 2019
@binarybottle
Copy link
Member Author

binarybottle commented Jun 10, 2019

I tried nilearn's plot_surf (https://nilearn.github.io/modules/generated/nilearn.plotting.plot_surf.html#nilearn.plotting.plot_surf) on mindboggle data:

import numpy as np
depths_array = np.asarray(depths)
fs_surf_mesh = subject_path + 'surf/lh.pial'
nilearn.plotting.plot_surf(surf_mesh=fs_surf_mesh, surf_map=depths_array, bg_map=None, 
                           hemi='left', view='lateral', 
                           cmap=None, colorbar=True, 
                           avg_method='mean', threshold=None, 
                           alpha='auto', bg_on_data=False, darkness=1, 
                           vmin=None, vmax=None, cbar_vmin=None, cbar_vmax=None, 
                           title=None, output_file=None, axes=None, figure=None)

but got the following error:


NotImplementedError Traceback (most recent call last)
in
8 alpha='auto', bg_on_data=False, darkness=1,
9 vmin=None, vmax=None, cbar_vmin=None, cbar_vmax=None,
---> 10 title=None, output_file=None, axes=None, figure=None)

/opt/miniconda-latest/envs/mb/lib/python3.6/site-packages/nilearn/plotting/surf_plotting.py in plot_surf(surf_mesh, surf_map, bg_map, hemi, view, cmap, colorbar, avg_method, threshold, alpha, bg_on_data, darkness, vmin, vmax, cbar_vmin, cbar_vmax, title, output_file, axes, figure, **kwargs)
188 axes.set_xlim(*limits)
189 axes.set_ylim(*limits)
--> 190 axes.set_aspect(.74)
191 axes.view_init(elev=elev, azim=azim)
192 axes.set_axis_off()

/opt/miniconda-latest/envs/mb/lib/python3.6/site-packages/matplotlib/axes/_base.py in set_aspect(self, aspect, adjustable, anchor, share)
1279 if (not cbook._str_equal(aspect, 'auto')) and self.name == '3d':
1280 raise NotImplementedError(
-> 1281 'It is not currently possible to manually set the aspect '
1282 'on 3D axes')
1283

NotImplementedError: It is not currently possible to manually set the aspect on 3D axes

@binarybottle binarybottle changed the title nbpapaya not plotting surfaces in jupyter notebook tutorial plotting surfaces in jupyter notebook tutorial broken Jun 10, 2019
@PeerHerholz
Copy link
Contributor

That might be a matplotlib thingy. I had the same problem recently and solved it by downgrading matplotlib to 3.0.3 I think.

@PeerHerholz
Copy link
Contributor

pinging @binarybottle to ask about current status: should I try to implement a corresponding fix?

@satra
Copy link
Member

satra commented Oct 4, 2019

@PeerHerholz - that would be great. perhaps a quick look to see if niwidgets can be used may also be helpful.

@PeerHerholz
Copy link
Contributor

@satra, on it! I'll try both (nilearn-matplotlib and niwidgets) here.

@PeerHerholz
Copy link
Contributor

quick update re nilearn: there will be a fix in the next release of nilearn and nistats as mentioned by this neurostars post. As the problem is not related to nilearn but matplotlib (starting at version 3.1) we could either install nilearn from source or downgrade the matplotlib version. Otherwise, we would've to wait for the next release which should happen soon. Let me know what you think (I would vote for waiting for the next release). Re niwidgets: currently checking it.

@PeerHerholz
Copy link
Contributor

Downgrading matplotlib to 3.0.3 solves it and both, the static (plot_surf) and interactive plot (view_surf) are working:

Screen Shot 2019-10-16 at 10 41 20 AM
Screen Shot 2019-10-16 at 10 44 53 AM

Although the interactive plot needs some more tweaking.

@PeerHerholz
Copy link
Contributor

Re niwidgets: not sure about it, that is if what I did makes sense. I had to put the extracted values (e.g. depths) into a .gii as niwidgets requires that. To do so, I converted the FreeSurfer surface to .gii, loaded it using nibabel, exchanged the values in the first dimension with the depth values and saved it. When trying to plot it as an overlay in niwidgets nothing is visible, but when I plot it directly it looks like this:
Screen Shot 2019-10-16 at 5 20 06 PM

@binarybottle
Copy link
Member Author

Wow, nice workaround, @PeerHerholz!

@PeerHerholz
Copy link
Contributor

@binarybottle should we go with the nilearn version first, till I figure out the niwidgets part completely?

@binarybottle
Copy link
Member Author

binarybottle commented Nov 5, 2019 via email

@satra
Copy link
Member

satra commented Nov 5, 2019

@PeerHerholz - while nilearn can plot surfaces, i'm not sure it can plot the shape features. hence it may limit what you can do.

in addition to niwidgets, you may want to take a look at vtk.js, which i know has been used in jupyter notebooks.

@PeerHerholz
Copy link
Contributor

@satra, yes. That's related to the examples and question I posted a bit further up. The example is based on depth values and the plotting seems to work (higher depth values further inside the cortex). The point I raised back then was how to tweak the plot to make it clearer and more interpretable. Was this your point? That although plots might work, they are not very comprehensive? In general, I like the nilearn version as it's rather light-weighted and (maybe) easier to use, especially for new users. That being said, if certain plotting (functions that would allow users to create plots for publications, posters, talks, etc.) would be included in the images, this should also be fine.

I'll check out vtk.js. There's also itkwidgets, but going from vtk to itk might create another hurdle we want to avoid.

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

No branches or pull requests

4 participants