nstat.TrialConfig

class nstat.TrialConfig(covMask=None, sampleRate=None, history=None, ensCovHist=None, ensCovMask=None, covLag=None, name='')[source]

Bases: object

Description of a single GLM fit configuration.

A TrialConfig specifies which covariates, history, ensemble history, and sample rate to apply to a Trial before fitting. Multiple TrialConfig objects are collected in a ConfigCollection to run a batch of nested-model comparisons.

Parameters:
  • covMask (sequence of str or nested sequences, or None) – Covariate labels to include in the design matrix. 'all' includes every covariate.

  • sampleRate (float or None) – If provided, the trial is resampled to this rate before fitting.

  • history (History or array_like or None) – Self-history specification (History object or window-times).

  • ensCovHist (History or array_like or None) – Ensemble-history specification.

  • ensCovMask (array_like or None) – Binary mask selecting which neighbours contribute ensemble history.

  • covLag (array_like or None) – Covariate shift / lag specification.

  • name (str) – Human-readable name for this configuration.

__init__(covMask=None, sampleRate=None, history=None, ensCovHist=None, ensCovMask=None, covLag=None, name='')[source]

Construct a single GLM-fit configuration (Matlab TrialConfig).

Parameters:
  • covMask (sequence of str, nested sequences, or None, optional) – Names of the covariates (and channels) to include in the design matrix. None or [] (the empty list) is the “unset” sentinel and leaves the mask empty. Use the literal string 'all' to include every covariate in a CovariateCollection.

  • sampleRate (float or None, optional) – Target sample rate in Hz to resample the trial to before fitting. None leaves the trial’s existing rate unchanged.

  • history (History, array_like, or None, optional) – Self-history specification. May be a History object or a vector of window boundary times in seconds.

  • ensCovHist (History, array_like, or None, optional) – Ensemble-history specification.

  • ensCovMask (array_like or None, optional) – Binary mask selecting which neighbour neurons contribute ensemble-history terms.

  • covLag (array_like or None, optional) – Per-covariate time shifts (covariate lags) in seconds.

  • name (str, optional) – Human-readable name for this configuration (appears in FitResult plots). Default "".

Return type:

None

Notes

None arguments are normalised to the empty list [] to match the MATLAB sentinel convention recognised by _is_empty_config_value().

See also

ConfigCollection

Ordered collection used to compare configurations.

Trial.setConfig

Apply a single TrialConfig to a trial.

setConfig(trial)[source]

Apply this configuration to a Trial (in place).

Sets the covariate mask, history, ensemble history, sample rate, and covariate lag on the trial.

Parameters:

trial (Trial)

Return type:

None

getName()[source]

Return this configuration’s human-readable name.

Return type:

str

setName(name)[source]

Set this configuration’s human-readable name.

Parameters:

name (str)

Return type:

None

toStructure()[source]

Serialize to a plain dict (Matlab TrialConfig.toStructure).

Return type:

dict[str, Any]

static fromStructure(structure)[source]

Reconstruct from a dict produced by toStructure().

Note

Follows Matlab’s omission of ensCovMask.

Parameters:

structure (dict[str, Any])

Return type:

TrialConfig

property covariate_names: list[str]

Return the name of each covariate group in the mask.