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
[ENH] pad t and F 'short' contrasts with zeros #4067
Conversation
👋 @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.
For new features:
For bug fixes:
We will review it as quick as possible, feel free to ping us with questions if needed. |
mentioned in the associated issue, using the contrasts symbolically (eg. 'c1 - c2') in the example mentioned in the issue so avoid having to change contrast length when the high pass filter model is changed. |
@bthirion I would not mind an early review on this. I do not like that the warnings / errors that have to be thrown in different places, feels like there should be a single function checking contrast shape and doing the padding rather than changes in several places. |
You mean, one single function for t and F ? |
The PR looks good overall. |
con_val = pad_contrast( | ||
con_val=con_val, theta=reg.theta, contrast_type=contrast_type | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bthirion
any reason why for F contrasts we do not rely on the FContrast methods and do something like
reg = regression_result[label_].Fcontrast(con_val)
the way we do it for T contrasts above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, this is because we had to trick it somehow to support fixed effects on F contrasts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok this may require a comment if we can remember the why otherwise I could add a TODO to try to refactor this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add this to your PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a TODO for now in case we want to merge and tackle this in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rather in another PR.
Codecov Report
@@ Coverage Diff @@
## main #4067 +/- ##
==========================================
+ Coverage 91.50% 91.60% +0.09%
==========================================
Files 143 143
Lines 16072 16091 +19
Branches 3339 3345 +6
==========================================
+ Hits 14707 14740 +33
+ Misses 820 804 -16
- Partials 545 547 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 7 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
TODO
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall!
nilearn/glm/_utils.py
Outdated
Where q = number of :term:`contrast` vectors | ||
and p = number of regressors. | ||
|
||
theta theta of RegressionResults instances |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add the type for theta here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added the type but also tried to improve the doc string: let me know if this reads sufficiently well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thx.
con_val = pad_contrast( | ||
con_val=con_val, theta=reg.theta, contrast_type=contrast_type | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rather in another PR.
* pad contrasts * refactor * rm test for warning * remove obsolete test * add test for error F contrast * add comment * add comment * update changelog * update changelog * improve doc string
Changes proposed in this pull request: