Channel Features
Status
The channel-feature domain currently has both canonical and legacy surfaces.
Canonical (new code):
src/cogpy/core/preprocess/badchannel/channel_features.pysrc/cogpy/core/preprocess/badchannel/pipeline.pysrc/cogpy/core/preprocess/badchannel/spatial.pysrc/cogpy/core/preprocess/badchannel/badlabel.py
Legacy (compatibility only):
src/cogpy/core/preprocess/channel_feature_functions.py(deprecated)src/cogpy/core/preprocess/channel_feature.py(legacy)src/cogpy/core/preprocess/detect_bads.py(legacy)
Canonical stack
1) Raw per-channel features
badchannel/channel_features.py defines raw temporal features over arrays shaped like (..., time), e.g.:
relative_variancedeviationstandard_deviationamplitudetime_derivativehurst_exponentkurtosisnoise_to_signal(withsnralias)
For xarray workflows, use extract_channel_features_xr(...).
2) Sliding-window utilities
Canonical sliding logic is in src/cogpy/core/utils/sliding_core.py.
badchannel/channel_features.py uses:
running_reduce_xr(...)running_blockwise_xr(...)
badchannel/pipeline.py uses shared window index helpers:
window_onsets(...)window_centers_idx(...)
This avoids re-implementing rolling/window indexing in preprocess modules.
3) Spatial normalization and feature maps
badchannel/pipeline.py orchestrates per-window feature map construction:
compute_feature_maps_for_window(...)for normalized spatial featurescompute_raw_feature_maps_for_window(...)for raw mapscompute_features_sliding(...)for stacked(feature, AP, ML, time_win)output
Normalization primitives are in badchannel/spatial.py:
normalize_rationormalize_differencenormalize_robust_zneighborhood statistics from adjacency
4) Outlier labeling
badchannel/badlabel.py is the canonical DBSCAN outlier path:
dbscan_outliers(...)grouped_dbscan_outliers(...)
Notes on legacy modules
Legacy modules remain importable for compatibility, but should not be used for new implementations.
channel_feature_functions.pycontains deprecated duplicates and older helpers.channel_feature.py/detect_bads.pyretain older orchestration patterns and APIs.
When migrating code:
Move raw feature logic to
badchannel/channel_features.py.Keep spatial normalization in
badchannel/spatial.py+badchannel/pipeline.py.Use
sliding_core.pyfor all rolling/window primitives.