ncrf.ForwardModel

class ncrf.ForwardModel(lead_field, noise_covariance, source, sensor, space)

Forward model and noise covariance with derived whitened quantities.

The lead field and noise covariance are stored as supplied; the whitened quantities used by the solver are derived (and recomputed on unpickling) rather than stored. A single instance is shared read-only across cross-validation folds.

Whitening projects sensor space onto the rank leading eigenvectors of the noise covariance, so the whitened quantities have rank rather than n_sensors channels. For a full-rank covariance the two coincide; for a rank-deficient one (e.g. after ICA component removal, Maxwell filtering, or SSP projection) the directions without noise are dropped, as data cleaned the same way carries no signal there either. The rank is the number of eigenvalues above a small fraction of the largest, chosen to separate removed directions from measured noise (see _RANK_TOL in the source).

Parameters:
  • lead_field (numpy._typing._array_like.NDArray[numpy.float64]) – Forward solution as a 2-D array, shape (n_sensors, n_sources) or (n_sensors, n_sources * len(space)) for free orientation.

  • noise_covariance (numpy._typing._array_like.NDArray[numpy.float64]) – Sensor-space noise covariance, shape (n_sensors, n_sensors), with the channels in the order of sensor.

  • source (eelbrain._data_obj.SourceSpace | eelbrain._data_obj.VolumeSourceSpace) – Source dimension of the forward model.

  • sensor (eelbrain._data_obj.Sensor) – Sensor dimension of the forward model.

  • space (eelbrain._data_obj.Space | None) – Orientation dimension (None for fixed orientation).

Methods

source_block(i)

Column/row slice of source i's orientation components in stacked arrays.

Attributes

dc

Number of orientation components per source.

mne_initializer

MNE-style initializer for whitened_lead_field.

lead_field

noise_covariance

source

sensor

space

rank

Rank of noise_covariance, i.e. the number of whitened channels.

whitening_filter

the inverse square root of noise_covariance restricted to its rank leading eigenvectors.

whitened_lead_field

Whitened and spectrally normalized lead_field used by solvers, shape (rank, n_sources).

whitened_noise_covariance

the (rank, rank) identity.

lead_field_scaling

Spectral norm removed from the whitened lead field.