Skip to Content
IntegrationsJupyter Notebooks

Jupyter Notebooks

Four starter notebooks for EEG data analysis with Python.

#NotebookDescription
101_load_and_plot_sessionLoad CSV or stream live, plot all channels
202_detect_blinksEye-blink artifact detection (threshold-based)
303_bandpower_and_alphaBand powers via Welch’s method, alpha tracking
404_export_features_for_mlWindowed features → ML-ready CSV (scikit-learn)

Setup

cd notebooks pip install -r requirements.txt pieeg-server --mock & jupyter lab

Live 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 samples

Recording 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()