bids_eeg/lib.rs
1#![deny(unsafe_code)]
2//! EEG (Electroencephalography) support for BIDS datasets.
3//!
4//! This crate provides typed access to all EEG-specific BIDS files and metadata,
5//! corresponding to the [BIDS-EEG specification](https://bids-specification.readthedocs.io/en/stable/modality-specific-files/electroencephalography.html).
6//!
7//! # Components
8//!
9//! - [`EegLayout`] — High-level interface for querying EEG files, channels,
10//! electrodes, events, metadata, coordinate systems, and physio data from
11//! a `BidsLayout`.
12//! - [`Channel`] / [`ChannelType`] — Typed representation of `_channels.tsv`
13//! entries with support for all BIDS channel types (EEG, EOG, ECG, EMG,
14//! TRIG, MISC, MEGMAG, MEGGRAD, ECOG, SEEG, DBS, etc.).
15//! - [`Electrode`] — Electrode positions from `_electrodes.tsv` with optional
16//! 3D coordinates, material, and impedance.
17//! - [`EegEvent`] — Events from `_events.tsv` with onset, duration, trial type,
18//! value, sample number, and response time.
19//! - [`EegMetadata`] — Typed EEG JSON sidecar metadata including sampling
20//! frequency, channel counts, placement scheme, reference, power line
21//! frequency, recording duration, and hardware/software filter descriptions.
22//! - [`CoordinateSystem`] — Coordinate system information from `_coordsystem.json`.
23//! - [`EdfHeader`] — Minimal EDF/BDF header parser for extracting channel count,
24//! sampling rates, channel labels, and recording duration directly from
25//! EEG data files.
26//! - [`EegData`] / [`ReadOptions`] — Read actual signal data from EDF, BDF, and
27//! BrainVision files, with support for channel inclusion/exclusion, time-range
28//! slicing, stim channel detection, and unit conversion. Use [`read_eeg_data`]
29//! for automatic format detection, or [`read_edf`] / [`read_brainvision`] directly.
30//! - [`Annotation`] — Time-stamped annotation parsed from EDF+ TAL channels,
31//! BDF status channels, or BrainVision `.vmrk` marker files.
32//!
33//! # Example
34//!
35//! ```no_run
36//! # use bids_layout::BidsLayout;
37//! use bids_eeg::EegLayout;
38//!
39//! # let layout = BidsLayout::new("/path").unwrap();
40//! let eeg = EegLayout::new(&layout);
41//! let summary = eeg.summary().unwrap();
42//! println!("{}", summary);
43//!
44//! for f in &eeg.get_eeg_files().unwrap() {
45//! if let Some(channels) = eeg.get_channels(f).unwrap() {
46//! println!("{}: {} channels", f.filename, channels.len());
47//! }
48//! }
49//! ```
50
51pub mod channels;
52pub mod coordsystem;
53pub mod csp;
54pub mod data;
55pub mod eeg_layout;
56pub mod electrodes;
57pub mod events;
58pub mod harmonize;
59pub mod metadata;
60pub mod pipeline;
61
62pub use channels::{Channel, ChannelType, read_channels_tsv};
63pub use coordsystem::CoordinateSystem;
64pub use csp::CSP;
65pub use data::{
66 Annotation, EegData, ReadOptions, read_brainvision, read_brainvision_markers, read_edf,
67 read_eeg_data,
68};
69pub use eeg_layout::{EdfHeader, EegDatasetSummary, EegLayout, PhysioData};
70pub use electrodes::{Electrode, read_electrodes_tsv};
71pub use events::{EegEvent, read_events_tsv};
72pub use harmonize::{ChannelStrategy, HarmonizationPlan, apply_harmonization, plan_harmonization};
73pub use metadata::EegMetadata;
74pub use pipeline::{Pipeline as EegPipeline, PipelineResult};