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

[FIX] Fix aspect ratio in surface plotting #2899

Conversation

NicolasGensollen
Copy link
Member

Fixes #2658

WIP...

Example

For plot_surf:

import hcp_utils as hcp
from nilearn import plotting, surface

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

Now gives:

aspect

TODO: Fix view_surf which, as pointed out by @jeromedockes, suffers from the same problem although it relies on a different machinery.

@NicolasGensollen NicolasGensollen self-assigned this Jul 19, 2021
@codecov
Copy link

codecov bot commented Jul 19, 2021

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d3caac1) 88.63% compared to head (ff34a75) 88.61%.
Report is 808 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2899      +/-   ##
==========================================
- Coverage   88.63%   88.61%   -0.02%     
==========================================
  Files         101      101              
  Lines       13818    13830      +12     
  Branches     2688     2690       +2     
==========================================
+ Hits        12247    12255       +8     
- Misses        979      983       +4     
  Partials      592      592              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@bthirion bthirion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least, the fix for plot_surf seems good.

@NicolasGensollen
Copy link
Member Author

Update: ea0f01e proposes a possible fix for view_surf. If you test it with:

import hcp_utils as hcp
from nilearn import plotting, surface

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

You should get:

view_surf1

With the problem of the initial zoom that still need to be fixed. That is, initially the figure looks like this:

view_surf2

and you have to zoom out.

@bthirion
Copy link
Member

I still have the problem with the initial zoom.

@NicolasGensollen NicolasGensollen marked this pull request as ready for review July 27, 2021 09:48
@NicolasGensollen
Copy link
Member Author

I still have the problem with the initial zoom.

Weird... 🤔
Do you still have the issue now? I changed the cameras settings and the examples in the artifacts look good now.

@bthirion
Copy link
Member

bthirion commented Aug 2, 2021

LGTM now.

Copy link
Member

@bthirion bthirion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Maybe a small whatsnew entry ?

@@ -76,22 +76,22 @@ function getCamera(plotDivId, viewSelectId) {
}
}
let cameras = {
"left": {eye: {x: -1.7, y: 0, z: 0},
"left": {eye: {x: -3.0, y: 0, z: 0},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem is that now the brain is too small and too far from the colorbar when plotting a surface map on a mesh in mni space (or close to it), which is the vast majority of use cases:

before:
newplot

now:

newplot(1)

I don't think deteriorating the plots for the most common use case to address an edge case is the way to go. maybe we should allow users to control the zoom (although they can do it with the mouse once the interactive plot is opened, and maybe further programmatic customization of the plots should be deferred to after #2902 is merged)

otherwise the fix to control the aspect ratio looks good!

@Remi-Gau Remi-Gau added the Surface Related to surface data or surface analysis. label Jun 13, 2023
@ymzayek
Copy link
Member

ymzayek commented Jan 3, 2024

I can take this one over. It is still an issue and concluding from what is done here I would keep the aspect ratio fix for both plot_surf and view_surf but remove the changes in the camera settings. There will still be the problem of the initial zoom for view_surf being too big for this use case but the user can zoom out.

@Remi-Gau Remi-Gau added the Plotting The issue is related to plotting functionalities. label Jan 23, 2024
@Remi-Gau
Copy link
Collaborator

Remi-Gau commented Jun 4, 2024

@Remi-Gau Remi-Gau closed this Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Plotting The issue is related to plotting functionalities. Surface Related to surface data or surface analysis.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plotting flat maps + plotting additional data as transparency
5 participants