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] properly infer slice_time_ref from BIDS derivatives #3605

Merged
merged 50 commits into from Apr 12, 2023

Conversation

Remi-Gau
Copy link
Collaborator

@Remi-Gau Remi-Gau commented Mar 18, 2023

Closes #3299

Changes proposed in this pull request:

  • decouple fetching RepetitionTime from fetching metadata related to slice timing
  • start a deprecating cycle to change the default value of slice_time_ref from 0 to None
  • add t_r and slice_time_ref validation for first level models
  • extract functions to get metadata from bids sidecar json files
  • add appropriate tests including regression test and test for deprecation warning

@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2023

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

@codecov
Copy link

codecov bot commented Mar 18, 2023

Codecov Report

Merging #3605 (de4a2a9) into main (0df241e) will increase coverage by 0.08%.
The diff coverage is 97.77%.

@@            Coverage Diff             @@
##             main    #3605      +/-   ##
==========================================
+ Coverage   91.32%   91.41%   +0.08%     
==========================================
  Files         133      133              
  Lines       15475    15540      +65     
  Branches     3208     3228      +20     
==========================================
+ Hits        14133    14206      +73     
+ Misses        789      784       -5     
+ Partials      553      550       -3     
Impacted Files Coverage Δ
nilearn/glm/first_level/first_level.py 93.80% <95.45%> (+2.15%) ⬆️
nilearn/_utils/data_gen.py 96.54% <100.00%> (+0.06%) ⬆️
nilearn/interfaces/bids/_utils.py 97.72% <100.00%> (ø)
nilearn/interfaces/bids/query.py 97.10% <100.00%> (+2.81%) ⬆️

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

nilearn/_utils/data_gen.py Outdated Show resolved Hide resolved
@@ -1122,6 +1164,7 @@ def _get_processed_imgs(
supported_filters=_bids_entities()["raw"]
+ _bids_entities()["derivatives"],
extra_filter=img_filters,
verbose=verbose,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am having to pass this verbose parameter around a bit too much to be able to control whether warnings, messages should be printed...

This should probably be handled better by implementing a logger in another PR.

@Remi-Gau Remi-Gau requested a review from ymzayek March 29, 2023 15:22
@Remi-Gau
Copy link
Collaborator Author

then in this (perhaps edge) case, the behavior would be different

yup your comment just prompted me to actually try to map most cases to get a better idea because I was not even clear about it myself.

@Remi-Gau
Copy link
Collaborator Author

Remi-Gau commented Mar 31, 2023

Todo

  • add test to specifically catch the deprecation warning.

nilearn/_utils/data_gen.py Show resolved Hide resolved
nilearn/_utils/data_gen.py Outdated Show resolved Hide resolved
nilearn/_utils/tests/test_data_gen.py Outdated Show resolved Hide resolved
nilearn/_utils/tests/test_data_gen.py Outdated Show resolved Hide resolved
nilearn/glm/first_level/first_level.py Outdated Show resolved Hide resolved
nilearn/glm/tests/test_first_level.py Show resolved Hide resolved
nilearn/glm/tests/test_first_level.py Show resolved Hide resolved
nilearn/interfaces/tests/test_bids.py Show resolved Hide resolved
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.

Almost there ! Thx

nilearn/glm/first_level/first_level.py Show resolved Hide resolved
nilearn/glm/first_level/first_level.py Show resolved Hide resolved
nilearn/interfaces/tests/test_bids.py Show resolved Hide resolved
Copy link
Member

@ymzayek ymzayek 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 @Remi-Gau !

nilearn/_utils/tests/test_data_gen.py Outdated Show resolved Hide resolved
Remi-Gau and others added 2 commits April 11, 2023 13:35
Co-authored-by: Yasmin <63292494+ymzayek@users.noreply.github.com>
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.

@ymzayek
Copy link
Member

ymzayek commented Apr 12, 2023

@Remi-Gau can you rebase on main and resolve the conflict? Then this can be merged.

@Remi-Gau
Copy link
Collaborator Author

rebased + green CI = merging

@Remi-Gau Remi-Gau merged commit 0b33453 into nilearn:main Apr 12, 2023
27 checks passed
@Remi-Gau Remi-Gau deleted the slice_timing branch April 12, 2023 09:38
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.

first_level_from_bids warnings ignore slice_time_ref argument
4 participants