Skip to content

Edit this page

Open an issue

Neuroworks Montage File

File Format Overview

The .mtg file uses Natus's proprietary CKeyTree serialization format, a nested key-value tree structure. The syntax follows a pattern like:

(."KeyName", value)

with nested tuples using (.(key, value), (key, value), ...).

Top-Level Structure

The file contains:

  1. Frequency Bins (Bin0–Bin5): define spectral band coloring (delta, theta, alpha, beta, gamma, and an undefined bin with -1 cutoffs)
  2. ChanNames: a master list of all available channel names (512 total, from named SEEG contacts through to generic C214–C512 slots, plus DC channels, TRIG, OSAT, PR, Pleth)
  3. Channels: an array of channel display definitions, each with a ChanIndex and Channel sub-object

Channel Object Fields

Each channel entry contains:

Field Meaning
ChanIndex Zero-based display row index
Calibration Calibration data (appears empty/default here)
ChanProcType Processing type (e.g. "EEG")
ChanType Channel type (e.g. "EEG")
Color Waveform color (0 = default)
From_Name Reference electrode (0 = none/referential, or a channel name string)
Gain Display gain (e.g. "150 uV/mm")
GroupId See below
HffCutoff High frequency filter cutoff (-1 = off)
LffCutoff Low frequency filter cutoff
NotchCutoff Notch filter (0 = off)
PositiveUp Polarity convention (0 = negative up, standard EEG)
Set Whether this channel is active/enabled (1 = yes)
To_Name The electrode name being displayed
WaveEnhanced Wave enhancement processing flag

What is GroupId?

The GroupId values look like this:

-180300055/52509/18658/163/103/223/56/191/26/78/90

This is a GUID (Globally Unique Identifier) stored in a slash-delimited decimal format rather than the standard hex format.

A standard Windows GUID has the structure:

{XXXXXXXX-XXXX-XXXX-XX-XX-XXXXXXXXXXXX}

which is internally stored as: - 1× 32-bit integer - 2× 16-bit integers
- 8× individual bytes

The pattern int32/uint16/uint16/byte/byte/byte/byte/byte/byte/byte/byte, 11 components total, is a raw GUID in decimal component notation.

What does GroupId represent functionally? Based on the context, it most likely identifies which electrode group or depth electrode shaft a contact belongs to — i.e., all contacts on the same SEEG depth electrode would share the same GroupId. However, in this file every channel has a different GroupId, suggesting these are per-channel unique identifiers (perhaps assigned at implant time by the Natus recording software to link montage channels back to specific amplifier inputs or patient-specific electrode records).

Notes for Scripting

Here is a summary of what you need to replicate:

# Pseudocode structure
file = {
  "header": "CKeyTree",
  "FreqBins": [Bin0..Bin5],   # probably reuse as-is
  "ChanNames": [...],          # full list of available channels
  "Channels": [
    {
      "ChanIndex": 0,           # sequential, 0-based
      "Calibration": None,
      "ChanProcType": "EEG",
      "ChanType": "EEG",
      "Color": 0,
      "From_Name": 0,           # 0 = reference, or string channel name
      "Gain": "150 uV/mm",
      "GroupId": <GUID>,        # 11-component decimal GUID
      "HffCutoff": -1.0,        # -1 = no HFF
      "LffCutoff": 1.0,         # 1 Hz LFF
      "NotchCutoff": 0.0,
      "PositiveUp": 0,
      "Set": 1,
      "To_Name": "ChannelName", # must match a name in ChanNames
      "WaveEnhanced": 0
    },
    ...
  ]
}

Key challenges

  1. Binary header: the file starts with ÿÿ bytes and other binary framing; you'll need to capture the exact byte header
  2. GroupId GUIDs: generate random GUIDs and convert to this decimal component format, or reuse from a template
  3. Bipolar derivations: if you want bipolar channels (e.g., RTePo1–RTePo2), set From_Name to the reference channel string instead of 0
  4. File is truncated: the full file likely has additional top-level keys after the Channels array (possibly including Stage-related fields)