Skip to content

The .mrk file format

A .mrk file is the file AnyWave uses to store markers. It is a plain text file, one marker per line, with the columns separated by tab characters. It is easy to write by hand, from a spreadsheet or from a script, and AnyWave reads and writes it in every place where markers are exchanged:

A first example

// A marker file written by hand
Spike   -1  11.45   0   Fz,Cz,  #FF8800
Spike   -1  12.2    0   Fz,Cz,  #FF8800
Alpha   9.5 3   2   O1,O2,P3,P4,    #2E9E5B
Stim A  -1  16  0   #0000FF
Noise   0.8 20  1.5
Line Label Value Position Duration Targets Color
1 Spike none 11.45 s 0 (single marker) Fz, Cz orange
2 Spike none 12.2 s 0 (single marker) Fz, Cz orange
3 Alpha 9.5 3 s 2 s (selection) O1, O2, P3, P4 green
4 Stim A none 16 s 0 (single marker) all channels (global) blue
5 Noise 0.8 20 s 1.5 s (selection) all channels (global) default

The first line, which starts with //, is a comment. This is the file that was loaded in the screenshot of the introduction.

The rules of the format

  • One marker per line, columns separated by a tab. Spaces do not separate columns: Stim A above is a label made of two words, and a line written with spaces between the columns is not understood.
  • Empty lines are ignored. Lines that start with // are ignored: use them for comments.
  • Numbers use a decimal point (11.45, not 11,45). There is no thousands separator, and no quotation marks around the text.
  • Times are in seconds from the beginning of the recording, not clock times.
  • A line that cannot be understood (no label, no value, no position) is skipped, without an error message. If a file loads with fewer markers than expected, look first at the separators between the columns.
  • The file has no header line: if you want one, start it with //.

The columns

# Content Required Details
1 Label yes The name of the marker. It cannot contain a tab. A line with an empty label is ignored; AnyWave writes No Label for a marker that has none.
2 Value yes A number. -1 means no value (the list shows No Value).
3 Position yes Where the marker starts, in seconds.
4 Duration no How long the marker lasts, in seconds. 0, or no column at all, makes a single marker.
5 and 6 Targets and Color no The channels the marker is about, and its color. See below.

The type of a marker (single or selection) is not stored: a marker with a duration other than 0 is a selection, the others are single markers.

Targets and color

  • Targets are channel names separated by commas: Fz,Cz. The names are the ones of the recording. A marker without targets is global. AnyWave writes a comma after every name (Fz,Cz,) and reads both forms.
  • Color is written as #RRGGBB, with the three components in hexadecimal: #FF0000 is red, #00FF00 green, #0000FF blue. A marker without color is drawn with the default one.

Targets and color can come in either order, because AnyWave recognizes the color by its #:

HFO 150 51.23   0.2 #FF0000 A1
HFO 150 51.23   0.2 A1  #FF0000

are the same marker. When there are no targets, the color goes in column 5 (Stim A in the first example). To leave the targets out and still have a color in column 6, leave column 5 empty (two tabs in a row).

Note

AnyWave also understands a color name such as red or darkcyan, but only in column 6, after the targets (the processes that set a color by name use it). In column 5 it would be read as a channel name. Prefer #RRGGBB, which works everywhere.

What AnyWave writes

Here is the beginning of a file written by Save markers, for a recording whose markers come from a BrainVision .vmrk file:

// AnyWave Marker File
Eyes closed -1  0.004000000189989805    7
New Marker  -1  5.621958255767822   1.984375
Eyes open   -1  7.004000186920166   62.99999618530273
Blink   -1  7.303999900817871   0
Blink   -1  9.604000091552734   0
Spike-wave  -1  11.00399971008301   2.5
  • The first line is // AnyWave Marker File.
  • The numbers have up to 16 significant digits. Positions and durations are kept as 32-bit floating point numbers, which is why 7.004 comes back as 7.004000186920166. It is the same position for all practical purposes: the rounding is a few microseconds during the first minutes of a recording, and stays under a millisecond for the first four hours. You do not need to round anything yourself.
  • The targets, when there are some, are written with a comma after each name, then the color.
  • The order of the lines does not matter when you write a file yourself.

What AnyWave does when it loads a file

  • The markers that start after the end of the recording are dropped, and the ones that go past the end are cut at the end.
  • A duration shorter than 10 ms (but not zero) is turned into 0: the marker becomes a single marker.
  • Duplicates are removed: two markers with the same label, the same duration, the same targets and a position that differs by less than one millisecond count as one. When you load a file by hand, AnyWave tells how many duplicates it removed.

Write a file yourself

From a spreadsheet. Put the label, value, position and duration in columns A to D (and the targets and the color in E and F if you need them), then save as Text (Tab delimited). Rename the file to .mrk. Do not use the CSV format: it separates the columns with commas or semicolons, which AnyWave does not read.

From a script. A few lines are enough, for instance in Python:

events = [("Stim", 12.5, 0.0), ("Stim", 31.2, 0.0), ("Rest", 40.0, 20.0)]   # label, seconds, duration

with open("my_markers.mrk", "w") as f:
    f.write("// written by my script\n")
    for label, position, duration in events:
        f.write(f"{label}\t-1\t{position}\t{duration}\n")

Then use Load markers (see Marker files, import and BIDS).

Tip

If the labels or the channel names contain accented or other non-ASCII characters, keep the file for your own machine: the characters are read in the encoding of the computer, so they may look different on another system. Plain ASCII characters travel everywhere.