Skip to content

EEG Client

The EEG class is the main entry point for EEG consciousness research. It wraps a LOC client to provide EEG-specific workflows.

Requires: pip install aime-loc[eeg]

EEG

EEG

AIME LOC EEG client for consciousness research.

Wraps a :class:~aime_loc.LOC client to provide EEG-specific workflows: loading, preprocessing, PSD extraction, and server-side True Coherence scoring.

Parameters:

Name Type Description Default
loc LOC

An authenticated :class:~aime_loc.LOC client instance.

required

Example::

from aime_loc import LOC
from aime_loc.eeg import EEG

loc = LOC(api_key="sk-aime-...")
eeg = EEG(loc)

recording = eeg.load("subject01.edf")
recording.preprocess()
epochs = recording.extract_epochs()
profile = eeg.score(epochs)

__init__(loc)

load(source, *, sfreq=None, ch_names=None, device=None, **kwargs)

Load an EEG recording from file or array.

Auto-detects format from file extension. Supports EEGLAB (.set), EDF (.edf), BrainVision (.vhdr), BDF (.bdf), EGI (.mff), CSV (.csv), and NumPy arrays.

Parameters:

Name Type Description Default
source str | Path | ndarray

File path or NumPy array of EEG data.

required
sfreq float | None

Sampling frequency (required for arrays and CSV).

None
ch_names list[str] | None

Channel names (optional, for arrays).

None
device str | None

Device preset name (e.g., "muse", "openbci_cyton"). Sets channel names and expected sampling rate.

None
**kwargs Any

Passed to the MNE reader.

{}

Returns:

Type Description
EEGRecording

class:EEGRecording ready for preprocessing.

Example::

recording = eeg.load("subject01.set")
recording = eeg.load("data.csv", device="muse", sfreq=256)
recording = eeg.load(numpy_array, sfreq=256)

from_mne(raw)

Create an EEGRecording from an existing MNE Raw object.

Use this after performing custom MNE preprocessing.

Parameters:

Name Type Description Default
raw Any

MNE Raw object.

required

Returns:

Type Description
EEGRecording

class:EEGRecording wrapping the Raw object.

Example::

recording = eeg.load("subject01.set")
mne_raw = recording.to_mne()
# ... custom MNE preprocessing ...
recording = eeg.from_mne(mne_raw)

score(epochs, *, subject=None, task=None)

Score EEG epochs for True Coherence.

Sends PSD data to the AIME API where Phi-Power band mapping, STB/ORD/BAL gate evaluation, and TC scoring are performed server-side (IP protected).

Parameters:

Name Type Description Default
epochs EpochSet

PSD epochs from :meth:EEGRecording.extract_epochs.

required
subject str | None

Override subject ID in metadata.

None
task str | None

Override task label in metadata.

None

Returns:

Type Description
EEGCognitiveProfile

class:EEGCognitiveProfile with TC scores and gate diagnostics.

score_session(session)

Score all recordings in a session (batch).

Parameters:

Name Type Description Default
session EEGSession

:class:EEGSession with added recordings.

required

Returns:

Type Description
SessionResults

class:SessionResults with per-recording profiles.

session()

Create a new multi-subject session container.

Returns:

Name Type Description
Empty EEGSession

class:EEGSession.

Usage

from aime_loc import LOC
from aime_loc.eeg import EEG

loc = LOC(api_key="sk-aime-...")
eeg = EEG(loc)

# Load → Preprocess → Extract → Score
recording = eeg.load("subject01.set")
recording.preprocess()
epochs = recording.extract_epochs(duration=2.0)
profile = eeg.score(epochs)

# Multi-subject session
session = eeg.session()
session.add(epochs, subject="sub-01", task="nback")
results = eeg.score_session(session)

Device Presets

DevicePreset dataclass

Configuration preset for a specific EEG device.

get_preset(device)

Get a device preset by name.

Parameters:

Name Type Description Default
device str

Device name (e.g., "muse", "openbci_cyton").

required

Returns:

Type Description
DevicePreset

DevicePreset with channel configuration.

Raises:

Type Description
ValueError

If device name is not recognized.