-
Notifications
You must be signed in to change notification settings - Fork 575
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] Refactor design matrix and contrast formula for the two-sample T-test example #4407
Conversation
👋 @YCHuang0610 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. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4407 +/- ##
==========================================
+ Coverage 91.85% 92.03% +0.17%
==========================================
Files 144 143 -1
Lines 16419 16647 +228
Branches 3434 3531 +97
==========================================
+ Hits 15082 15321 +239
+ Misses 792 758 -34
- Partials 545 568 +23
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
import numpy as np | ||
|
||
condition_effect = np.hstack(([1] * n_subjects, [-1] * n_subjects)) | ||
vertical_subjects = np.hstack(([1] * n_subjects, [0] * n_subjects)) | ||
horizontal_subjects = np.hstack(([0] * n_subjects, [1] * n_subjects)) |
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.
Sorry I should have been clearer, but when you do this you make the design matrix rank deficient: the sum of these two regressors, is equal to the some of all the subject regressors.
This means that the design matrix is no longer invertible, and some contrasts are not estimable. Normally, you should get a warning when you run that code.
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.
Sorry for that mistake for the paired design matrix.
Now I have modified the paired design matrix as follows:
which rank is 17.
The unpaired design matrix is now added a intercept column as follows:
Its rank is 2 which is a full column rank matrix.
… full column rank
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.
examples/05_glm_second_level/plot_second_level_two_sample_test.py
Outdated
Show resolved
Hide resolved
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.
Thanks for your contribution, @YCHuang0610! Just a couple final things before we merge this.
Since this is your first contribution to nilearn could you please:
- add yourself to the authors section of CITATION.cff
- also add this change to the
nilearn/doc/changes/latest.rst
See https://nilearn.github.io/stable/development.html#changelog for more details on how to do this. And don't hesitate to ping me here if needed.
Thanks!
Thank you for the guidance! |
doc builder was complaining about the example's label in |
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.
All good now. Merging!
Closes #4400
Changes proposed in this pull request: