Loading EEG Data¶
AIME LOC supports all major EEG file formats via the MNE-Python backend, plus raw NumPy arrays and CSV files from consumer devices.
Supported Formats¶
| Format | Extension | Devices / Systems | MNE Reader |
|---|---|---|---|
| EEGLAB | .set / .fdt |
Any (exported) | read_raw_eeglab() |
| EDF / EDF+ | .edf |
Clinical, Muse (export) | read_raw_edf() |
| BrainVision | .vhdr / .vmrk / .eeg |
BrainProducts | read_raw_brainvision() |
| BioSemi BDF | .bdf |
BioSemi ActiveTwo | read_raw_bdf() |
| EGI MFF | .mff |
EGI / Magstim | read_raw_egi() |
| CSV | .csv |
Consumer devices | numpy.loadtxt() |
| NumPy array | ndarray |
Any / custom | Direct construction |
Format is auto-detected from file extension.
Loading from Files¶
from aime_loc import LOC
from aime_loc.eeg import EEG
loc = LOC()
eeg = EEG(loc)
# Auto-detected format
recording = eeg.load("subject01.set") # EEGLAB
recording = eeg.load("subject01.edf") # EDF
recording = eeg.load("subject01.vhdr") # BrainVision
recording = eeg.load("subject01.bdf") # BDF
recording = eeg.load("subject01.mff") # EGI
# Path objects work too
from pathlib import Path
recording = eeg.load(Path("data") / "sub-01" / "eeg" / "nback.set")
Inspecting a Recording¶
print(recording)
# EEGRecording(eeglab, 64ch, 500Hz, 300.0s, raw)
print(f"Channels: {recording.n_channels}")
print(f"Sample rate: {recording.sfreq} Hz")
print(f"Duration: {recording.duration:.1f}s")
print(f"Channel names: {recording.channel_names[:5]}...")
Loading from NumPy Arrays¶
For custom pipelines or data from non-standard sources:
import numpy as np
# Shape: (n_channels, n_samples)
data = np.random.randn(32, 128000)
recording = eeg.load(data, sfreq=256)
Required parameter
sfreq is required when loading from NumPy arrays. The SDK cannot infer the sampling rate from raw data.
You can optionally provide channel names:
Loading from CSV¶
Consumer EEG devices often export CSV files:
# Basic CSV (channels as columns)
recording = eeg.load("session.csv", sfreq=256)
# With device preset (sets channel names + expected sample rate)
recording = eeg.load("meditation.csv", device="muse", sfreq=256)
The CSV loader automatically detects whether channels are rows or columns and transposes if needed.
Device Presets¶
Built-in presets for popular consumer EEG devices:
| Device | Preset Name | Channels | Default Sfreq |
|---|---|---|---|
| Muse 2 / Muse S | "muse" |
4 (TP9, AF7, AF8, TP10) | 256 Hz |
| OpenBCI Cyton | "openbci_cyton" |
8 | 250 Hz |
| Emotiv EPOC X | "emotiv_epoc" |
14 | 256 Hz |
| Neurosity Crown | "neurosity" |
8 | 256 Hz |
| g.tec Unicorn | "gtec_unicorn" |
8 | 250 Hz |
# Device preset auto-sets channel names and expected sample rate
recording = eeg.load("data.csv", device="muse")
# Override sample rate if needed
recording = eeg.load("data.csv", device="muse", sfreq=256)
See Consumer Devices for detailed per-device guides.
Working with MNE¶
The EEGRecording wraps an MNE Raw object. You can access it directly:
# Get the MNE Raw object
raw = recording.to_mne()
# Use any MNE function
print(raw.info)
raw.plot() # MNE interactive plot
raw.compute_psd().plot() # MNE PSD plot
# After custom MNE processing, return to AIME
recording = eeg.from_mne(raw)
Passing MNE Keyword Arguments¶
Extra keyword arguments are passed through to the MNE reader:
Next Steps¶
- Preprocessing — Filter, re-reference, artifact rejection
- Consumer Devices — Per-device setup guides