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
Conversation
ymzayek
commented
Nov 24, 2023
- Part of [ENH] Next steps for development on experimental surface module #4027
👋 @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.
For new features:
For bug fixes:
We will review it as quick as possible, feel free to ping us with questions if needed. |
Codecov ReportAttention:
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 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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"): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"} |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
nilearn/conftest.py
Outdated
@@ -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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome!!! thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good with me
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 |
There was a problem hiding this 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"): |
There was a problem hiding this comment.
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.
@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. |
Can be merged I think. |