cedalion.mlutils.features
Feature extraction from epoched fNIRS data for use with scikit-learn pipelines.
Functions
|
Extract scalar features from epoched data for use in ML classifiers. |
- cedalion.mlutils.features.epoch_features(
- epochs: DataArray,
- feature_types: list[Literal['slope', 'mean', 'max', 'min', 'auc']],
- reltime_slices: dict[Literal['slope', 'mean', 'max', 'min', 'auc'], slice] | None = None,
Extract scalar features from epoched data for use in ML classifiers.
For each requested feature type, a scalar value is computed over the
"reltime"axis (optionally restricted to a sub-window). All non-epoch dimensions (channel, chromo, …) are then stacked into a flat"feature"dimension so the result is suitable as a 2-D feature matrix for scikit-learn estimators (rows = epochs, columns = features).- Parameters:
epochs – DataArray with at least an
"epoch"dimension and a"reltime"dimension.feature_types – One or more of
"slope","mean","max","min","auc". A string is also accepted as a shorthand for a single-element list.reltime_slices – Optional mapping from feature type to a
sliceof relative-time values used to restrict the window for that feature. Unspecified feature types use the fullreltimerange.
- Returns:
xr.DataArray with dimensions
(epoch, feature)wherefeatureis a multi-index stacking all non-epoch, non-reltime dimensions and thefeature_typelabel.- Raises:
ValueError – If an unrecognised feature type is requested.