Jupyter Notebooks
Four starter notebooks for EEG data analysis with Python.
| # | Notebook | Description |
|---|---|---|
| 1 | 01_load_and_plot_session | Load CSV or stream live, plot all channels |
| 2 | 02_detect_blinks | Eye-blink artifact detection (threshold-based) |
| 3 | 03_bandpower_and_alpha | Band powers via Welch’s method, alpha tracking |
| 4 | 04_export_features_for_ml | Windowed features → ML-ready CSV (scikit-learn) |
Setup
cd notebooks
pip install -r requirements.txt
pieeg-server --mock &
jupyter labLive Streaming Example
import asyncio, json, websockets
async def stream_samples(n=1000):
samples = []
async with websockets.connect("ws://raspberrypi.local:1616") as ws:
async for msg in ws:
frame = json.loads(msg)
samples.append(frame["channels"])
if len(samples) >= n:
break
return samplesRecording Analysis
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("../recordings/pieeg_20260401_143136.csv")
fig, axes = plt.subplots(4, 4, figsize=(16, 12), sharex=True)
for i, ax in enumerate(axes.flat):
ax.plot(df.iloc[:, i + 1], linewidth=0.3)
ax.set_ylabel(f"Ch {i}")
plt.tight_layout()
plt.show()