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

Copy input image header to the output by default #4397

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

man-shu
Copy link
Contributor

@man-shu man-shu commented Apr 24, 2024

The following functions under nilearn.image have been updated to copy image header by default

Copy link
Contributor

👋 @man-shu 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 Apr 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.95%. Comparing base (abb80ff) to head (88fbc46).
Report is 70 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4397      +/-   ##
==========================================
+ Coverage   91.85%   91.95%   +0.09%     
==========================================
  Files         144      143       -1     
  Lines       16419    16639     +220     
  Branches     3434     3529      +95     
==========================================
+ Hits        15082    15300     +218     
+ Misses        792      773      -19     
- Partials      545      566      +21     
Flag Coverage Δ
macos-13_3.10_test_plotting 91.81% <100.00%> (?)
macos-13_3.12_test_plotting 91.81% <100.00%> (?)
macos-13_3.8_test_plotting 91.77% <100.00%> (?)
macos-13_3.9_test_plotting 91.78% <100.00%> (?)
macos-14_3.12_test_plotting 91.81% <100.00%> (?)
macos-latest_3.11_test_plotting ?
ubuntu-latest_3.10_test_plotting 91.81% <100.00%> (-0.05%) ⬇️
ubuntu-latest_3.11_test_plotting 91.81% <100.00%> (?)
ubuntu-latest_3.12_test_plotting 91.81% <100.00%> (?)
ubuntu-latest_3.12_test_pre 91.81% <100.00%> (?)
ubuntu-latest_3.8_test_plot_min 91.48% <100.00%> (?)
ubuntu-latest_3.8_test_plotting 91.77% <100.00%> (?)
ubuntu-latest_3.9_test_plotting 91.78% <100.00%> (?)
windows-latest_3.10_test_plotting 91.79% <100.00%> (?)
windows-latest_3.11_test_plotting 91.79% <100.00%> (?)
windows-latest_3.12_test_plotting 91.79% <100.00%> (?)
windows-latest_3.8_test_plotting 91.75% <100.00%> (?)
windows-latest_3.9_test_plotting 91.75% <100.00%> (?)

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.

@man-shu
Copy link
Contributor Author

man-shu commented Apr 24, 2024

The fix was indeed the one proposed in #4393.

So now the default behavior for all functions under nilearn.image module (except math_img) is to directly copy the input image's header info to the output image in whichever fields possible and update the rest, via new_img_like.

As for math_img, it was the most peculiar case and I think the choices made in #4337 should stay in place.

@man-shu man-shu marked this pull request as draft April 24, 2024 13:06
@man-shu man-shu marked this pull request as ready for review April 24, 2024 19:23
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.

The change LGTM but you must at least make it visible.
I'm wondering whether we should go through deprecation cycles...

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.

@Remi-Gau
Copy link
Collaborator

Remi-Gau commented Apr 25, 2024

I'm wondering whether we should go through deprecation cycles...

yeah I am wondering about this as well, because some of this may induce behavior changes in the code.

unless we decide that the old behavior was a bug and that this is a bug fix

@emdupre
Copy link
Member

emdupre commented Apr 30, 2024

Personally I would be +1 deprecation cycles ! This is a noticeable enough change (and I don't know that the before was wrong ) that I think we should alert users.

@Remi-Gau
Copy link
Collaborator

Personally I would be +1 deprecation cycles ! This is a noticeable enough change (and I don't know that the previous before was wrong ) that I think we should alert users.

Good with me to err on the side of caution and let our users know.

@man-shu
Copy link
Contributor Author

man-shu commented May 2, 2024

Yes, I also agree with going through the deprecation cycles and letting people know.

But my feeling is that it should not affect existing internal nilearn routines because, as far as I know, we don't ever directly use the header information in any of the workflows. Some bids-dependent functionalities need TR info, but that is extracted from JSON sidecars.

However, some external software probably does use the headers.

@man-shu man-shu requested a review from Remi-Gau May 3, 2024 09:22
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.

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.

[BUG] Several functions under the image module do not carry over the header information to the output
4 participants