pub trait TimeSeries {
Show 24 methods
// Required methods
fn n_channels(&self) -> usize;
fn n_samples(&self) -> usize;
fn channel_names(&self) -> &[String];
fn sampling_rate(&self) -> f64;
fn channel_data(&self, index: usize) -> Option<&[f64]>;
fn duration(&self) -> f64;
// Provided methods
fn channel_data_by_name(&self, name: &str) -> Option<&[f64]> { ... }
fn times(&self) -> Vec<f64> { ... }
fn channel_means(&self) -> Vec<f64> { ... }
fn channel_stds_with_means(&self, means: &[f64]) -> Vec<f64> { ... }
fn channel_stds(&self) -> Vec<f64> { ... }
fn z_score(&self) -> Vec<Vec<f64>> { ... }
fn min_max_normalize(&self) -> Vec<Vec<f64>> { ... }
fn window(&self, start_sec: f64, end_sec: f64) -> Vec<Vec<f64>> { ... }
fn epochs(&self, window_sec: f64) -> Vec<Vec<Vec<f64>>> { ... }
fn epochs_with_stride(
&self,
window_sec: f64,
stride_sec: f64,
) -> Vec<Vec<Vec<f64>>> { ... }
fn to_flat_vec(&self) -> Vec<f64> { ... }
fn to_column_major(&self) -> Vec<f64> { ... }
fn shape(&self) -> (usize, usize) { ... }
fn log_variance(&self) -> Vec<f64> { ... }
fn band_power(&self) -> Vec<f64> { ... }
fn rms(&self) -> Vec<f64> { ... }
fn peak_to_peak(&self) -> Vec<f64> { ... }
fn covariance_matrix(&self) -> Vec<f64> { ... }
}Expand description
Trait for read-only access to multichannel time-series data.
All electrophysiology data types (EegData, MegData, NirsData)
implement this trait, enabling modality-agnostic processing.
Required Methods§
Sourcefn n_channels(&self) -> usize
fn n_channels(&self) -> usize
Number of channels.
Sourcefn n_samples(&self) -> usize
fn n_samples(&self) -> usize
Number of time samples (for channel 0; channels may differ for multi-rate).
Sourcefn channel_names(&self) -> &[String]
fn channel_names(&self) -> &[String]
Channel names / labels.
Sourcefn sampling_rate(&self) -> f64
fn sampling_rate(&self) -> f64
Primary sampling rate in Hz.
Sourcefn channel_data(&self, index: usize) -> Option<&[f64]>
fn channel_data(&self, index: usize) -> Option<&[f64]>
Get one channel’s data by index.
Provided Methods§
Sourcefn channel_data_by_name(&self, name: &str) -> Option<&[f64]>
fn channel_data_by_name(&self, name: &str) -> Option<&[f64]>
Get one channel’s data by name.
Sourcefn channel_means(&self) -> Vec<f64>
fn channel_means(&self) -> Vec<f64>
Mean value per channel.
Sourcefn channel_stds_with_means(&self, means: &[f64]) -> Vec<f64>
fn channel_stds_with_means(&self, means: &[f64]) -> Vec<f64>
Standard deviation per channel (using pre-computed means).
Sourcefn channel_stds(&self) -> Vec<f64>
fn channel_stds(&self) -> Vec<f64>
Standard deviation per channel.
Sourcefn z_score(&self) -> Vec<Vec<f64>>
fn z_score(&self) -> Vec<Vec<f64>>
Z-score normalize all channels (zero mean, unit variance).
Returns a new Vec<Vec<f64>>.
Sourcefn min_max_normalize(&self) -> Vec<Vec<f64>>
fn min_max_normalize(&self) -> Vec<Vec<f64>>
Min-max normalize all channels to [0, 1].
Sourcefn window(&self, start_sec: f64, end_sec: f64) -> Vec<Vec<f64>>
fn window(&self, start_sec: f64, end_sec: f64) -> Vec<Vec<f64>>
Extract a time window as a channels × samples Vec<Vec<f64>>.
Useful for cutting epochs from continuous data for ML training.
start_sec and end_sec are in seconds.
Sourcefn epochs(&self, window_sec: f64) -> Vec<Vec<Vec<f64>>>
fn epochs(&self, window_sec: f64) -> Vec<Vec<Vec<f64>>>
Extract non-overlapping fixed-length epochs.
Returns a Vec of epochs, each epoch is channels × window_samples.
Drops the last partial epoch if it’s shorter than window_sec.
Sourcefn epochs_with_stride(
&self,
window_sec: f64,
stride_sec: f64,
) -> Vec<Vec<Vec<f64>>>
fn epochs_with_stride( &self, window_sec: f64, stride_sec: f64, ) -> Vec<Vec<Vec<f64>>>
Extract epochs with a given stride (allows overlap when stride < window).
Returns Vec<epoch> where each epoch is Vec<channel_data>.
Sourcefn to_flat_vec(&self) -> Vec<f64>
fn to_flat_vec(&self) -> Vec<f64>
Flatten channels × samples into a single contiguous Vec<f64> (row-major).
Layout: [ch0_s0, ch0_s1, ..., ch0_sN, ch1_s0, ..., chM_sN].
This is the format expected by most ML frameworks (batch × features).
Sourcefn to_column_major(&self) -> Vec<f64>
fn to_column_major(&self) -> Vec<f64>
Get data as a contiguous Vec<f64> in column-major order (samples × channels).
Layout: [ch0_s0, ch1_s0, ..., chM_s0, ch0_s1, ch1_s1, ..., chM_sN].
This matches the layout expected by many time-series models (T × C).
Sourcefn shape(&self) -> (usize, usize)
fn shape(&self) -> (usize, usize)
Shape as (n_channels, n_samples) — matches tensor dimension conventions.
Sourcefn log_variance(&self) -> Vec<f64>
fn log_variance(&self) -> Vec<f64>
Log-variance per channel — a simple but effective BCI feature.
Equivalent to MOABB’s LogVariance transformer.
Returns one value per channel: ln(var(channel_data)).
Sourcefn band_power(&self) -> Vec<f64>
fn band_power(&self) -> Vec<f64>
Band power per channel — average power in the signal.
Returns one value per channel: mean(x²).
Sourcefn peak_to_peak(&self) -> Vec<f64>
fn peak_to_peak(&self) -> Vec<f64>
Peak-to-peak amplitude per channel: max - min.
Sourcefn covariance_matrix(&self) -> Vec<f64>
fn covariance_matrix(&self) -> Vec<f64>
Compute the covariance matrix (channels × channels).
Returns a flat Vec in row-major order (length = n_channels²). Used for Riemannian geometry BCI methods (CSP, MDM, etc.).