MonStim Analyzer — Project Write-up

Published:

MonStim Analyzer is a full-featured desktop application for visualization, curation, and statistical analysis of multi-channel H-reflex EMG recordings. Built from scratch in Python, it handles 100+ GB datasets and has reduced per-session analysis time by ~80% for several researchers in my lab.
~80%
Reduction in analysis time
1M+
Recordings processed
5+
Daily active users (lab)
100+ GB
Datasets handled
Python PyQt6 Signal Processing Matplotlib NumPy / SciPy Statistics Pandas

The Problem

Analyzing H-reflex EMG data — a standard electrophysiology assay in spinal neuroscience — was entirely manual. Each recording session produced dozens of binary data files, and the existing workflow required:

  1. Loading each file individually in MATLAB
  2. Manually scrolling waveforms to identify signal peaks by eye
  3. Copying values into Excel, session by session
  4. Running statistics in a separate tool

For a typical experiment, this process consumed 2+ hours per session and introduced substantial human error: peak identification was subjective, there was no audit trail, and re-analyzing data for a revision meant starting over from scratch.


My Approach

Rather than incrementally improving the MATLAB scripts, I identified that the core problems were architectural: the workflow had no single source of truth for raw data, no reproducible record of analysis decisions, and no convenient way to visualize and inspect signals interactively. The right solution was a self-contained application that handled the full pipeline.

I chose Python for the implementation (NumPy/SciPy for numerical work, Matplotlib for visualization) and PyQt6 as the GUI framework — giving researchers an interface that looks and behaves like a native desktop application with no coding knowledge required.


Technical Implementation

Memory-efficient data I/O

Experiments generate files that greatly exceed available RAM. The application uses lazy loading to overcome this limitation: it indexes session files on startup and loads recordings on demand, caching processed results in a structured hierarchy (Session → Channel → Recording Sweep) to minimize disk reads.

Signal processing pipeline

The core algorithms — designed for the specific characteristics of compound muscle action potentials — include:

  • Bandpass filtering: Butterworth filter with user-configurable frequency bounds to suppress motion artifact and high-frequency noise
  • Adaptive peak detection: finds the M-wave and H-wave peaks within physiologically constrained time windows after the stimulus; handles variable signal amplitudes across a recruitment curve
  • Latency and amplitude extraction: sub-millisecond precision using parabolic interpolation around the detected peak sample

Interactive visualization

The analysis canvas embeds a live Matplotlib figure in the Qt window. Researchers can scroll through sweeps, zoom in on individual waveforms, and manually override any automated peak call with a click — all decisions are written back to the session data object immediately.

Statistical reporting

After analysis, the application generates a session summary automatically: recruitment curves (M-wave and H-wave amplitude vs. stimulus intensity), max H-reflex ratio, and standard summary statistics. Reports export to CSV and a formatted PDF.

Reproducibility

Every analysis decision is stored in the session file alongside the raw data. Loading a session in the future produces exactly the same results — the analysis is fully reproducible and auditable.


Results & Impact

  • ~80% reduction in per-session curation/analysis time: from 2+ hours to under 25 minutes
  • 1,000,000+ recordings processed through the application across ongoing projects
  • Adopted by 5+ researchers in the lab as their primary EMG analysis tool, replacing the prior MATLAB workflow entirely
  • Zero critical bugs reported since the initial deployment; iterative feature additions have been released based on researcher feedback

AEWorthy/MonStim-Analyzer