brainvision 0.0.1

Rust library and TUI for Brain Products BrainVision RDA EEG streams over TCP/IP
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Example: read ~4 seconds and print min/max for first channel.
use brainvision::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
    env_logger::init();
    let host = std::env::var("BRAINVISION_HOST").unwrap_or_else(|_| "127.0.0.1".into());
    let mut dev = BrainVisionDevice::connect_default(&host)?;
    let h = dev.wait_for_start()?;
    let scans = dev.capture((h.sampling_rate_hz() as u32).max(1) * 4)?;
    let ch0: Vec<f64> = scans
        .iter()
        .filter_map(|s| s.eeg().first().copied())
        .collect();
    let min = ch0.iter().copied().fold(f64::INFINITY, f64::min);
    let max = ch0.iter().copied().fold(f64::NEG_INFINITY, f64::max);
    println!("CH1 min={:.3} µV max={:.3} µV", min, max);
    Ok(())
}