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] Set edgecolors when plotting contours so that they are rendered #3973

Merged
merged 8 commits into from Sep 14, 2023

Conversation

ymzayek
Copy link
Member

@ymzayek ymzayek commented Sep 13, 2023

@github-actions
Copy link
Contributor

👋 @ymzayek 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 13, 2023

Codecov Report

Merging #3973 (2e98fbb) into main (93c49f1) will decrease coverage by 0.10%.
Report is 4 commits behind head on main.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##             main    #3973      +/-   ##
==========================================
- Coverage   91.79%   91.69%   -0.10%     
==========================================
  Files         134      134              
  Lines       15772    15781       +9     
  Branches     3284     3289       +5     
==========================================
- Hits        14478    14471       -7     
- Misses        751      767      +16     
  Partials      543      543              
Flag Coverage Δ
macos-latest_3.10 91.67% <50.00%> (-0.03%) ⬇️
macos-latest_3.11 91.67% <50.00%> (-0.03%) ⬇️
macos-latest_3.8 91.64% <50.00%> (-0.03%) ⬇️
macos-latest_3.9 91.64% <50.00%> (-0.03%) ⬇️
ubuntu-latest_3.10 91.67% <50.00%> (-0.03%) ⬇️
ubuntu-latest_3.11 91.67% <50.00%> (-0.03%) ⬇️
ubuntu-latest_3.8 ?
ubuntu-latest_3.9 ?
windows-latest_3.10 91.62% <50.00%> (-0.03%) ⬇️
windows-latest_3.11 91.62% <50.00%> (-0.03%) ⬇️
windows-latest_3.8 91.58% <50.00%> (-0.03%) ⬇️
windows-latest_3.9 91.58% <50.00%> (-0.03%) ⬇️

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

Files Changed Coverage Δ
nilearn/plotting/surf_plotting.py 94.30% <50.00%> (-1.19%) ⬇️

... and 7 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ymzayek
Copy link
Member Author

ymzayek commented Sep 13, 2023

With this PR, the contours should render correctly again.

Code to test:

from nilearn import datasets
from nilearn import surface
from nilearn import plotting
import numpy as np

motor_images = datasets.fetch_neurovault_motor_task()
stat_img = motor_images.images[0]

fsaverage = datasets.fetch_surf_fsaverage()
texture = surface.vol_to_surf(stat_img, fsaverage.pial_right)

destrieux_atlas = datasets.fetch_atlas_surf_destrieux()
parcellation = destrieux_atlas['map_right']

regions_dict = {b'G_postcentral': 'Postcentral gyrus',
                b'G_precentral': 'Precentral gyrus'}
regions_indices = [
    np.where(np.array(destrieux_atlas['labels']) == region)[0][0]
    for region in regions_dict
]
labels = list(regions_dict.values())

output_file = './plop.pdf'
fig = plotting.plot_surf_stat_map(
    fsaverage.infl_right, texture, hemi='right',
    threshold=1., bg_map=fsaverage.sulc_right,
#    output_file=output_file
)
plotting.show()

output_file = './plop2.pdf'
plotting.plot_surf_contours(
    fsaverage.infl_right, parcellation, labels=labels,
    levels=regions_indices, figure=fig,
    legend=True,
    colors=['g', 'k'],
#    output_file=output_file
)

Uncomment the output_file argument to check rendering in PDF

@ymzayek
Copy link
Member Author

ymzayek commented Sep 14, 2023

Contours are rendered again: https://output.circle-artifacts.com/output/job/2b6d2712-1278-44a8-bc36-25c8ad1b65a8/artifacts/0/dev/auto_examples/01_plotting/plot_3d_map_to_surface_projection.html#display-outlines-of-the-regions-of-interest-on-top-of-a-statistical-map

vs bug in dev docs: https://nilearn.github.io/dev/auto_examples/01_plotting/plot_3d_map_to_surface_projection.html#display-outlines-of-the-regions-of-interest-on-top-of-a-statistical-map

Side note:
Codecov patch failure is because we don't test mpl version < 3.3.3. In our minimum versions test, mpl 3.5.3 gets installed being the latest version that is compatible with the minimum versions of the other packages we specify. This is separate from this PR but shouldn't we rather also specify mpl version to be the oldest we support for the min test workflow?

doc/changes/latest.rst Outdated Show resolved Hide resolved
Copy link
Collaborator

@Remi-Gau Remi-Gau left a comment

Choose a reason for hiding this comment

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

I cannot reproduce with the code snippet you provided but I trust CI more than my own incompetence.

Good to go

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.

@Remi-Gau Remi-Gau merged commit 8d8467a into nilearn:main Sep 14, 2023
28 of 29 checks passed
@ymzayek ymzayek deleted the fix-contours branch September 15, 2023 08:48
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

Successfully merging this pull request may close these issues.

[BUG] Contours in plot_3d_map_to_surface_projection examples are not being rendered correctly
3 participants