nirspipe.pipeline.glm_worsley#
Worsley’s bias-corrected AR noise model for the GLM (--noise-model worsley).
The AR coefficients come from the OLS residual’s autocovariances after removing the bias the
fit puts into them, as fmristat’s fmrilm.m does (Worsley et al., 2002): the residual is
the data with the design projected out, which leaves its autocovariances short of the
noise’s, most of all at the low frequencies the drift terms absorb. Each lag’s sum of
products has expectation \(\sum_k M_{jk} a_k\) in the noise autocovariances
\(a_k\), with
where \(R\) forms the residual from the design and \(D_j\) is the symmetric lag-j
shift (\(D_0\) the identity), so \(a = M^{-1} c\) is solved for and its AR
coefficients found by Levinson-Durbin. A channel whose corrected autocovariances are not
positive definite at the order asked for is fitted as auto would fit it.
On a run with BAD_ spans the residual and the lag products cover kept frames only, and
\(R\) is the kept rows’ residual-forming matrix, zero on the censored ones, so the same
expectation holds.
Module Contents#
Functions#
|
|
fmristat’s |
|
|
|
Yule-Walker coefficients from autocovariances by Levinson-Durbin, None when not positive definite. |
|
One channel’s bias-corrected AR coefficients, None when they cannot be had at this order. |
|
Every channel fitted under the bias-corrected AR model, in mne-nirs’ results container. |
Data#
API#
- nirspipe.pipeline.glm_worsley.logger = 'get_logger(...)'#
- nirspipe.pipeline.glm_worsley.NOISE_PREFIX = 'worsley'#
- nirspipe.pipeline.glm_worsley.worsley_order(noise_model: str, sfreq: float) int#
worsley-> 4x the sampling rate, asauto;worsley5-> 5.
- nirspipe.pipeline.glm_worsley.bias_matrix(design: numpy.ndarray, keep: numpy.ndarray, order: int) numpy.ndarray#
fmristat’s
Mfor lags 0..order, from an orthonormal basis rather than the n x n matrices.tr(R D_j R D_k)withR = W - Q Q'(Wthe kept-frame mask,Qthe basis) expands totr(W D_j W D_k) - 2 tr(Q' D_j W D_k Q) + tr(A_j A_k),A_j = Q' D_j Q; the first term is nonzero only forj = k, where it counts the kept frames (lag 0) or twice the pairs of kept framesjapart.
- nirspipe.pipeline.glm_worsley.lag_products(resid: numpy.ndarray, keep: numpy.ndarray, order: int) numpy.ndarray#
sum_t r[t] r[t + j]for j = 0..order, over pairs of kept frames only.
- nirspipe.pipeline.glm_worsley.levinson(acov: numpy.ndarray, order: int) numpy.ndarray | None#
Yule-Walker coefficients from autocovariances by Levinson-Durbin, None when not positive definite.
rhois in nilearn’s sign convention,y[t] - sum(rho[k] * y[t-k-1])white:acov [1, 0.5, 0.25], order 2 -> [0.5, 0.0]
- nirspipe.pipeline.glm_worsley.worsley_rho(resid: numpy.ndarray, keep: numpy.ndarray, m: numpy.ndarray) numpy.ndarray | None#
One channel’s bias-corrected AR coefficients, None when they cannot be had at this order.
- nirspipe.pipeline.glm_worsley.fit_worsley(haemo: mne.io.BaseRaw, design_matrix: pandas.DataFrame, noise_model: str, keep: numpy.ndarray | None = None) tuple[Any, list[str]]#
Every channel fitted under the bias-corrected AR model, in mne-nirs’ results container.
Returns the results and the channels fitted as
autoinstead. Withoutkeepthe fit is nilearn’s AR model, asauto’s; with it, the censored fit ofnirspipe.pipeline.glm_censored.fit_channel(), whitened on the full axis and refitted on the kept rows.