ncrf.NCRF

class ncrf.NCRF(lead_field, noise_covariance, n_iter=30, n_iterc=10, n_iterf=100)

Result container and object-based API for NCRF.

Parameters:
  • lead_field – Forward solution a.k.a. lead-field matrix, with sensor and source dimensions and an optional space dimension for free orientation.

  • noise_covariance – Noise covariance matrix in sensor space, typically estimated from empty-room recordings.

  • n_iter – Number of out iterations of the algorithm, by default set to 10.

  • n_iterc – Number of Champagne iterations within each outer iteration, by default set to 30.

  • n_iterf – Number of FASTA iterations within each outer iteration, by default set to 100.

h

The neuro-current response function. It is one NDVar when fitting a single predictor and a sequence of NDVars when fitting multiple predictors.

h_scaled

h with the original stimulus scaling restored.

explained_var

Fraction of total variance explained by the fitted NCRFs.

voxelwise_explained_variance

Source-wise contributions to explained variance.

Gamma

Individual source covariance matrices.

sigma_b

Data covariance estimates under the model.

theta

NCRF coefficients over the Gabor basis.

mu

Regularization parameter used for the fitted model.

residual

The fit error, i.e. the result of the eval_obj error function on the final fit.

tstart

TRF start time in seconds, one value per predictor.

tstep

Sample spacing in seconds.

tstop

TRF stop time in seconds, one value per predictor.

basis_std

Standard deviation of the Gaussian basis functions in seconds.

stim_baseline

Mean that was subtracted from stim.

stim_scaling

Scale by which stim was divided.

Notes

Usage:

  1. Use RegressionData.from_data() to construct a prepared dataset from MEG and stimulus segments.

  2. Initialize NCRF with the lead field and noise covariance.

  3. Call NCRF.fit() with the RegressionData instance to estimate the cortical TRFs.

  4. Access the cortical TRFs in the NCRF.h attribute.

Methods

compute_ES_metric(models, data)

Compute the estimation-stability metric across cross-validation folds.

compute_explained_variance(data)

Compute the global explained-variance score for a fitted model.

cv_info()

Summarize stored cross-validation scores in a table.

cv_mu([criterion])

Retrieve best mu based on cross-validation

cvfunc(data, n_splits, tol, mu)

eval_l2(data)

Evaluate the unweighted L2 prediction error used in CV.

eval_obj(data[, return_wl2])

Evaluate the current objective value on a dataset.

fit(data[, mu, do_crossvalidation, tol, ...])

Fit the NCRF model to prepared regression data.