A Python wrapper for EEGPlot.jl
Project description
🧠 pyEEGPlot
Bring the power of Julia's EEGPlot.jl to your Python workflow.
A Python wrapper for the Julia package EEGPlot.jl, designed to bring EEGPlot's visualization capabilities to Python while preserving the original function syntax and terminology as closely as possible.
Note: the first plot may take longer to appear because Julia compiles the required functions on first use. Subsequent plots are generated much faster.
⚙️ Features
- Python interface to EEGPlot.jl: Use the Julia plotting engine directly from Python.
- Static and Interactive Plots: Support both
CairoMakie(static) andGLMakie(interactive) backends. - Multiple Datasets: Plot EEG/ERP data with overlays and additional panels for artifacts or components.
- Event Markers: Visualize triggers and events as lines or blocks.
- Time Constant Consistency: Maintains a constant pixel-per-second scale regardless of sampling rate.
- Interactive Controls: Deep inspection of data via keyboard and mouse shortcuts (in interactive mode).
- GUI Support: Includes a desktop GUI to initialize the chosen backend, generate demo plot, and load EEG files for visualization.
📦 Installation
1. Install Julia
Before using pyEEGPlot, make sure that Julia is installed on your system and that the julia executable is available from your terminal or command prompt.
2. Install pyEEGPlot
You can install pyEEGPlot directly from PyPi:
pip install pyEEGPlot
Alternatively, you can install it from source:
git clone https://github.com/lore1907/pyEEGPlot.git
cd pyEEGPlot
pip install .
Or install it directly from GitHub:
# Or install it directly from Github
pip install git+https://github.com/lore1907/pyEEGPlot.git
After installing the Python package, run:
import pyEEGPlot as pyep
pyep.configure()
This step:
- creates an isolated Julia environment for pyEEGPlot,
- installs the required Julia dependencies,
- downloads EEGPlot.jl from GitHub,
- precompiles the Julia packages.
Note: the first-time Julia setup may take significantly longer than a typical pure-Python package installation because it also installs and precompiles Julia dependencies.
Once configuration is complete, you can initialize a backend and create plots normally.
🖥 Backend Initialization
pyEEGPlot provides explicit backend initialization.
Two backends are supported:
GLMakiefor interactive plotsCairoMakiefor static plots and image export
Backend initialization is performed explicitly so that the plotting environment is configured in a predictable way before any figure is created. During this step, pyEEGPlot also performs a backend-specific warm-up procedure to reduce latency when generating the first actual plot.
In general:
- use
GLMakiewhen you want to inspect signals interactively, - use
CairoMakiewhen you want fast static rendering or save plots as images.
Using init_plotting()
Before creating plots, you can explicitly initialize the desired backend with:
import pyEEGPlot as pyep
pyep.init_plotting(backend="static", do_warmup=False)
#or
pyep.init_plotting(backend="dynamic", do_warmup=True)
The function allows you to:
- select the plotting backend explicitly,
- perform backend initialization before creating a figure,
- optionally run a warm-up step to reduce latency on the first real plot.
🧭 Two Ways to Use pyEEGPlot
pyEEGPlot can be used in two complementary ways:
1. Desktop GUI workflow
The GUI is intended for the most common visualization tasks and quick inspection of EEG files.
Use the GUI when you want to:
- initialize the selected backend,
- generate and display a demo plot,
- load EEG data from supported files (currently
.edfand.txt), - configure basic plotting options such as figure size and sampling rate,
- enable or disable event marker visualization, when available,
- save plots as
.pngwhen using the static backend.
2. Python API workflow
The Python API is intended for advanced and fully customizable use.
Use the Python API when you want to:
- work directly in scripts or notebooks,
- integrate plotting into an existing EEG analysis pipeline,
- use advanced keyword arguments from EEGPlot.jl,
- plot overlays, projections, lower panels, or auxiliary signals,
- combine pyEEGPlot with NumPy, SciPy, scikit-learn, MNE, or custom preprocessing steps.
In general, the GUI covers common usage, while the Python API provides the full flexibility of the wrapper.
🪟 Desktop GUI
To launch the GUI, run:
python -m pyEEGPlot.eeg_gui
Note: GUI startup and backend initialization may take some time on first use, especially when Julia compilation is required.
GUI limitations
The GUI is currently designed for common use cases and basic file visualization.
Some advanced EEGPlot.jl features are not implemented in the GUI yet, including for example:
- overlays and projections,
- additional lower panels (
Y,Y_size), - advanced combinations of keyword arguments.
For these cases, use the Python API directly.
Supported File Formats
The GUI currently supports loading:
.edffiles,.txtfiles.
When loading data from supported files, pyEEGPlot extracts the signal matrix and, when possible, any event-related information needed for event marker visualization.
Depending on the file content and available metadata, some plotting options may or may not be enabled.
Event Visualization
When event or trigger information is available, pyEEGPlot can display temporal markers on the EEG timeline.
These markers can be enabled or disabled from the GUI. At the moment, event durations are not represented. Events are currently rendered as fixed-width onset markers rather than variable-duration intervals.
Event visualization is especially useful for:
- stimulus onsets,
- experimental triggers,
- time-locked inspection of EEG activity.
🚀 Quick Start with Python API
The following examples mirror the EEGPlot.jl Quick Start and illustrate common usage patterns in Python.
Static Plot
Static plots are generated with the CairoMakie static backend. This backend is suitable for fast, non-interactive visualization and for exporting images of the signal. Here are two quick examples:
import numpy as np
import pyEEGPlot as pyep
# One-time setup on a new machine
# pyep.configure()
pyep.init_plotting(backend="static", do_warmup=False)
X = np.random.randn(512, 4)
sr = 128
labels = ["Fp1", "Fp2", "C3", "C4"]
fig = pyep.eegplot(X, sr, labels, fig_size=(800, 400))
Here is a second example using Julia-side data loading:
import numpy as np
from pyEEGPlot import eegplot
from julia import Eegle, CairoMakie
# Activate static backend
CairoMakie.activate_()
# Read example EEG data using Eegle.jl
X = Eegle.readASCII(Eegle.EXAMPLE_Normative_1)
sr = 128
sensors = Eegle.readSensors(Eegle.EXAMPLE_Normative_1_sensors)
# Plot EEG
eegplot(X, sr, sensors, fig_size=(814, 450))
In this example:
Xcontains the EEG data matrix,sris the sampling rate,sensorscontains sensor location information,fig_sizecontrols the output figure size in pixels.
Multiple Datasets (PCA Example)
pyEEGPlot also supports visualization of additional signals derived from the original EEG data. This is useful, for example, when displaying PCA component scores, projections, artifact-related signals, or other auxiliary time series alongside the main EEG plot.
from pyEEGPlot import eegplot
from julia import Eegle, CairoMakie, LinearAlgebra, Statistics
# Read data
X = Eegle.readASCII(Eegle.EXAMPLE_Normative_1)
sr = 128
sensors = Eegle.readSensors(Eegle.EXAMPLE_Normative_1_sensors)
# Basic PCA projection using Julia's LinearAlgebra
# (Note: In Python you could also use scikit-learn or numpy)
cov = Statistics.cov(X)
vals, vecs = LinearAlgebra.eigen(cov)
u = vecs[:, -1:] # Principal component axis
y = X @ u # Component scores (T x 1)
P = y @ u.T # Projection (T x N)
eegplot(X, sr, sensors,
fig_size=(814, 614),
overlay=P,
Y=y,
Y_size=0.1)
In this example:
overlay=Padds a channel-wise projection over the main EEG traces,Y=ydisplays an additional lower panel containing the component scores,Y_size=0.1sets the relative height of the additional panel.
This mechanism is particularly useful when comparing original signals with model-based reconstructions or low-dimensional summaries.
📖 Documentation
For more examples and detailed information on arguments, keyword arguments, and interactive controls, please refer to the official EEGPlot.jl documentation:
✍️ Authors
Original Julia package by Marco Congedo, Tomas Ros, and Generative AI.
Python wrapper by Lorenzo Bartoli l.bartoli@studenti.unina.it.
Project supervision by Lucrezia Di Marino lucrezia.dimarino2@unina.it.
📄 License
This project is released under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyeegplot-0.1.1.tar.gz.
File metadata
- Download URL: pyeegplot-0.1.1.tar.gz
- Upload date:
- Size: 19.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54b5a3542056ad64c5b1b9d18b4d1d7dd7ab578914c11564f030d92f2630d850
|
|
| MD5 |
8282bb61df8997c61e05de9bbc4732a5
|
|
| BLAKE2b-256 |
9925a10a2fcee96668118d2d450fe5495ec1125c20ef84fa302ca50dc00b3db2
|
Provenance
The following attestation bundles were made for pyeegplot-0.1.1.tar.gz:
Publisher:
publish.yml on lore1907/pyEEGPlot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyeegplot-0.1.1.tar.gz -
Subject digest:
54b5a3542056ad64c5b1b9d18b4d1d7dd7ab578914c11564f030d92f2630d850 - Sigstore transparency entry: 1359351926
- Sigstore integration time:
-
Permalink:
lore1907/pyEEGPlot@52cdd7bd89f72545eb1f8528a5618e7c20cd663e -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/lore1907
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@52cdd7bd89f72545eb1f8528a5618e7c20cd663e -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyeegplot-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pyeegplot-0.1.1-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd471b803281982b84f2e6340f7bb68094d76f6837c3742268cafc89d755447d
|
|
| MD5 |
b0ca4d3130b1529cdf41d037b2d530d7
|
|
| BLAKE2b-256 |
f76e9a25e197262c734b63b338ad98dd04e8fb0d3f62026835e7e4145608ffe1
|
Provenance
The following attestation bundles were made for pyeegplot-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on lore1907/pyEEGPlot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyeegplot-0.1.1-py3-none-any.whl -
Subject digest:
bd471b803281982b84f2e6340f7bb68094d76f6837c3742268cafc89d755447d - Sigstore transparency entry: 1359351957
- Sigstore integration time:
-
Permalink:
lore1907/pyEEGPlot@52cdd7bd89f72545eb1f8528a5618e7c20cd663e -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/lore1907
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@52cdd7bd89f72545eb1f8528a5618e7c20cd663e -
Trigger Event:
release
-
Statement type: