MonStim Plotter — Project Write-up
Published:
The Problem
Every paper our lab produces requires dozens of EMG trace figures: individual recording sweeps overlaid across stimulus intensities, annotated with peak markers, and styled to match journal requirements. Before this tool existed, each figure was produced by hand — researcher by researcher, with no shared standard.
The consequences were predictable:
- Inconsistency: figures for the same experiment differed in font size, lineweight, axis limits, and color between researchers
- Non-reproducibility: updating a figure for a revision (e.g., changing axis limits or color scheme) meant recreating it from scratch
- Time cost: generating the figure set for a typical manuscript section took half a day
My Approach
The key design insight was to treat figure generation as a data pipeline with a configuration layer. The data (which sweeps to include, how to normalize) and the presentation (colors, font sizes, layout) should be fully separated — so changing the appearance never requires touching the data logic.
I built MonStim Plotter as a companion to MonStim Analyzer: it reads the same session files, applies a researcher-defined configuration, and outputs a complete figure set.
Technical Implementation
Modular configuration system
Researchers define a YAML configuration file specifying:
- Which channels and sweep ranges to include
- Figure dimensions and DPI for target publication/journal
- Color palette (per-channel or condition-based)
- Font sizes, lineweights, axis label formats
- Annotation style for peak markers
The config file is version-controlled alongside the data, so the complete recipe for any figure in a paper is archived and reproducible.
Separation of data and rendering
The application has two fully independent module layers: a data layer (inherits MonStim Analyzer’s session object model) and a rendering layer (Matplotlib-based). Swapping a colormap or font size requires changing only the config — the data layer is untouched. This separation made iterating on figure styles fast and safe.
Batch processing
Given a session directory and a config file, MonStim Plotter processes every recording and exports figures in a single pass. Output formats — PNG (screen-optimized), SVG (vector, editable in Illustrator/Inkscape), and PDF (print-ready) — are generated simultaneously, so researchers have the right format for any downstream use.
Interactive preview
Before committing to a full batch run, researchers can preview any individual figure in the application window, adjust config parameters live, and confirm the output looks correct — preventing wasted batch jobs.
Results & Impact
- Figure generation for a typical manuscript: reduced from approximately 2–4 hours of manual work to under 10 minutes of automated batch processing
- Adopted as the lab standard for EMG trace figures, ensuring consistent styling and formatting
- Reproducibility: the config file for each figure is archived with the data, enabling exact recreation
