109 lines
2.9 KiB
Rust
109 lines
2.9 KiB
Rust
//! # RustyNeuro - MEG/EEG Analysis Platform
|
|
//!
|
|
//! A GPU-accelerated neuroimaging analysis platform inspired by Brainstorm,
|
|
//! built natively in Rust for the RustyTorch ecosystem.
|
|
//!
|
|
//! ## Features
|
|
//!
|
|
//! - **File I/O**: Support for EDF, BDF, FIF, CTF, BrainVision, BIDS, NWB formats
|
|
//! - **Signal Processing**: Filtering, artifact removal (SSP, ICA), epoching
|
|
//! - **Forward Modeling**: Spherical head models, BEM integration
|
|
//! - **Inverse Solutions**: MNE, dSPM, sLORETA, LCMV beamformer
|
|
//! - **Connectivity**: Coherence, PLV, wPLI, Granger causality, PAC
|
|
//! - **Statistics**: Cluster-based permutation tests, parametric tests
|
|
//!
|
|
//! ## Quick Start
|
|
//!
|
|
//! ```rust,ignore
|
|
//! use rtx_neuro::{NeuroData, Recording};
|
|
//! use rtx_neuro_io::edf::EdfReader;
|
|
//!
|
|
//! // Load an EDF file
|
|
//! let recording = EdfReader::open("data.edf")?;
|
|
//!
|
|
//! // Apply bandpass filter (1-40 Hz)
|
|
//! let filtered = recording.filter(1.0, 40.0)?;
|
|
//!
|
|
//! // Create epochs around events
|
|
//! let epochs = filtered.create_epochs(&events, -0.2, 0.5)?;
|
|
//!
|
|
//! // Compute average
|
|
//! let evoked = epochs.average()?;
|
|
//! ```
|
|
|
|
#![warn(missing_docs)]
|
|
|
|
pub mod channel;
|
|
pub mod data;
|
|
pub mod epoch;
|
|
pub mod event;
|
|
pub mod montage;
|
|
pub mod protocol;
|
|
pub mod recording;
|
|
|
|
// Re-export core types
|
|
pub use channel::{Channel, ChannelInfo, ChannelType};
|
|
pub use data::NeuroData;
|
|
pub use epoch::{Epochs, EpochsConfig, Evoked};
|
|
pub use event::{Annotation, Annotations, Event, EventId, Events};
|
|
pub use montage::{Montage, MontageType};
|
|
pub use protocol::{Protocol, Subject};
|
|
pub use recording::{Recording, RecordingInfo};
|
|
|
|
// Re-export sub-crates
|
|
pub use rtx_neuro_io as io;
|
|
pub use rtx_neuro_signal as signal;
|
|
|
|
/// Errors specific to neuroimaging operations
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum NeuroError {
|
|
/// Error reading or writing data files
|
|
#[error("I/O error: {0}")]
|
|
Io(#[from] std::io::Error),
|
|
|
|
/// Invalid data format or structure
|
|
#[error("Invalid data format: {0}")]
|
|
InvalidFormat(String),
|
|
|
|
/// Channel-related errors
|
|
#[error("Channel error: {0}")]
|
|
Channel(String),
|
|
|
|
/// Event-related errors
|
|
#[error("Event error: {0}")]
|
|
Event(String),
|
|
|
|
/// Processing errors
|
|
#[error("Processing error: {0}")]
|
|
Processing(String),
|
|
|
|
/// Dimension mismatch
|
|
#[error("Dimension mismatch: expected {expected}, got {got}")]
|
|
DimensionMismatch {
|
|
/// Expected dimension
|
|
expected: String,
|
|
/// Actual dimension
|
|
got: String,
|
|
},
|
|
|
|
/// Missing required data
|
|
#[error("Missing required data: {0}")]
|
|
MissingData(String),
|
|
|
|
/// Invalid parameter value
|
|
#[error("Invalid parameter: {0}")]
|
|
InvalidParameter(String),
|
|
}
|
|
|
|
/// Result type for neuroimaging operations
|
|
pub type NeuroResult<T> = Result<T, NeuroError>;
|
|
|
|
/// Sampling frequency in Hz
|
|
pub type SampleRate = f64;
|
|
|
|
/// Time in seconds
|
|
pub type TimeSeconds = f64;
|
|
|
|
/// Sample index (0-based)
|
|
pub type SampleIndex = usize;
|