EEG Quick Analysis Example¶
A minimal example: load a single EEG file, score it, and generate a figure.
The Script¶
"""Quick EEG consciousness analysis — 10 lines of code."""
from aime_loc import LOC
from aime_loc.eeg import EEG
loc = LOC()
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, subject="sub-01")
# Results
print(profile.summary())
profile.radar_chart(save="eeg_profile.png")
profile.to_json("eeg_profile.json")
Output¶
With a Muse Headset¶
from aime_loc import LOC
from aime_loc.eeg import EEG
loc = LOC()
eeg = EEG(loc)
# Load Muse CSV export
recording = eeg.load("muse_meditation.csv", device="muse")
recording.preprocess(bandpass=(1.0, 40.0), notch=60.0)
epochs = recording.extract_epochs(duration=2.0)
profile = eeg.score(epochs, task="meditation")
print(f"Meditation TC: {profile.tc_score:.1f}%")
print(f"Best function: {profile.best_function}")
profile.radar_chart()
With Visualization¶
from aime_loc import LOC
from aime_loc.eeg import EEG
from aime_loc.eeg.viz import psd_plot, timeseries_plot, cognitive_radar
loc = LOC()
eeg = EEG(loc)
recording = eeg.load("subject01.edf")
recording.preprocess()
epochs = recording.extract_epochs()
profile = eeg.score(epochs)
# Generate all figures
psd_plot(epochs, show=False, save="fig1_psd.png")
timeseries_plot(epochs, profile, show=False, save="fig2_timeseries.png")
cognitive_radar(profile, show=False, save="fig3_radar.png", journal="nature")
# Export data
profile.to_csv("scores.csv")
profile.to_json("profile.json")
print(profile.to_latex())