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

[FIX] Make load_confounds' confounds file selection more generic #3794

Merged
merged 19 commits into from Jul 5, 2023

Conversation

tsalo
Copy link
Member

@tsalo tsalo commented Jun 29, 2023

Closes #3792.

Changes proposed in this pull request:

  • Build candidate confounds filenames from entities in the image files. The only value that is hardcoded is "desc-confounds".
  • Update tests to cover more cases.
    • The tests that would have failed before are test_get_file_name[True-_desc-confounds_regressors-part] and test_get_file_name[False-_desc-confounds_timeseries-part].

@github-actions
Copy link
Contributor

github-actions bot commented Jun 29, 2023

👋 @tsalo 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.

@tsalo tsalo added Bug for bug reports BIDS labels Jun 29, 2023
@tsalo tsalo changed the title Make load_confounds' confound-selection more generic [FIX] Make load_confounds' confound-selection more generic Jun 29, 2023
@Remi-Gau
Copy link
Collaborator

For the test I think I had modified the functions to generate dummy datasets to accommodate more bids derivatives entities.

Maybe this can help.

@codecov
Copy link

codecov bot commented Jun 29, 2023

Codecov Report

Merging #3794 (8888ef1) into main (089a1a0) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #3794      +/-   ##
==========================================
+ Coverage   91.52%   91.54%   +0.02%     
==========================================
  Files         133      133              
  Lines       15561    15598      +37     
  Branches     3229     3245      +16     
==========================================
+ Hits        14242    14279      +37     
  Misses        772      772              
  Partials      547      547              
Flag Coverage Δ
macos-latest_3.10 ?
macos-latest_3.11 ?
macos-latest_3.8 91.43% <100.00%> (+0.02%) ⬆️
macos-latest_3.9 91.43% <100.00%> (+0.02%) ⬆️
ubuntu-latest_3.10 91.46% <100.00%> (+0.02%) ⬆️
ubuntu-latest_3.11 ?
ubuntu-latest_3.8 ?
ubuntu-latest_3.9 ?
windows-latest_3.10 91.40% <100.00%> (+0.02%) ⬆️
windows-latest_3.11 91.40% <100.00%> (+0.02%) ⬆️
windows-latest_3.8 91.37% <100.00%> (+0.02%) ⬆️
windows-latest_3.9 ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...n/interfaces/fmriprep/tests/test_load_confounds.py 98.34% <ø> (ø)
nilearn/interfaces/fmriprep/tests/utils.py 100.00% <ø> (ø)
...ilearn/interfaces/fmriprep/load_confounds_utils.py 100.00% <100.00%> (ø)
...rfaces/fmriprep/tests/test_load_confounds_utils.py 100.00% <100.00%> (ø)

... and 14 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@tsalo
Copy link
Member Author

tsalo commented Jun 29, 2023

@Remi-Gau Thanks! I think I used the modified functions correctly.

@tsalo tsalo requested review from htwangtw and Remi-Gau June 29, 2023 19:30
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.

Main thing would be to extract into a function the part that generates the list of candidates files.

nilearn/interfaces/fmriprep/load_confounds_utils.py Outdated Show resolved Hide resolved
nilearn/interfaces/fmriprep/load_confounds_utils.py Outdated Show resolved Hide resolved
nilearn/interfaces/fmriprep/load_confounds_utils.py Outdated Show resolved Hide resolved
nilearn/interfaces/fmriprep/load_confounds_utils.py Outdated Show resolved Hide resolved
@tsalo tsalo changed the title [FIX] Make load_confounds' confound-selection more generic [FIX] Make load_confounds' confounds file selection more generic Jun 30, 2023
@tsalo tsalo marked this pull request as ready for review June 30, 2023 14:37
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 just one minor thing to refactor the test

Co-authored-by: Hao-Ting Wang <haotingwang@pm.me>
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
Copy link
Collaborator

Remi-Gau commented Jul 5, 2023

Thanks @tsalo

@Remi-Gau Remi-Gau merged commit e65624b into nilearn:main Jul 5, 2023
29 checks passed
@tsalo tsalo deleted the make-load-confounds-more-general branch July 5, 2023 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BIDS Bug for bug reports
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] load_confounds on 0.10.1 does not detect the corresponding confound file
3 participants