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

[MAINT] Refactor test nifti label maskers #4333

Merged
merged 10 commits into from Mar 21, 2024

Conversation

Remi-Gau
Copy link
Collaborator

Changes proposed in this pull request:

  • use existing fixtures
  • add new fixtures
  • parametrize tests
  • extract tests for errors and warnings
  • split long tests into independent tests

Copy link
Contributor

👋 @Remi-Gau 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.

@Remi-Gau Remi-Gau marked this pull request as ready for review March 20, 2024 15:44
Copy link

codecov bot commented Mar 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.07%. Comparing base (abb80ff) to head (d4ad8cf).
Report is 34 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4333      +/-   ##
==========================================
+ Coverage   91.85%   92.07%   +0.21%     
==========================================
  Files         144      143       -1     
  Lines       16419    16496      +77     
  Branches     3434     3463      +29     
==========================================
+ Hits        15082    15188     +106     
+ Misses        792      760      -32     
- Partials      545      548       +3     
Flag Coverage Δ
macos-latest_3.11_test_plotting ?
ubuntu-latest_3.10_test_plotting ?
ubuntu-latest_3.8_test_min 68.83% <ø> (?)
ubuntu-latest_3.9_test_plotting 91.91% <ø> (?)
windows-latest_3.10_test_plotting 91.92% <ø> (?)
windows-latest_3.11_test_plotting 91.92% <ø> (?)

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.

LGTM overall, thx !

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 then.

)

# Test with data and atlas of different shape:
# the atlas should be resampled to the data
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC, both atlas and mask would be resampled?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

From the doc:

For example, if resampling_target is “data”, the atlas is resampled to the shape of the data if needed.

If it is “labels” then mask_img and images provided to fit() are resampled to the shape and affine of maps_img.

“None” means no resampling: if shapes and affines do not match, a ValueError is raised.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When the target is labels there is a check in the test to make sure the mask is resampled.

I don't see a test for the None case though so actually worth adding it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see! So mask_img does not need to be resampled to data because it is applied to the labels_img (not the data). As mentioned here:
"Mask to apply to regions before extracting signals."

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

@man-shu man-shu merged commit a0f7ecc into nilearn:main Mar 21, 2024
32 of 34 checks passed
@man-shu
Copy link
Contributor

man-shu commented Mar 21, 2024

Merging!

@Remi-Gau
Copy link
Collaborator Author

Just realized that the test for some of the errors did not have a match= to make sure that they send the proper error message.

Will make a mini follow up PR

@man-shu
Copy link
Contributor

man-shu commented Mar 21, 2024

Oops, did I merge too soon?

@Remi-Gau
Copy link
Collaborator Author

Oops, did I merge too soon?

no worries, I will send a follow up PR that should be smaller and also easier to review

@Remi-Gau Remi-Gau deleted the refactor/tests_niftilabelmaskers branch March 21, 2024 13:37
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