use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EegData {
pub samples: Vec<f64>,
pub time: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MotionData {
pub samples: Vec<f64>,
pub time: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DevData {
pub signal: f64,
pub contact_quality: Vec<f64>,
pub battery_percent: f64,
pub time: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MetricsData {
pub values: Vec<f64>,
pub time: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BandPowerData {
pub powers: Vec<f64>,
pub time: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MentalCommandData {
pub action: String,
pub power: f64,
pub time: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FacialExpressionData {
pub eye_action: String,
pub upper_action: String,
pub upper_power: f64,
pub lower_action: String,
pub lower_power: f64,
pub time: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SysData {
pub events: Vec<serde_json::Value>,
}
#[derive(Debug, Clone)]
pub struct DataLabels {
pub stream_name: String,
pub labels: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Record {
pub uuid: String,
#[serde(default)]
pub title: String,
#[serde(default, rename = "startDatetime")]
pub start_datetime: String,
#[serde(default, rename = "endDatetime")]
pub end_datetime: String,
#[serde(default)]
pub description: String,
#[serde(default, rename = "licenseId")]
pub license_id: String,
#[serde(default, rename = "applicationId")]
pub application_id: String,
#[serde(flatten)]
pub extra: HashMap<String, serde_json::Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Marker {
pub uuid: String,
#[serde(default, rename = "type")]
pub marker_type: String,
#[serde(default)]
pub value: serde_json::Value,
#[serde(default)]
pub label: String,
#[serde(default, rename = "startDatetime")]
pub start_datetime: String,
#[serde(flatten)]
pub extra: HashMap<String, serde_json::Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HeadsetInfo {
pub id: String,
pub status: String,
#[serde(default, rename = "connectedBy")]
pub connected_by: String,
#[serde(flatten)]
pub extra: HashMap<String, serde_json::Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProfileInfo {
pub name: String,
#[serde(default, rename = "readOnly")]
pub read_only: bool,
}
#[derive(Debug, Clone)]
pub enum CortexEvent {
Connected,
Authorized,
SessionCreated(String),
Disconnected,
Error(String),
Eeg(EegData),
Motion(MotionData),
Dev(DevData),
Metrics(MetricsData),
BandPower(BandPowerData),
MentalCommand(MentalCommandData),
FacialExpression(FacialExpressionData),
Sys(SysData),
DataLabels(DataLabels),
CortexInfo(serde_json::Value),
RecordCreated(Record),
RecordStopped(Record),
RecordExported(Vec<String>),
RecordPostProcessingDone(String),
QueryRecordsDone {
records: Vec<Record>,
count: u64,
},
DownloadRecordsDone(serde_json::Value),
MarkerInjected(Marker),
MarkerUpdated(Marker),
ProfilesQueried(Vec<String>),
ProfileLoaded(bool),
ProfileSaved,
McActiveActions(serde_json::Value),
McSensitivity(serde_json::Value),
McBrainMap(serde_json::Value),
McTrainingThreshold(serde_json::Value),
HeadsetsQueried(Vec<HeadsetInfo>),
Warning { code: i64, message: serde_json::Value },
HeadsetClockSynced(serde_json::Value),
}
pub const EPOC_CHANNEL_NAMES: [&str; 14] = [
"AF3", "F7", "F3", "FC5", "T7", "P7", "O1",
"O2", "P8", "T8", "FC6", "F4", "F8", "AF4",
];
pub const INSIGHT_CHANNEL_NAMES: [&str; 5] = ["AF3", "AF4", "T7", "T8", "Pz"];
pub const METRIC_LABELS: [&str; 13] = [
"eng.isActive", "eng", "exc.isActive", "exc", "lex",
"str.isActive", "str", "rel.isActive", "rel",
"int.isActive", "int", "foc.isActive", "foc",
];