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 flat maps + plotting additional data as transparency #2658

Open
jsmentch opened this issue Jan 11, 2021 · 7 comments · May be fixed by #2899 or #4184
Open

Plotting flat maps + plotting additional data as transparency #2658

jsmentch opened this issue Jan 11, 2021 · 7 comments · May be fixed by #2899 or #4184
Assignees
Labels
Enhancement for feature requests Plotting The issue is related to plotting functionalities.

Comments

@jsmentch
Copy link

I am plotting Cifti files with hcp-utils and nilearn. It works very nicely for the standard inflated surface but the aspect ratio is off for plotting a flatmap (squished to a square):

download (42)

download (43)

I'm so far unable to plot the bilateral brain flat map without this stretching happening. Is there interest in supporting plotting these flatmaps, maybe adding a keyword arg? And/or does anyone have tips on how to preserve the correct aspect ratio? I have been trying to modify the axes and fig.subplots_adjust but no luck.

Another related feature request is to be able to plot multiple stats on one surface map eg one type of data by color and another by transparency/alpha. On the above images for example, I've plotted my surf_data as normal and then blended it into the bg_map based on another map of r2score values. I could help to add this kind of functionality if it would be helpful and not complicate things too much. Thanks!

@jsmentch jsmentch added the Enhancement for feature requests label Jan 11, 2021
@bthirion
Copy link
Member

Thx for the report !
What version of Nilearn are you using ? The 0.7.0 ?
Other wise, it would be great if you could share the flat map for us to reproduce and fix.

@jsmentch
Copy link
Author

Sure! Yes this is v0.7.0 and looks like their surfaces are here

here is an example if hcp-utils is installed:

import hcp_utils as hcp
from nilearn import plotting
plotting.plot_surf(hcp.mesh.flat_right)

plot is not too stretched I think plotting one hemisphere
download (44)

plotting bilateral is squished:
plotting.plot_surf(hcp.mesh.flat)
download (45)

@NicolasGensollen NicolasGensollen added the Plotting The issue is related to plotting functionalities. label Jan 12, 2021
@bthirion
Copy link
Member

This is weird indeed. thank you for reporting.
Best,

@jeromedockes
Copy link
Member

thanks! interestingly I can also reproduce it with view_surf, which uses completely independent machinery than plot_surf

@bthirion
Copy link
Member

bthirion commented Jul 5, 2021

Could we have a short script to work on it ?

@jeromedockes
Copy link
Member

Could we have a short script to work on it ?

basically the script posted above by @jsmentch:

import numpy as np
from matplotlib import pyplot as plt

import hcp_utils as hcp
from nilearn import plotting, surface

surf = surface.load_surf_mesh(hcp.mesh.flat)

plotting.plot_surf(surf)
plt.gcf().savefig("/tmp/plot-surf-hcp.png", bbox_inches="tight")
plotting.view_surf(surf).open_in_browser()
plt.close("all")


plt.scatter(surf.coordinates[::10, 1], surf.coordinates[::10, 2])
plt.gca().set_aspect(1)
plt.gcf().savefig("/tmp/scatter-nodes.png", bbox_inches="tight")

you will need to pip install hcp-utils

@bthirion
Copy link
Member

Indeed, thx. @NicolasGensollen I think this is one for you, whenever you can. Best,

@NicolasGensollen NicolasGensollen self-assigned this Jul 19, 2021
@NicolasGensollen NicolasGensollen linked a pull request Jul 19, 2021 that will close this issue
@ymzayek ymzayek linked a pull request Jan 5, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement for feature requests Plotting The issue is related to plotting functionalities.
Projects
None yet
4 participants