Crates.io | easy-rs |
lib.rs | easy-rs |
version | |
source | src |
created_at | 2025-01-30 23:01:20.436889 |
updated_at | 2025-02-03 01:51:08.823839 |
description | A Rust library for reading and processing EEG and accelerometer data from .easy files. |
homepage | |
repository | https://github.com/eugenehp/easy |
max_upload_size | |
id | 1536949 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
easy
is a Rust library designed for reading and processing EEG and accelerometer data stored in .easy
and .easy.gz
files. It provides tools for extracting and parsing EEG signals, accelerometer data, timestamps, and event markers, making it suitable for processing neuroscience data in Rust.
.easy
files..easy
and .easy.gz
file formats..info
files, including electrode names, number of channels, and recording start time.To add the easy-rs
library to your project, include it as a dependency in your Cargo.toml
:
[dependencies]
easy-rs = "0.0.4"
Alternatively, you can clone the repository directly and build from source:
git clone https://github.com/eugenehp/easy.git
cd easy
cargo build
Here’s a basic example of how to use the EasyReader
struct to load and process an .easy
file:
use anyhow::Result;
use easy_rs::{easy_reader::EasyReader, info::EEGData};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let filename = "data/Example01.info";
let data = EEGData::parse_file(filename)?;
println!("{data:#?}");
let filename = "data/Example01.easy";
// let filename = "data/Example01.easy.gz";
let mut reader = EasyReader::new(filename, 1.0, false)?; // 1.0 scale
// Then read the easy data, all at once
// reader.parse_data()?;
// reader.print_summary();
// println!("{reader:#?}");
// a streaming example
reader.stream(Some(10000), |eeg_chunk, acc_chunk, markers_chunk| {
// Process the chunk, for example, you could print the first few samples or store them
println!("Processing chunk of size: {}", eeg_chunk.len());
println!("First EEG sample: {:?}", eeg_chunk.first());
println!("First Acc sample: {:?}", acc_chunk.first());
println!("First Marker: {:?}", markers_chunk.first());
})?;
Ok(())
}
Once the file is loaded, you can access the processed data like this:
let eeg_data = reader.np_eeg.as_ref().unwrap();
let accelerometer_data = reader.np_acc.as_ref().unwrap();
let markers = reader.np_markers.as_ref().unwrap();
// Example: Print the first 5 EEG samples
println!("First 5 EEG samples: {:?}", eeg_data.slice(s![..5, ..]));
EasyReader::new(filepath: &str, verbose: bool)
: Initializes the reader for a given .easy
file.EasyReader::get_info()
: Reads metadata from the .info
file if available.EasyReader::parse_data()
: Reads and processes the EEG and accelerometer data from the .easy
file.EasyReader::strestream(&mut self, chunk_size: Option<usize>, mut process_chunk: FnMut(Vec<Vec<Float>>, Vec<Vec<Float>>, Vec<Float>))
: Streams the EEG and accelerometer data from the .easy
file.EasyReader::print_summary()
: Prints a summary of the loaded data, including EEG channels, start time, and a preview of the data..easy
file.If you'd like to contribute to the project, feel free to open an issue or submit a pull request. Here are a few guidelines:
cargo test
.This project is licensed under the MIT License - see the LICENSE file for details.
For any questions or feedback, feel free to open an issue on the GitHub repository.
Inspired by NEPy
2025, Eugene Hauptmann