ruv-neural-decoder
Cognitive state classification and BCI decoding from neural topology embeddings.
Overview
ruv-neural-decoder classifies cognitive states from brain graph embeddings and
topology metrics. It provides multiple decoding strategies -- KNN classification
from labeled exemplars, threshold-based rule systems, temporal transition detection,
and clinical biomarker scoring -- plus an ensemble pipeline that combines all
strategies for robust real-time brain-computer interface (BCI) output.
Features
- KNN decoder (
knn_decoder): K-nearest neighbor classification using stored labeled embeddings fromruv-neural-memory; supports configurable k and distance metrics - Threshold decoder (
threshold_decoder): Rule-based classification from topology metric ranges (mincut value, modularity, efficiency, Fiedler value) with configurableTopologyThresholdbounds per cognitive state - Transition decoder (
transition_decoder): Detects cognitive state transitions from temporal topology dynamics; outputsStateTransitionevents matching knownTransitionPatterntemplates - Clinical scorer (
clinical):ClinicalScorerfor biomarker detection via deviation from healthy baseline distributions; flags abnormal topology patterns - Ensemble pipeline (
pipeline):DecoderPipelinecombining all decoder strategies with confidence-weighted voting; producesDecoderOutputwith classified state, confidence score, and contributing decoder votes
Usage
use ;
use ;
// Threshold-based decoding from topology metrics
let mut decoder = new;
decoder.add_threshold;
let state = decoder.decode;
// KNN-based decoding from embeddings
let mut knn = new; // k=5
knn.add_exemplar;
let predicted = knn.classify;
// Transition detection from temporal sequences
let mut transition_decoder = new;
if let Some = transition_decoder.check
// Full ensemble pipeline
let mut pipeline = new;
let output: DecoderOutput = pipeline.decode;
println!;
API Reference
| Module | Key Types |
|---|---|
knn_decoder |
KnnDecoder |
threshold_decoder |
ThresholdDecoder, TopologyThreshold |
transition_decoder |
TransitionDecoder, StateTransition, TransitionPattern |
clinical |
ClinicalScorer |
pipeline |
DecoderPipeline, DecoderOutput |
Feature Flags
| Feature | Default | Description |
|---|---|---|
std |
Yes | Standard library support |
wasm |
No | WASM-compatible decoding |
Integration
Depends on ruv-neural-core for CognitiveState, TopologyMetrics, and
NeuralEmbedding types. Consumes embeddings from ruv-neural-embed and
topology results from ruv-neural-mincut. The KNN decoder can query stored
exemplars from ruv-neural-memory.
License
MIT OR Apache-2.0