Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 📂 Mitsar / WinEEG File Notes
- EEG stack is 3 parts:
- .EEG = raw stream (INT16 LE, multiplexed frames)
- .ERD/.VHDR = meta, offsets, chans, fs, calibration pointers
- .EVT/.VMRK = event / marker table
- Diff from BrainVision: Mitsar doesn’t keep all calibration in the sidecar. Some of it lives inside the .EEG header itself.
- 🧩 .EEG Layout (reverse-engineered)
- Header (0x000–0x3FF)
- Magic words: 0x0F0E, 0xB7CC, 0x0065 → loader sanity check
- Channel count, fs, frame size values
- Calibration table: 1 byte per chan at 0x0326–0x0338
- EEG chans: 0x0C = 12 µV/bit (default sensitivity)
- Reduced sets: 0x03 = 3 µV/bit
- Marker chans untouched (0x0A, 0x00)
- Some garbage/patient/reserved blocks we don’t care about
- Data section
- Multiplexed INT16 LE
- Frame = n_chans * 2 bytes
- Alignment is strict: (filesize – header – trailer) % frame_size == 0
- Trailer
- Tiny footer/pad/CRC-ish block
- Size varies (2–34 bytes observed)
- LB EO EEG → 34 bytes, NP EC → 2 bytes
- Wrong trailer = loader chokes (seek fail)
- âš¡ Calibration Hack
- Breakthrough = those single-byte µV/bit values.
- Stock = 0x0C (12 µV/bit)
- Low-sens = 0x03 (3 µV/bit)
- Ratio checks out (12/3 = 4×).
- WinEEG multiplies sample × calib byte → µV.
- If you don’t patch → WinEEG thinks everything is ~0 amplitude → blank grid.
- Patch EEG chans to 0x01 (1 µV/bit) → traces appear, scaling knob works.
- 🔧 EDF → Mitsar .EEG Conversion Flow
- Parse EDF
- Pull chan count, fs, sample count
- EDF must be uniform fs across chans (Mitsar doesn’t handle mixed rates)
- Export raw INT16 LE
- Scale EDF float → int16
- Interleave channels (frame-major)
- Splice into Mitsar template
- Take a known-good Mitsar .EEG (same chan count)
- Copy header/trailer verbatim
- Overwrite middle frames w/ EDF samples
- Keep head+tail frames if paranoid
- Patch calibration bytes
- EEG chans → 0x01 (1 µV/bit)
- Marker chans (0 + 18) untouched
- Validate trailer alignment
- (filesize – 1024 – trailer) % (n_chans*2) == 0
- Auto-detect trailer size if needed
- ✅ Rules of the Road
- Header magics intact → otherwise WinEEG throws seek failed
- Trailer correct → else misaligned, loader dies
- Calibration patched → else invisible traces
- Data is raw int16 LE multiplexed → big endian or planar = nope
- Sampling interval exact (µs precision) → even tiny fs mismatch = bugged
- 🎯 EDF → Mitsar Recipe (final)
- Load EDF + convert → raw int16
- Grab template .EEG (match chan count)
- Copy header + trailer unchanged
- Replace data block (keep markers intact)
- Patch 0x0327–0x0337 = 0x01 (EEG chans)
- Save, check alignment, done
- 👉 TL;DR:
- Mitsar .EEG is a template-driven container:
- magic header + 1-byte calibration table + raw INT16 frames + fixed-len trailer.
- Calibration patch was the last lock. Once you flip those bytes, EDF → EEG works and WinEEG plays nice.
Advertisement
Add Comment
Please, Sign In to add comment