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] Implement surface maps masker #4830

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

man-shu
Copy link
Contributor

@man-shu man-shu commented Nov 29, 2024

Changes proposed in this pull request:

  • A new SurfaceMapsMasker object:
    • implement fit_transform
    • implement inverse_transform
      • will return unmasked img as of now, should return masked if mask is provided
    • implement generate_report and everything else related to reporting
      • test the reporting with an example
    • allow memory caching
    • update check_fitted
    • logging
    • tests

@man-shu man-shu added this to the 0.11.1 milestone Nov 29, 2024
@man-shu man-shu self-assigned this Nov 29, 2024
@man-shu man-shu added Blocker Surface Related to surface data or surface analysis. labels Nov 29, 2024
Copy link
Contributor

👋 @man-shu 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.

Copy link

codecov bot commented Nov 29, 2024

Codecov Report

Attention: Patch coverage is 59.52381% with 51 lines in your changes missing coverage. Please review.

Project coverage is 93.41%. Comparing base (a88a118) to head (da511e6).
Report is 34 commits behind head on main.

Files with missing lines Patch % Lines
nilearn/maskers/surface_maps_masker.py 59.20% 41 Missing and 10 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4830      +/-   ##
==========================================
- Coverage   93.62%   93.41%   -0.21%     
==========================================
  Files         135      137       +2     
  Lines       17105    17269     +164     
  Branches     2954     2976      +22     
==========================================
+ Hits        16014    16132     +118     
- Misses        579      617      +38     
- Partials      512      520       +8     
Flag Coverage Δ
macos-latest_3.10_test_plotting 92.93% <59.52%> (-0.21%) ⬇️
macos-latest_3.11_test_plotting 92.93% <59.52%> (-0.21%) ⬇️
macos-latest_3.12_test_plotting 92.92% <59.52%> (-0.21%) ⬇️
macos-latest_3.13_test_plotting 92.93% <59.52%> (-0.21%) ⬇️
macos-latest_3.9_test_plotting 92.91% <59.52%> (-0.21%) ⬇️
ubuntu-latest_3.10_test_plotting 92.93% <59.52%> (-0.21%) ⬇️
ubuntu-latest_3.11_test_plotting 92.93% <59.52%> (-0.21%) ⬇️
ubuntu-latest_3.12_test_plotting 92.93% <59.52%> (-0.21%) ⬇️
ubuntu-latest_3.13_test_plotting 92.93% <59.52%> (-0.21%) ⬇️
ubuntu-latest_3.13_test_pre 92.95% <59.52%> (-0.20%) ⬇️
ubuntu-latest_3.9_test_min 69.28% <59.52%> (+0.10%) ⬆️
ubuntu-latest_3.9_test_plot_min 91.82% <59.52%> (-0.20%) ⬇️
ubuntu-latest_3.9_test_plotting 92.91% <59.52%> (-0.21%) ⬇️
windows-latest_3.10_test_plotting 92.91% <59.52%> (-0.21%) ⬇️
windows-latest_3.11_test_plotting 92.91% <59.52%> (-0.21%) ⬇️
windows-latest_3.12_test_plotting 92.91% <59.52%> (-0.21%) ⬇️
windows-latest_3.13_test_plotting 92.91% <59.52%> (-0.21%) ⬇️
windows-latest_3.9_test_plotting 92.89% <59.52%> (-0.21%) ⬇️

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.

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.

This looks quit good, but coverage could still be improved.

@pytest.fixture
def surf_maps_img(surf_mesh):
"""Return a sample surface map image using the sample mesh.
Has 4 different overlapping regions per hemisphere.
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be better to have different numbers of regions per hemisphere ?

-------
output : :obj:`numpy.ndarray`
Signal for each element.
shape: (img data shape, total number of vertices)
Copy link
Member

Choose a reason for hiding this comment

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

does not sound right.

maps_img_ : :obj:`~numpy.ndarray`
The maps image converted to a numpy array by concatenating the \
data of both hemispheres/parts.
shape: (n_vertices, n_regions)
Copy link
Member

Choose a reason for hiding this comment

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

What is the distinction between n_regions and self.n_elements ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocker Surface Related to surface data or surface analysis.
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

[ENH] Implement SurfaceMapsMasker to allow Parcellations to work with surface data
2 participants