Lightweight replay app for MUedit2 motor unit editing sessions. Useful for inspecting the editing work of students or colleagues in collaborative projects, or for reviewing decomposition edits from other groups when assessing a paper.
This software is functional and ready for use. We continue to actively maintain and update these tools in line with the advancements of our research projects, and we welcome any contributions to make them useful for the wider community.
- Replays MUedit2 edit steps on an interactive timeline
Prev/Nextnavigation with MUedit2-style undo-like state managementupdate_filtersteps replayed with the real filter-update algorithm against BIDS EMG, honouring theuse_peeloffandlock_spikesflags recorded in the edit log- Artifact markers (
add_artifact/delete_artifact) tracked per motor unit and subtracted during filter replay - Displays firing rate (instantaneous discharge rate) and the pulse train with discharge and artifact markers
- Web-based interface with a Python backend and JavaScript frontend
- Cross-platform launchers (macOS/Linux and Windows)
| Format | Extension | Description |
|---|---|---|
| Decomposition | .npz |
MUedit2-style decomposition output (pulse trains + discharge times) |
| Edit log | _edited.json |
MUedit2 edit-history sidecar (history, mu_uids, artifact_times) |
| BIDS EMG | .bdf, .edf |
Raw recording with a _channels.tsv sidecar (legacy _emg_channels.tsv also accepted), used to replay update_filter steps |
Recent MUedit2 versions save the decomposition under <bids_root>/derivatives/muedit/sub-XX/[ses-YY]/decomp/, while the raw EMG stays at <bids_root>/sub-XX/[ses-YY]/emg/. MUreplay reads both layouts (the older flat <bids_root>/sub-XX/decomp/ is still supported) and infers the BIDS dataset root automatically.
- Python 3.11+
- Conda (Anaconda or Miniconda)
numpyfor.npzloadingscipyandpyedflibforupdate_filterreplay against BIDS EMG
- Create and activate the conda environment:
conda env create -f environment.yml
conda activate MUreplay- Install MUreplay in editable mode:
pip install -e .- Launch the app from the repository root:
macOS / Linux:
./scripts/run_MUreplay.shWindows (PowerShell):
powershell -ExecutionPolicy Bypass -File .\scripts\run_MUreplay.ps1Or run manually (split terminals):
cd python && python server.py --host 0.0.0.0 --port 8000cd frontend && python -m http.server 8080Then open http://localhost:8080.
Windows first-time setup (if script execution is blocked):
Set-ExecutionPolicy -Scope CurrentUser RemoteSignedAfter installation, MUreplay exposes:
mureplay-server— starts the backend API server
With MUreplay running, open http://localhost:8080 in a browser.
python: command not found— activate the conda env before launching.- Port already in use — set
MUREPLAY_BACKEND_PORT/MUREPLAY_FRONTEND_PORTto free ports. - Browser does not open automatically — open
http://localhost:<MUREPLAY_FRONTEND_PORT>manually. update_filterreplay fails — check thatscipyandpyedflibare installed and the BIDS root path is set correctly.
- User guide: docs/user-guide.md
MUreplay expects MUedit2-style NPZ content. These keys are read:
- Required:
pulse_trains(orpulseTrains)discharge_times(ordistimes,dischargeTimes)
- Optional:
fsamp(orfs)grid_namesmu_grid_indexmu_uidsedit_history(orhistory) if present in NPZ
If mu_uids is missing, MUreplay generates ids from mu_grid_index.
MUreplay reads edit steps from a JSON sidecar with:
history: array of edit actions (update_filter,add_spikes,delete_spikes,delete_dr,remove_outliers,add_artifact,delete_artifact,flag_mu,duplicate_mu,remove_duplicates)mu_uids: optional MU id list overriding NPZ idsartifact_times: optional per-MU artifact sample positions
{
"history": [
{
"type": "update_filter",
"mu_uid": "g0_mu0",
"timestamp": "2026-04-16T14:32:10.000Z",
"view_start": 0,
"view_end": 40000,
"use_peeloff": true,
"lock_spikes": false,
"spikes_added": [3000],
"spikes_removed": [3200]
}
],
"mu_uids": ["g0_mu0"],
"artifact_times": [[12000, 18500]]
}- Preferred replay pair:
<entity>_decomp.npz<entity>_edited.json
- If the user selects
<entity>_edited.npz, MUreplay auto-tries to load:<entity>_decomp.npz<entity>_edited.json
These files are resolved from the folder of the selected file (e.g. derivatives/muedit/sub-XX/[ses-YY]/decomp/), and MUREPLAY_BIDS_ROOT (set in frontend/runtime-config.js) is used as a fallback BIDS root.
MUreplay is a companion to MUedit for high-density EMG decomposition; it replays the editing sessions produced by MUedit2.