nipy / mindboggle

Automated anatomical brain label/shape analysis software (+ website)
http://mindboggle.info
Other
146 stars 54 forks source link

plotting surfaces in jupyter notebook tutorial broken #177

Open binarybottle opened 5 years ago

binarybottle commented 5 years ago
Screen Shot 2019-06-10 at 8 19 16 AM
binarybottle commented 5 years ago

TO DO -- use nilearn's plot_surf:

https://nilearn.github.io/modules/generated/nilearn.plotting.plot_surf.html#nilearn.plotting.plot_surf

binarybottle commented 5 years ago

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
PeerHerholz commented 5 years ago

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 commented 5 years ago

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

satra commented 5 years ago

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

PeerHerholz commented 5 years ago

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

PeerHerholz commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Wow, nice workaround, @PeerHerholz!

PeerHerholz commented 4 years ago

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

binarybottle commented 4 years ago

Sounds good!

Cheers, @rno

Arno Klein, PhD MATTER Lab Director Joseph Healey Scholar Senior Research Scientist Child Mind Institute 101 E 56 St, NY, NY matter.childmind.org 347-577-2091


From: Peer Herholz notifications@github.com Sent: Tuesday, November 5, 2019 9:45:26 AM To: nipy/mindboggle mindboggle@noreply.github.com Cc: Arno Klein Arno.Klein@childmind.org; Mention mention@noreply.github.com Subject: Re: [nipy/mindboggle] plotting surfaces in jupyter notebook tutorial broken (#177)

@binarybottlehttps://github.com/binarybottle should we go with the nilearn version first, till I figure out the niwidgets part completely?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/nipy/mindboggle/issues/177?email_source=notifications&email_token=AABZX5EWEIVIWEJIIKU4YKLQSGBINA5CNFSM4HWTAJMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDC52YI#issuecomment-549838177, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AABZX5F6E7ELK5OHIBGIH7TQSGBINANCNFSM4HWTAJMA.

satra commented 4 years ago

@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 commented 4 years ago

@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.