ncrf.RegressionData¶
- class ncrf.RegressionData(meg, stim, design, samples=None, forward=None)¶
Dataset for NCRF fitting: M/EEG segments, their predictors, and the design.
Use
from_data()to derive the design, including its normalization, from the data itself.Warning
The
megandstimNDVars are referenced rather than copied, and the arrays are built from them when first accessed. Do not modify the NDVars in place while the dataset, or one derived from it, is in use: arrays built afterwards would reflect the change, but the normalization recorded on the design would not.- Parameters:
meg (list[eelbrain._data_obj.NDVar]) – M/EEG segments, each an NDVar with
sensorandtimedimensions. All segments share the sensor dimension and the time axis length and step.stim (list[collections.abc.Sequence[eelbrain._data_obj.NDVar]]) – Predictors, one list per segment with one NDVar per predictor variable. Each predictor may be 1-D over time or carry one feature dimension before time, and shares the time axis of its segment’s
meg.design (ncrf._trf_design.TRFDesign) – Design describing the predictors, the TRF lags and basis, and the normalization to apply to the covariates.
samples (numpy._typing._array_like.NDArray[numpy.int64] | None) – Indices of the time samples the dataset covers, into the time axis of
meg;Nonefor all samples.from_data()drops samples whose lag window extends beyond the stimulus, andtimeslice()selects cross-validation folds.forward (ncrf._forward.ForwardModel | None) – Forward model whose whitening filter is applied to the responses, or
Nonefor raw data. Set bywhiten(); whitened data thus carries the forward model it is fit with, and recording it letswhiten()distinguish a no-op (same filter) from an error (different filter).
Notes
The stored fields are the raw inputs. The arrays the solver consumes,
responsesandcovariates, are derived from them on demand according todesign, which fixes the TRF lags, the Gaussian basis the predictors are projected onto, and the centering and scaling of the covariates.
Methods
|
Construct a dataset from MEG and stimulus NDVars, deriving the design from them. |
|
Return a dataset whose covariates are centered and scaled. |
|
Return a new dataset restricted to a subset of this dataset's samples. |
|
Return a dataset whose responses are whitened with |
Attributes
Per-segment |
|
Per-segment |
|
Per-segment |
|
Covariate matrices for the solver, one per segment, each shaped |
|
Whether the responses are transformed by a whitening filter (see |
|
|
|
M/EEG arrays for the solver, one per segment, each shaped |
|
Sensor dimension shared by all MEG segments. |
|