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

[ENH] Improve plotting contours for PlotlySurfaceFigure objects by adding add_contours method #3949

Open
wants to merge 44 commits into
base: main
Choose a base branch
from

Conversation

psadil
Copy link
Contributor

@psadil psadil commented Sep 4, 2023

Changes proposed in this pull request:

@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2023

👋 @psadil Thanks for creating a PR!

Until this PR is ready for review, you can include the [WIP] tag in its title, or leave it as a github draft.

Please make sure it is compliant with our contributing guidelines. In particular, be sure it checks the boxes listed below.

  • PR has an interpretable title.
  • PR links to Github issue with mention Closes #XXXX (see our documentation on PR structure)
  • Code is PEP8-compliant (see our documentation on coding style)
  • Changelog or what's new entry in doc/changes/latest.rst (see our documentation on PR structure)

For new features:

  • There is at least one unit test per new function / class (see our documentation on testing)
  • The new feature is demoed in at least one relevant example.

For bug fixes:

  • There is at least one test that would fail under the original bug conditions.

We will review it as quick as possible, feel free to ping us with questions if needed.

@codecov
Copy link

codecov bot commented Sep 4, 2023

Codecov Report

Attention: Patch coverage is 96.27329% with 6 lines in your changes missing coverage. Please review.

Project coverage is 92.84%. Comparing base (abb80ff) to head (cb8ad06).
Report is 113 commits behind head on main.

Files Patch % Lines
nilearn/plotting/displays/_figures.py 96.15% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3949      +/-   ##
==========================================
+ Coverage   91.85%   92.84%   +0.98%     
==========================================
  Files         144      147       +3     
  Lines       16419    17166     +747     
  Branches     3434     3611     +177     
==========================================
+ Hits        15082    15938     +856     
+ Misses        792      685     -107     
+ Partials      545      543       -2     
Flag Coverage Δ
macos-latest_3.10_test_plotting 92.39% <95.65%> (?)
macos-latest_3.11_test_plotting 92.39% <95.65%> (+0.53%) ⬆️
macos-latest_3.12_test_plotting 92.39% <95.65%> (?)
macos-latest_3.8_test_plotting 92.36% <95.65%> (?)
macos-latest_3.9_test_plotting 92.37% <95.65%> (?)
ubuntu-latest_3.10_test_plotting 92.39% <95.65%> (+0.53%) ⬆️
ubuntu-latest_3.11_test_plotting 92.39% <95.65%> (?)
ubuntu-latest_3.12_test_plotting 92.39% <95.65%> (?)
ubuntu-latest_3.12_test_pre 92.39% <95.65%> (?)
ubuntu-latest_3.8_test_min 68.42% <0.00%> (?)
ubuntu-latest_3.8_test_plot_min 91.30% <12.42%> (?)
ubuntu-latest_3.8_test_plotting 92.36% <95.65%> (?)
ubuntu-latest_3.9_test_plotting 92.37% <95.65%> (?)
windows-latest_3.10_test_plotting 92.38% <95.65%> (?)
windows-latest_3.11_test_plotting 92.38% <95.65%> (?)
windows-latest_3.12_test_plotting 92.38% <95.65%> (?)
windows-latest_3.8_test_plotting 92.35% <95.65%> (?)
windows-latest_3.9_test_plotting 92.37% <95.65%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@ymzayek
Copy link
Member

ymzayek commented Sep 5, 2023

@psadil thanks for getting started on this! Will try to start a review this week

@ymzayek ymzayek changed the title Improving plot surf contours [ENH] Improve plotting contours for PlotlySurfaceFigure objects by adding add_contours method Sep 5, 2023
@psadil
Copy link
Contributor Author

psadil commented Sep 6, 2023

Tests added!

Do these seem like they're on the right track?

@Remi-Gau
Copy link
Collaborator

Remi-Gau commented Sep 6, 2023

Tests added!

Thanks!!

Do these seem like they're on the right track?

Had a very quick look: it does help also understand how these methods are used, so definitely useful

psadil and others added 4 commits September 6, 2023 10:08
Co-authored-by: Remi Gau <remi_gau@hotmail.com>
Co-authored-by: Remi Gau <remi_gau@hotmail.com>
Co-authored-by: Remi Gau <remi_gau@hotmail.com>
nilearn/plotting/displays/_figures.py Outdated Show resolved Hide resolved
nilearn/plotting/displays/_figures.py Outdated Show resolved Hide resolved
nilearn/plotting/tests/test_surf_plotting.py Outdated Show resolved Hide resolved
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, thx !

Co-authored-by: Himanshu Aggarwal <himanshuaggarwal1997@gmail.com>
psadil and others added 2 commits June 23, 2024 14:15
Co-authored-by: Remi Gau <remi_gau@hotmail.com>
Copy link
Contributor

@man-shu man-shu left a comment

Choose a reason for hiding this comment

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

Thanks for resolving all the comments @psadil ! But just a few more tests :)
And then we can add this to the changelog, see: https://nilearn.github.io/stable/development.html#changelog

nilearn/plotting/displays/_figures.py Show resolved Hide resolved
nilearn/plotting/displays/_figures.py Show resolved Hide resolved
@psadil
Copy link
Contributor Author

psadil commented Jul 1, 2024

It looks like those failures for NPY201 are being triggered by different parts of the repo?

@Remi-Gau
Copy link
Collaborator

Remi-Gau commented Jul 1, 2024

It looks like those failures for NPY201 are being triggered by different parts of the repo?

yes that's not you

I will merge the main branch in your PR to solve this: remember to pull first before you push again 😉

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.

Looks mostly good. A little effort on pedagogy would help.

nilearn/plotting/displays/_figures.py Outdated Show resolved Hide resolved

# Loop over the remaining vertices in order of distance from the
# current vertex
while len(visited_vertices) < len(centroids):
Copy link
Member

Choose a reason for hiding this comment

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

Can we make sure that the loop ends ?
What algorithm is implemented here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a modification of the approach listed in the original issue: #3711 (comment), with the modifications aiming to ensure that the contour does not cross itself. I'm not sure how it could fail to end, but if preferred I think I could update it to a for loop.

Copy link
Member

Choose a reason for hiding this comment

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

I'd more comfortable with a for loop indeed...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good! I cleaned up the sorting procedure a bit and added a few more explanatory comments cb8ad06.

nilearn/plotting/displays/_figures.py Outdated Show resolved Hide resolved
nilearn/plotting/displays/_figures.py Show resolved Hide resolved
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.

[ENH] improving plot_surf_contours
5 participants