nirspipe.pipeline.glm_censored#
GLM fits that leave BAD_ frames out of the estimate.
The design is built on the full time axis (HRF convolution and drift basis see continuous
time), the AR filter is estimated from lag windows lying wholly in kept time, both sides are
whitened as continuous series, and only then are the BAD_ rows dropped from the fit.
Module Contents#
Functions#
Per frame, whether it lies outside every |
|
The fixed AR order a noise model names: ols 0, ar1 1, arN N, auto 4x the rate. |
|
AR coefficients of a residual with gaps, from lag windows wholly in kept time. |
|
One channel: OLS on the kept rows, AR from the gap-aware residual, refit whitened. |
|
AR-IRLS under the same three rules: AR order and coefficients by BIC from lag windows in kept time, whitening on the full axis, the robust refit on the kept rows only. |
|
Every channel fitted on its kept rows, in mne-nirs’ results container. |
|
The design columns nilearn builds for one condition: itself, its derivative and dispersion, or its FIR delays. |
|
Conditions whose every column is exactly zero on every kept row. |
|
Per condition, how many events touch no |
|
What left the fit, by frames: the share per kind, the span count, the kept frames. |
|
Data#
API#
- nirspipe.pipeline.glm_censored.logger = 'get_logger(...)'#
- nirspipe.pipeline.glm_censored.MIN_FRAMES_PER_REGRESSOR = 3#
- nirspipe.pipeline.glm_censored.kept_frames(raw: mne.io.BaseRaw) numpy.ndarray#
Per frame, whether it lies outside every
BAD_span, of either kind.
- nirspipe.pipeline.glm_censored.ar_order(noise_model: str, sfreq: float) int#
The fixed AR order a noise model names: ols 0, ar1 1, arN N, auto 4x the rate.
- nirspipe.pipeline.glm_censored.gap_ar_coefficients(resid: numpy.ndarray, keep: numpy.ndarray, order: int, search: bool = False) numpy.ndarray#
AR coefficients of a residual with gaps, from lag windows wholly in kept time.
Least squares on forward and backward lag rows with a constant, each row dropped when its sample or any of its lags is censored. With
searchthe order is chosen by BIC over0..orderon the rows the largest order allows:\[\mathrm{BIC}(p) = n \log(\mathrm{RSS}_p / n) + p \log n\]- Parameters:
- Returns:
rhoin nilearn’s sign convention,y[t] - sum(rho[k] * y[t-k-1])white.- Return type:
ndarray,shape (p,)- Raises:
StageError -- When the kept stretches hold too few lag windows to fit the coefficients.
- nirspipe.pipeline.glm_censored.fit_channel(y: numpy.ndarray, design: numpy.ndarray, keep: numpy.ndarray, order: int)#
One channel: OLS on the kept rows, AR from the gap-aware residual, refit whitened.
The returned nilearn result is fitted on the whitened kept rows, so its theta, scale, df and contrasts are the censored fit’s; the data-space residual is taken by the caller on the full axis.
- nirspipe.pipeline.glm_censored.fit_channel_irls(y: numpy.ndarray, design: numpy.ndarray, keep: numpy.ndarray, pmax: int)#
AR-IRLS under the same three rules: AR order and coefficients by BIC from lag windows in kept time, whitening on the full axis, the robust refit on the kept rows only.
- nirspipe.pipeline.glm_censored.fit_censored(haemo: mne.io.BaseRaw, design_matrix: pandas.DataFrame, keep: numpy.ndarray, noise_model: str) Any#
Every channel fitted on its kept rows, in mne-nirs’ results container.
- nirspipe.pipeline.glm_censored.condition_columns(design_matrix: pandas.DataFrame, condition: str) list[str]#
The design columns nilearn builds for one condition: itself, its derivative and dispersion, or its FIR delays.
- nirspipe.pipeline.glm_censored.silent_conditions(design_matrix: pandas.DataFrame, conditions: list[str], keep: numpy.ndarray) list[str]#
Conditions whose every column is exactly zero on every kept row.
- nirspipe.pipeline.glm_censored.events_left(events: pandas.DataFrame, spans) dict[str, dict[str, int]]#
Per condition, how many events touch no
BAD_span, out of how many.tap at 10 s (5 s), 50 s (5 s); BAD_ over 48-60 s -> {"tap": {"left": 1, "total": 2}}
A zero-length event is left when its onset lies outside every span.
- nirspipe.pipeline.glm_censored.censor_summary(raw: mne.io.BaseRaw, keep: numpy.ndarray) dict[str, Any]#
What left the fit, by frames: the share per kind, the span count, the kept frames.
- nirspipe.pipeline.glm_censored.refuse_too_few_frames(keep: numpy.ndarray, n_regressors: int, name: str) None#