-
Notifications
You must be signed in to change notification settings - Fork 530
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
RF: Simplify high-pass filtering in algorithms.confounds #3651
base: master
Are you sure you want to change the base?
Conversation
Legendre and cosine detrending are implemented almost identically, although with several minor variations. Here I separate regressor creation from detrending to unify the implementations. This now uses `np.linalg.pinv(X)` to estimate the betas in both cases, rather than using `np.linalg.lstsq` in the cosine filter. lstsq uses SVD and can thus fail to converge in rare cases. Under no circumstances should (X.T @ X) be singular, so the pseudoinverse is unique and precisely what we want.
4dde564
to
4717e23
Compare
@jhlegarreta I wonder if I could bug you for a review. I suspect this would be a quick one for you, but let me know if it's not. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3651 +/- ##
==========================================
- Coverage 70.83% 70.47% -0.36%
==========================================
Files 1276 1276
Lines 59314 59305 -9
Branches 9824 9822 -2
==========================================
- Hits 42013 41797 -216
- Misses 16125 16353 +228
+ Partials 1176 1155 -21 ☔ View full report in Codecov by Sentry. |
For Legendre regressors, the ith column is the ith-order polynomial, so the constant column is 0. For the cosine regressors, a constant column was appended to the end, in contradiction of the docstring. This brings both into alignment so columns are sorted from lowest to highest frequency and aligns the DCT behavior with its docstring.
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.
Take my review with some care: I am not familiar with fMRI data processing.
Changes look sensible; the methods being changed are not tested, though 😬. Documenting the methods would help 📖.
Thanks for addressing the reported issue so fast.
Legendre and cosine detrending are implemented almost identically, although with several minor variations. Here I separate regressor creation from detrending to unify the implementations.
This now uses
np.linalg.pinv(X)
to estimate the betas in both cases, rather than usingnp.linalg.lstsq
in the cosine filter. lstsq uses SVD and can thus fail to converge in rare cases. Under no circumstances should (X.T @ X) be singular, so the pseudoinverse is unique and precisely what we want.Issue raised in https://neurostars.org/t/fmriprep-numpy-linalg-linalg-linalgerror-svd-did-not-converge/29525.