# EMG Suite viewer A local viewer for stereo video, projected right-hand pose, 18-channel pre-processed EMG, right-hand contact labels, per-finger contact scores, pressure estimates, and raw camera IMU inspection. Trials and file locations come from the dataset metadata. All source Parquet files and MP4s are read-only; no video conversion or dataset edits are performed. There are no CDN requests or frontend build steps. Python dependencies are pinned in `requirements.txt`. Stored pressure values are **baseline-subtracted glove ADC counts predicted from EMG**. Independent validation of pressure-estimation accuracy is not available for this release. The plots show recovered activation derived from these predictions, not calibrated force in Newtons. The viewer supports exploration and inspection; no improvement in robot-training performance has been established or is claimed. ## Launch From the dataset root (the folder containing `data/` and `Visualize/`), use Python 3.12: ```bash python3.12 -m venv .venv .venv/bin/python -m pip install -r Visualize/requirements.txt .venv/bin/python Visualize/server.py --port 8023 ``` See [Quickstart in the dataset README](../README.md#quickstart) for setup details. Open [http://127.0.0.1:8023/](http://127.0.0.1:8023/). Stop the server with Ctrl+C. If that port is occupied, choose another port or use `--port 0` and open the address printed by the server. It always binds to `127.0.0.1`. The default dataset root is the parent of this folder; `--root /absolute/path/to/EMGSuite-v1` overrides it. The requirements install NumPy, pandas, PyArrow and headless OpenCV in a dedicated environment. Opening `index.html` directly as a file will not work: the Python API reads the Parquet files and supports MP4 byte-range requests. ## Appearance The viewer follows the Preload company website: white-and-black surfaces, Saira headings, Manrope body text, the original Preload mark and wordmark, rounded panels, pill controls, and dotted details. The EMG Suite title and Preload logo share the header, with the logo aligned right. The original Latin font files and logo images are embedded in the existing CSS/HTML so they load locally with no new server routes or external requests. Font licenses are included in `Visualize/licenses/`. Plot axes and traces use colors suited to light backgrounds; the contact/no-contact/unknown shading and all data transformations retain their existing meaning. ## Controls - Use the tinted dropdown to select a trial. The selector shows two-digit trial numbers (00–42), participant and duration; date, wearing session and trial identity remain in the inspector. All 43 trials are available without predefined training/validation/test assignments. A link such as `http://127.0.0.1:8023/#trial=10` selects a trial. - Play/pause, set 0.25–2× speed, drag the shared slider, click the trial timeline, step one frame, or jump ±1/±5 seconds. - Drag the full-width progress slider to seek, or use **Go** to jump to its selected position. Frame and Time entry fields have been removed; the current time and frame remain visible above the slider. - Space plays/pauses; Left/Right step frames; Shift+Left/Right jump one second; J/L jump five seconds; Home/End select first/last frame. Shortcuts are ignored while typing or interacting with form controls. - Use **Left eye / Right eye** above the single video panel. Right eye is the default; the selection persists across trials. Switching eyes preserves the current frame, playback speed and paused/playing state. The video height is capped at 420 pixels on desktop. - Toggle projected hand pose. The overlay uses the selected eye’s camera projection. Its checkbox sits beside the eye toggle in the video header. Joint support and recording details remain available in the inspector. - Pressure defaults to stacked, color-coded **History** plots inspired by [demo 3](https://preload.ai/tech-demo/#force-and-contact-labeling): thumb and index traces with current values. Choose 3/5/10 seconds of trailing history. Both fingers, Raw / Smoothed, and the full trial timeline share one fixed vertical range: zero to the maximum valid recovered activation across both fingers in the entire trial. This range is calculated when loading a trial and stays fixed during playback, seeking, smoothing changes and history-window changes. Empty/all-zero trials use 0–1. Unsupported intervals break the traces. Other fingers stay unavailable. **Raw / Smoothed** switches the pressure readouts, short histories and full trial timeline together. Raw is the default and means recovered activation without temporal smoothing; the hand diagram has been removed. The underlying data and API remain unchanged. - **Force estimates** heads the right panel; its plotted values are recovered activation, not calibrated force in Newtons. Below the activation plots, **Right-hand contact** shows the current label and a binary step chart: **1 = contact**, **0 = no contact**. Unknown labels (−1 or missing) leave gaps, with no line connecting across them. It shares the activation plots’ trailing 3/5/10-second window and shows the stored combined thumb/index label, independently of pressure-model validity and smoothing. Per-finger EMG probability scores remain available in the frame inspector. - The pressure histories and full-trial timeline shade the background with that same combined label: **green = contact**, **gray = no contact**, **amber = unknown**. The legend is above the timeline. Each label covers its frame's playback interval, including the final frame; shading is clipped to the displayed window and stays visible when pressure is unavailable. It is shared by both fingers and does not indicate which finger is touching. Time before the first frame has no shading. - The complete selected trial’s EMG loads before playback is enabled. Select a 2/5/10-second EMG window; playback, seeking and window changes read the same in-memory samples without further EMG requests. The panel shows the title, window selector, traces, current-frame cursor and CH 01–18 labels. Processing/status captions, numeric baseline/scale/time annotations and the hover readout are hidden. The underlying signal remains pre-processed µV; each channel remains centered and autoscaled. - Open **Frame & recording inspector** while paused for all 27 frame fields, acquisition timestamps, filtered EMG references, trial boundaries and the complete stereo calibration profile. The inspector also shows the selected exposure’s camera IMU capture batch: all ten raw six-channel samples, exact sample timestamps and offsets from the exposure in milliseconds. Recording details include nullable IMU vendor parameters and their unapplied/unverified status. During playback it asks you to pause rather than displaying stale frame details. ## Data mappings | Display | Dataset source and interpretation | | --- | --- | | Trial browser | `meta/trials.parquet`; paths and lengths from `meta/episodes/**/*.parquet` and templates in `meta/info.json`. | | Left/right video | Metadata-resolved `videos/observation.images.{left,right}/…/*.mp4`; one shared `frame_index` identifies a stereo exposure. | | Pose overlay | `hand_joints_camera_m` reshaped to 21×3 metres in the **left optical camera frame**, filtered by `hand_joint_valid`, finite coordinates and positive depth. Wrist 0 connects to five four-joint finger chains. | | Projection | Per-trial profile in `meta/calibrations.parquet`. OpenCV projects with each eye's exported-image K and all eight distortion coefficients. Right-eye points first undergo `R_left_to_right @ X_left + t_left_to_right_m`. The current exports are unrectified and unmirrored. A future rectified/mirrored profile produces an explicit error rather than an incorrect overlay. | | EMG | Trial's matching `sensors/emg/…/*.parquet`, column `microvolts_filtered`: 18 channels in µV. Trial filenames match the episode's data chunk and file indices. The full trial transfers once as compact numeric arrays. Connected line traces draw every visible source sample at its actual timestamp, without display downsampling; each channel is centered and autoscaled, with its numeric baseline and amplitude scale hidden. Invalid/nonfinite samples, run changes, source-index discontinuities and timestamp gaps break the lines. Unapproved segments appear amber. Quality counts and continuous segment boundaries accompany the full-trial response. Missing processed files raise an error without falling back to raw EMG. | | Camera IMU inspector | `data/camera_imu/…/*.parquet`, joined by trial ID and `parent_frame_index`, not an exposure-to-next-exposure time slice. Six signed int16 device counts retain `raw_0`…`raw_5` order. A batch spans time around the associated exposure; individual timestamps remain distinct. Trial IMU files load lazily when inspecting a frame. Reference parameters come from `meta/camera_imu_reference.parquet` via `calibration_id`; null remains null. No scale, bias, rotation or time-offset correction is applied, and no accelerometer/gyroscope axis labels are assumed. | | Time alignment | Playback uses the fixed-rate `frame_index / fps`, equivalent to `timestamp` in this release. The EMG cursor uses the current frame's **acquisition** `host_time_ns`, with integer subtraction before converting to relative seconds. This is not Unix time. The inspector preserves nanoseconds as strings and exposes the computed half-open sample range in the trial's EMG table. | | Combined contact | The current-frame indicator, binary history, pressure-chart backgrounds and inspector show the stored right-hand `contact`: 1 if thumb or index touches, 0 if both are free, −1 if unknown. The binary chart leaves unknown frames blank. It includes the dataset’s visual review/model agreement, rather than thresholding the per-finger EMG scores. Pressure smoothing does not change it. | | Pressure | Stored values are baseline-subtracted glove ADC counts predicted from EMG, with no independently validated accuracy for this release. Browser-only recovery from `pressure_thumb_adc` and `pressure_index_adc`, shown only when `model_valid` and finite. Thumb: `max(0, (pressure_thumb_adc + 3.400553667092545) / 0.5170289437889563)`. Index: `max(0, (pressure_index_adc + 5.729761362606111) / 0.5819535950321174)`. JavaScript numbers use float64 precision. Readouts, histories and the full-trial timeline show recovered activation, not ADC counts or Newtons. Missing estimates remain unavailable. Middle/ring/little have no estimates. | | Pressure smoothing | Applied to the recovered, zero-clamped activation arrays: frontend-only centered Gaussian, standard deviation **50 ms**, truncated at ±4σ (±200 ms). Weights use acquisition timestamps and are renormalized at the ends of each valid segment. Unsupported/nonfinite estimates and acquisition gaps split segments, so gaps remain unavailable. The current trial’s derived arrays are cached only in browser memory. Smoothing uses preceding and following frames; the inspector always retains original stored ADC values. Neither the API nor dataset arrays are modified. | | Secondary scores | `contact_thumb_probability` and `contact_index_probability` are EMG model scores, distinct from the canonical contact field. | | Inspector | All 27 frame columns, the computed EMG sample range and first sample, trial metadata, and calibration. | A single video element plays the selected eye. `requestVideoFrameCallback` drives values and the eye-specific overlay from its displayed exposure. Switching eyes briefly pauses playback, loads the other source, seeks to the same frame, and resumes if it was playing. Old video callbacks and trial loads are invalidated. Pausing and frame stepping settle the video, overlay and signals to one frame. A less precise animation-frame fallback supports browsers without `requestVideoFrameCallback`. The supplied preprocessing metadata specifies a 20–450 Hz Butterworth bandpass followed by a 50 Hz notch, using offline zero-phase forward/backward filtering. The viewer reads these results directly; it does not filter or resample again. The original timestamps, sample indices, run IDs and approval flags remain the alignment reference. Filter-valid status does not certify signal accuracy, and the supplied filter metadata notes possible endpoint transients. Trial changes cancel older requests and discard the previous trial’s EMG buffer. Trial metadata and full EMG load in parallel; playback is enabled only after both are ready and the selected video has loaded. The backend keeps at most two trial objects in its LRU cache. The browser retains all EMG samples for the selected trial in one buffer; seeking and changing the visible window never fetch or replace this buffer. Inspector details still load on demand, and video uses browser-managed byte-range requests. ## Full-trial EMG transport `GET /api/trial//emg/full` returns a binary response containing every pre-processed sample, with no resampling. Its first 16 bytes are the ASCII magic `EMGTRIAL`, a little-endian uint32 version (1), and a uint32 JSON-header byte length. The UTF-8 JSON header identifies the trial, sample count, 18 channels, source, units, quality counts and continuous usable segments (`start` inclusive, `stop` exclusive, approval, run ID). Zero padding aligns the following arrays to eight bytes: float64 acquisition seconds relative to the first video-frame host timestamp, followed by sample-major float32 EMG values. Both arrays are little-endian. JavaScript uses typed-array views of the received buffer without duplicating the signal. The browser validates the trial identity, sample count, source, byte length and segment bounds. All samples are transported, including invalid rows; only usable segments are drawn. Invalid/nonfinite samples, source-index discontinuities, time gaps, run changes and approval changes split the drawing paths. The legacy windowed JSON endpoint remains available for inspection and verification but is no longer used by the viewer. ## Current schema and IMU interpretation The current release stores 27 frame columns, two EMG columns and nine trial columns. Frame count and stream paths are derived from the episode index. The server derives frontend pose-support masks from `pose_target_status` (0 unavailable, 1 original, 2 interpolated), and EMG sample intervals from acquisition timestamps. Single-run information and filter parameters come from embedded EMG Parquet metadata. These are viewer conveniences; the source files are unchanged. Camera IMU axis order and scale are explicitly unverified in the capture documentation. Vendor references are present for 39 trials; trials **02, 03, 04 and 12** have no matched reference but retain their raw samples. The reference JSON also varies: two profiles contain explicit 4×4 forward/inverse transforms and omit `compensation_required`; the inspector preserves these differences. Physical synchronization accuracy has not been independently established. Reference effective offsets of about 1.78–1.97 ms have not been applied. See the [metadata schema reference](../meta/SCHEMA_REFERENCE.md) and [camera IMU documentation](../data/camera_imu/README.md).