Question about mwk2 event structure

beshoy.agayby's Avatar


14 Apr, 2019 03:50 PM

Hi Chris,

When I extracted events from .mwk files with different event codes, the extracted events were sorted in the order of the events' occurrence. However, with .mwk2, I noticed that the data is sorted according to the type of the event and not chronologically. Is this the only way of extracting data now or can I specify some option to get them in chronological order?
I can always re-order them according to the time stamps in Matlab, but I wanted to get more info form you.

Thanks in advance,


  1. Support Staff 1 Posted by Christopher Sta... on 16 Apr, 2019 01:56 PM

    Christopher Stawarz's Avatar

    Hi Beshoy,

    Yes, MWK2 files are sorted first by event code, then by event time. This makes extracting events by code tremendously faster than with the old MWK format. (Filtering by time is usually faster, too, but to a smaller degree.)

    At present, there's no way to request that getEvents (or MWKFile in Python) return the events for multiple event codes sorted first by time. I could add support for this pretty easily. (Under the hood, MWK2 files are SQLite databases, so it'd just be a matter of adding an optional ORDER BY clause to the selection query.) However, this would result in longer read times, since you'd be jumping around through the event file (which is naturally sorted by code first).

    I'll do some tests to assess exactly how much slower sorted-by-time reads take. If performance isn't drastically worse, I'll add that as an option to MWorks' event-reading tools.


  2. 2 Posted by beshoy.agayby on 16 Apr, 2019 02:32 PM

    beshoy.agayby's Avatar

    Hi Chris,

    Thanks for the quick reply. Indeed, it's much faster than before. It shouldn't be a problem really; I was just curious if i was missing anything. I assume it would be easier to do it after extraction.


Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac