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] nilearn.interface: make private functions used outside of their module public #4168

Merged
merged 11 commits into from Dec 18, 2023

Conversation

Remi-Gau
Copy link
Collaborator

@Remi-Gau Remi-Gau commented Dec 16, 2023

Changes proposed in this pull request:

  • remove nilearn.interface.bids._utils and move functions closer to where they are used or into a new nilearn.interface.bids.utils
  • make private functions public if used in nilearn.interface.fmriprep used outside of their module

@Remi-Gau
Copy link
Collaborator Author

Several functions interfaces/fmriprep seem to be unused in the code base.

@htwangtw is this to be expected?

  • '_load_motion' mentioned only 1 time in nilearn/interfaces/fmriprep/load_confounds_components.py.
  • '_load_high_pass' mentioned only 1 time in nilearn/interfaces/fmriprep/load_confounds_components.py.
  • '_load_wm_csf' mentioned only 1 time in nilearn/interfaces/fmriprep/load_confounds_components.py.
  • '_load_global_signal' mentioned only 1 time in nilearn/interfaces/fmriprep/load_confounds_components.py.
  • '_load_compcor' mentioned only 1 time in nilearn/interfaces/fmriprep/load_confounds_components.py.
  • '_load_ica_aroma' mentioned only 1 time in nilearn/interfaces/fmriprep/load_confounds_components.py.
  • '_load_scrub' mentioned only 1 time in nilearn/interfaces/fmriprep/load_confounds_components.py.
  • '_load_non_steady_state' mentioned only 1 time in nilearn/interfaces/fmriprep/load_confounds_components.py.

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.

Copy link

codecov bot commented Dec 16, 2023

Codecov Report

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

Comparison is base (092c339) 91.97% compared to head (19da3e9) 92.00%.

Files Patch % Lines
nilearn/interfaces/bids/utils.py 90.90% 0 Missing and 2 partials ⚠️
nilearn/interfaces/bids/glm.py 97.22% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4168      +/-   ##
==========================================
+ Coverage   91.97%   92.00%   +0.02%     
==========================================
  Files         146      145       -1     
  Lines       16382    16378       -4     
  Branches     3431     3431              
==========================================
+ Hits        15068    15069       +1     
+ Misses        771      768       -3     
+ Partials      543      541       -2     
Flag Coverage Δ
macos-latest_3.10_test_plotting 91.78% <97.45%> (+0.02%) ⬆️
macos-latest_3.11_test_plotting 91.78% <97.45%> (+0.02%) ⬆️
macos-latest_3.12_test_plotting ?
macos-latest_3.8_test_plotting ?
macos-latest_3.9_test_plotting 91.75% <97.45%> (+0.02%) ⬆️
ubuntu-latest_3.10_test_plotting 91.78% <97.45%> (+0.02%) ⬆️
ubuntu-latest_3.11_test_plotting 91.78% <97.45%> (+0.02%) ⬆️
ubuntu-latest_3.12_test_plotting 91.78% <97.45%> (+0.02%) ⬆️
ubuntu-latest_3.12_test_pre 91.78% <97.45%> (+0.02%) ⬆️
ubuntu-latest_3.8_test_min 68.97% <72.88%> (-0.01%) ⬇️
ubuntu-latest_3.8_test_plot_min 91.50% <97.45%> (+0.02%) ⬆️
ubuntu-latest_3.8_test_plotting 91.74% <97.45%> (+0.02%) ⬆️
ubuntu-latest_3.9_test_plotting 91.75% <97.45%> (+0.02%) ⬆️
windows-latest_3.10_test_plotting 91.76% <97.45%> (+0.02%) ⬆️
windows-latest_3.11_test_plotting 91.76% <97.45%> (+0.02%) ⬆️
windows-latest_3.12_test_plotting ?
windows-latest_3.8_test_plotting 91.72% <97.45%> (+0.02%) ⬆️
windows-latest_3.9_test_plotting 91.73% <97.45%> (+0.02%) ⬆️

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.

@htwangtw
Copy link
Member

Several functions interfaces/fmriprep seem to be unused in the code base.

@htwangtw is this to be expected?

  • '_load_motion' mentioned only 1 time in nilearn/interfaces/fmriprep/load_confounds_components.py.
  • '_load_high_pass' mentioned only 1 time in nilearn/interfaces/fmriprep/load_confounds_components.py.
  • '_load_wm_csf' mentioned only 1 time in nilearn/interfaces/fmriprep/load_confounds_components.py.
  • '_load_global_signal' mentioned only 1 time in nilearn/interfaces/fmriprep/load_confounds_components.py.
  • '_load_compcor' mentioned only 1 time in nilearn/interfaces/fmriprep/load_confounds_components.py.
  • '_load_ica_aroma' mentioned only 1 time in nilearn/interfaces/fmriprep/load_confounds_components.py.
  • '_load_scrub' mentioned only 1 time in nilearn/interfaces/fmriprep/load_confounds_components.py.
  • '_load_non_steady_state' mentioned only 1 time in nilearn/interfaces/fmriprep/load_confounds_components.py.

Yes - here's how these _load_* functions are used in the code:
https://github.com/nilearn/nilearn/blob/main/nilearn%2Finterfaces%2Ffmriprep%2Fload_confounds.py#L485

@Remi-Gau Remi-Gau changed the title [ENH] nilearn.interface: make private functions used outside of their module public [MAINT] nilearn.interface: make private functions used outside of their module public Dec 16, 2023
@Remi-Gau
Copy link
Collaborator Author

Ah yes. Thanks.
Will add a comment at the top of that module in case future me forgets about this.

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, but there are some codecov complaints...

@Remi-Gau
Copy link
Collaborator Author

LGTM, but there are some codecov complaints...

looks like some of those are "false positive".

will double check but I think that in any case there are couple of lines in the incriminated files that were not hit by the tests so I will to cover them with some new tests

@Remi-Gau
Copy link
Collaborator Author

OK should improve the coverage of those lines: https://app.codecov.io/gh/nilearn/nilearn/blob/master/nilearn%2Finterfaces%2Fbids%2Fglm.py#L98

Had to do some refactoring of the test suite so probably increase the number of line changes

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.

Copy link
Member

@htwangtw htwangtw left a comment

Choose a reason for hiding this comment

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

LGTM!

@Remi-Gau Remi-Gau merged commit 8b0657b into nilearn:main Dec 18, 2023
32 checks passed
@Remi-Gau Remi-Gau deleted the confounds_private branch December 18, 2023 20:17
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