Skip to main content

DGLZ

EEG emotion recognition with CNN-Transformer encoders and three-stage hierarchical classifiers.

Overview

DGLZ is a Python toolkit for EEG-based emotion recognition. It combines convolutional neural network (CNN) feature extractors with Transformer encoders to model both local and global temporal patterns in EEG signals. A three-stage hierarchical classification pipeline progressively refines emotion predictions.

Key components:

  • Data processing -- EEG I/O, channel selection, band filtering, signal transforms, and index building.
  • Resampling -- Truncated-Gaussian and subject-state-aware resampling strategies for balanced training data.
  • Datasets -- PyTorch-style dataset classes for resampled, subject-state, normal-emotion, and depression-emotion data with configurable collation and splitting.
  • Models -- CNN blocks, Transformer blocks, token embeddings, and specialised encoder architectures for trial-level, subject-state, normal-emotion, and depression-emotion classification.
  • Training -- Loss functions, optimizers, schedulers, early stopping, checkpointing, and metric tracking.
  • Prediction -- Post-processing, prediction aggregation, three-stage inference pipeline, and submission formatting.
  • CLI -- A unified eemo command-line interface built on Typer.

Installation

Requires Python 3.13 or later.

# Clone the repository
git clone https://github.com/SuShuHeng/DGLZ.git
cd DGLZ

# Install in editable (development) mode
pip install -e .

# Or with all optional dependencies (test + packaging tools)
pip install -e ".[all]"

Updating

# Check and update from PyPI, fallback to GitHub Release (default)
eemo update

# Update from GitHub Release only (skip PyPI)
eemo update --dist-repo

# Install a specific version from GitHub Release
eemo update --dist-repo --tag v0.1.2

# Use a custom distribution repository
eemo update --dist-repo --dist-repo-url https://github.com/example/repo.git --tag v0.1.2

# Use a custom wheel filename pattern
eemo update --dist-repo --tag v0.1.2 --asset-pattern "dglz-*.whl"

# Preview without installing
eemo update --dry-run

CLI Usage

After installation the eemo command is available:

# Show available commands
eemo --help

# Prepare raw EEG data for processing
eemo prepare --help

# Resample datasets for balanced training
eemo resample --help

# Train a model
eemo train --help

# Run the three-stage hierarchical inference pipeline
eemo infer-three-stage --help

# Run predictions with a trained model
eemo pred --help

# Display the current version
eemo version

# Manage configuration files
eemo config --help

# Run experiment training sweeps
eemo exp-train --help

# Run experiment prediction sweeps
eemo exp-pred --help

# Manage model checkpoints
eemo ckpt --help

Project Structure

DGLZ/
├── pyproject.toml          # Package metadata and build configuration
├── README.md               # This file
├── .python-version         # Python version pin (3.13)
├── configs/                # Configuration files
├── docs/                   # Documentation
├── src/
│   └── eemoclas/           # Main package
│       ├── __init__.py
│       ├── __version__.py
│       ├── cli/            # Command-line interface
│       │   └── main.py     # Entry point (registers as `eemo`)
│       ├── data/           # EEG I/O, splitting, transforms
│       ├── datasets/       # PyTorch dataset classes
│       ├── model/          # CNN-Transformer architectures
│       ├── prediction/     # Inference and post-processing
│       ├── resampling/     # Data resampling strategies
│       ├── training/       # Training loop utilities
│       └── utils/          # Configuration, logging, metrics, paths
└── tests/                  # Test suite

Running Tests

pip install -e ".[test]"
pytest

License

Licensed under the Apache License 2.0.

Metadata

Release files for DGLZ 0.1.24.post10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for DGLZ 0.1.24.post10
File Size Uploaded Provenance Actions
dglz-0.1.24.post10.tar.gz 455.9 kB Without provenance Details for dglz-0.1.24.post10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for DGLZ 0.1.24.post10
File Interpreter ABI Platform Actions
dglz-0.1.24.post10-py3-none-any.whl Python 3 none any Details for dglz-0.1.24.post10-py3-none-any.whl

Total release size: 879.3 kB

Release files / dglz-0.1.24.post10.tar.gz

Download URL dglz-0.1.24.post10.tar.gz
Size 455.9 kB
Tags Source
SHA-256 checksum
How to use checksums
10bbc97048fd623f7a2afd6a121402bb6aeb27eb26e639b20d35431b41e508fc
BLAKE2b-256 checksum
How to use checksums
2f333e1c04d876dc7880b642d6fa09b97704c374dfea81e7d804fb30e6c18c50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release files / dglz-0.1.24.post10-py3-none-any.whl

Download URL dglz-0.1.24.post10-py3-none-any.whl
Size 423.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07a3e150a02d1ebb08231ec7032a198f25ce68dc2ecaa74d1f839e1db58c8617
BLAKE2b-256 checksum
How to use checksums
9648915f067bd042666d6eecc1dc02266e3d80bad421e7c54c64c8c99f96bae7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Security for DGLZ 0.1.24.post10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page