Skip to main content

TimeSeries

Trait TimeSeries 

Source
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§

Source

fn n_channels(&self) -> usize

Number of channels.

Source

fn n_samples(&self) -> usize

Number of time samples (for channel 0; channels may differ for multi-rate).

Source

fn channel_names(&self) -> &[String]

Channel names / labels.

Source

fn sampling_rate(&self) -> f64

Primary sampling rate in Hz.

Source

fn channel_data(&self, index: usize) -> Option<&[f64]>

Get one channel’s data by index.

Source

fn duration(&self) -> f64

Total duration in seconds.

Provided Methods§

Source

fn channel_data_by_name(&self, name: &str) -> Option<&[f64]>

Get one channel’s data by name.

Source

fn times(&self) -> Vec<f64>

Time array for channel 0: [0, 1/sr, 2/sr, ...].

Source

fn channel_means(&self) -> Vec<f64>

Mean value per channel.

Source

fn channel_stds_with_means(&self, means: &[f64]) -> Vec<f64>

Standard deviation per channel (using pre-computed means).

Source

fn channel_stds(&self) -> Vec<f64>

Standard deviation per channel.

Source

fn z_score(&self) -> Vec<Vec<f64>>

Z-score normalize all channels (zero mean, unit variance). Returns a new Vec<Vec<f64>>.

Source

fn min_max_normalize(&self) -> Vec<Vec<f64>>

Min-max normalize all channels to [0, 1].

Source

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.

Source

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.

Source

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>.

Source

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).

Source

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).

Source

fn shape(&self) -> (usize, usize)

Shape as (n_channels, n_samples) — matches tensor dimension conventions.

Source

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)).

Source

fn band_power(&self) -> Vec<f64>

Band power per channel — average power in the signal.

Returns one value per channel: mean(x²).

Source

fn rms(&self) -> Vec<f64>

RMS (root-mean-square) per channel.

Source

fn peak_to_peak(&self) -> Vec<f64>

Peak-to-peak amplitude per channel: max - min.

Source

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.).

Implementors§