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] Let _check_embedded_nifti_masker work with surface masker #4120

Merged
merged 14 commits into from Dec 5, 2023

Conversation

ymzayek
Copy link
Member

@ymzayek ymzayek commented Nov 24, 2023

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.

Copy link

codecov bot commented Nov 27, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (d6d822d) 91.81% compared to head (292f9bc) 91.85%.
Report is 5 commits behind head on main.

Files Patch % Lines
nilearn/decoding/space_net.py 66.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4120      +/-   ##
==========================================
+ Coverage   91.81%   91.85%   +0.03%     
==========================================
  Files         144      144              
  Lines       16172    16236      +64     
  Branches     3360     3381      +21     
==========================================
+ Hits        14849    14913      +64     
+ Misses        781      780       -1     
- Partials      542      543       +1     
Flag Coverage Δ
macos-latest_3.10_test_plotting 91.67% <92.59%> (+0.03%) ⬆️
macos-latest_3.11_test_plotting 91.67% <92.59%> (+0.03%) ⬆️
macos-latest_3.12_test_plotting 91.67% <92.59%> (+0.03%) ⬆️
macos-latest_3.8_test_plotting 91.63% <92.59%> (+0.03%) ⬆️
macos-latest_3.9_test_plotting 91.64% <92.59%> (+0.03%) ⬆️
ubuntu-latest_3.10_test_plotting 91.67% <92.59%> (+0.03%) ⬆️
ubuntu-latest_3.11_test_plotting 91.67% <92.59%> (+0.03%) ⬆️
ubuntu-latest_3.12_test_plotting 91.67% <92.59%> (+0.03%) ⬆️
ubuntu-latest_3.12_test_pre 91.67% <92.59%> (+0.03%) ⬆️
ubuntu-latest_3.8_test_min 69.06% <92.59%> (-0.11%) ⬇️
ubuntu-latest_3.8_test_plot_min 91.39% <92.59%> (+0.03%) ⬆️
ubuntu-latest_3.8_test_plotting 91.63% <92.59%> (+0.03%) ⬆️
ubuntu-latest_3.9_test_plotting 91.64% <92.59%> (+0.03%) ⬆️
windows-latest_3.10_test_plotting 91.65% <92.59%> (+0.03%) ⬆️
windows-latest_3.11_test_plotting 91.65% <92.59%> (+0.03%) ⬆️
windows-latest_3.12_test_plotting 91.65% <92.59%> (+0.03%) ⬆️
windows-latest_3.8_test_plotting 91.61% <92.59%> (+0.03%) ⬆️
windows-latest_3.9_test_plotting 91.62% <92.59%> (+0.03%) ⬆️

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.

from .._utils.cache_mixin import _check_memory
from .._utils.class_inspect import get_params
from .multi_nifti_masker import MultiNiftiMasker
from .nifti_masker import NiftiMasker


def _check_embedded_nifti_masker(estimator, multi_subject=True):
def _check_embedded_nifti_masker(estimator, masker_type="multi_nii"):
Copy link
Member Author

Choose a reason for hiding this comment

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

Can't we just remove this keyword argument completely and just set masker_type based on isinstance checks?

Copy link
Member

Choose a reason for hiding this comment

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

I agree with that. ATM the masker_type could be "multi_nii", 'surface', 'nifti', but this is fare from clear.

"tests",
"externals",
}
modules_to_ignore = {"data", "tests", "externals", "conftest"}
Copy link
Collaborator

Choose a reason for hiding this comment

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

functions in conftest.py should be ignored by default

@@ -34,7 +34,7 @@ def test_number_public_functions():
If this is intentional, then the number should be updated in the test.
Otherwise it means that the public API of nilearn has changed by mistake.
"""
assert len({_[0] for _ in all_functions()}) == 227
assert len({_[0] for _ in all_functions()}) == 205
Copy link
Collaborator

Choose a reason for hiding this comment

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

consequence of ignoring functions in conftest.py

@@ -12,6 +12,7 @@
# we need to import these fixtures even if not used in this module
from nilearn.datasets.tests._testing import request_mocker # noqa: F401
from nilearn.datasets.tests._testing import temp_nilearn_data_dir # noqa: F401
from nilearn.experimental.surface.tests.conftest import * # noqa: F401, F403
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would not be opposed to move the fixture in nilearn/conftest.py rather than doing an "import all".
Any reasons why we should not do it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not a blocker for a merge.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well we wanted to isolate the new surface module and related code while it's still being developed. But I don't see a way to do that for this PR. I don't like this solution either I just didn't want to rewrite the fixtures and this is temporary. I can instead just import the needed fixtures

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK let's leave it like this for now though maybe we should probably leave a comment to flag this for future us so that the temporary does not become too permanent.

Copy link
Member Author

Choose a reason for hiding this comment

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

I made the imports explicit and added a note.

Copy link
Collaborator

Choose a reason for hiding this comment

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

awesome!!! thanks

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.

Good with me

@ymzayek
Copy link
Member Author

ymzayek commented Nov 30, 2023

I have not added a test for space net yet but I'm thinking to do it in another PR. It might be more involved to get it to work since BaseSpaceNet fit method calls get_data on the mask img, which is not adapted to surface data. I'll open a follow-up PR after this is merged

@ymzayek ymzayek added this to the release 0.11.0 milestone Nov 30, 2023
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.

from .._utils.cache_mixin import _check_memory
from .._utils.class_inspect import get_params
from .multi_nifti_masker import MultiNiftiMasker
from .nifti_masker import NiftiMasker


def _check_embedded_nifti_masker(estimator, multi_subject=True):
def _check_embedded_nifti_masker(estimator, masker_type="multi_nii"):
Copy link
Member

Choose a reason for hiding this comment

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

I agree with that. ATM the masker_type could be "multi_nii", 'surface', 'nifti', but this is fare from clear.

@ymzayek
Copy link
Member Author

ymzayek commented Dec 4, 2023

I agree with that. ATM the masker_type could be "multi_nii", 'surface', 'nifti', but this is fare from clear.

@bthirion it is stated in the docstring of this function and it is a private function in any case. What is supported in terms of the type of makser is also relayed to the functions or classes that use this function.

@bthirion
Copy link
Member

bthirion commented Dec 4, 2023

Can be merged I think.

@ymzayek ymzayek merged commit ef08959 into nilearn:main Dec 5, 2023
32 checks passed
@ymzayek ymzayek deleted the decoder_masker_validation branch December 5, 2023 08:54
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.

None yet

3 participants