Dear Experts,
How can I calculate whitening matrix W using Nilearn? In SPM12 it is stored in SPM.xX.W after model estimation.
Thank you!
Ruslan
Dear Experts,
How can I calculate whitening matrix W using Nilearn? In SPM12 it is stored in SPM.xX.W after model estimation.
Thank you!
Ruslan
A lead for you to get started: several of the models of nilearn have a whiten method
Thank you! I have seen these functions and their descriptions before. I see that I can get whitened design matrix X. However, my question is: is it possible to somehow get whitening matrix W per se?
Ah right. Sorry. Misread your post.
Had a quick look at the code for those method but could not see anything that would match.
@bthirion do you have an idea?
Hi,
you obtained a whitened design matrix for each autocorrelation values, which makes it complex. It is thus hidden in the code.
You can find it here: nilearn/nilearn/glm/regression.py at main · nilearn/nilearn · GitHub
If you want to stare it, access it etc, you need to do a bit of tweaking.
I’m curious about your use case.
Best,
Bertrand
@bthirion Thank you!
If you want to stare it, access it etc, you need to do a bit of tweaking.
I was hoping there was a relatively easy way to access the whitening matrix W, like in SPM. But now I understand that it will be difficult. Thank you for pointing out where to look for the W matrix in the code.
I’m curious about your use case.
I want to replicate spm_peb_ppi.m function for deconvolution in Python. I use ridge regression instead of parametric empirical bayes (PEB) for parameter estimation. The only place I’m stuck is how can I get the W matrix using Nilearn and apply it to convolved cosine basis set Hxb (like here: spm12/spm_peb_ppi.m at 03ac9473cad402407b6472228377c0167fdc54b8 · spm/spm12 · GitHub).
Best,
Ruslan
I see. atm I have no better suggestion than implementing it manually by extracting the code you need from Nilearn.
Note that the whitening has more impact on the variance estimate than on the beta estimate, so if you’re interested in the beta only, you may want to skip the whitening to get a fast approximation ?
Best,
Bertrand
@bthirion Yes, I’ll probably skip this step.
One more theoretical question. Let’s assume that whitening has a noticeable effect on the beta estimate (just a thought experiment). If I have already pre-processed the BOLD signal prior to deconvolution using a model with a ‘filtered and whitened’ design matrix KWX, is it necessary to apply whitening to the deconvolution model (WHxb)? May I say that multiplying Hxb by W is not necessary since I am using ‘whitened residuals’ from the KWX model?
Best,
Ruslan
IIUC Hxb is meant to represent slow drifts. I find it weird to whiten it. Actually, filtering it should barely have an impact.
Disclaimer: I 'm not familiar with SPM, I may have misunderstood what is done here.
Best,
Bertrand
MANAGED BY INCF