Mworks library unpacking on linux system

Hi Chris,

I’m trying to unpack mwel2 files, using either MATLAB or python, on a non-OSX machine. The mworks library that comes shipped with the app is compiled in OS X – any chance you can provide something for a linux system?

Alternatively, I see that we can use the msgpack module to directly unpack mwel2 files, but I don’t see how to get the variable names (rather than just the integer code). Can you advise on this?

Let me know, and thanks in advance,
Rishi

Hi Rishi,

The mworks library that comes shipped with the app is compiled in OS X – any chance you can provide something for a linux system?

Sorry, but MWorks doesn’t support Linux.

Alternatively, I see that we can use the msgpack module to directly unpack mwel2 files, but I don’t see how to get the variable names (rather than just the integer code). Can you advise on this?

You’re referring to this Python code, right?

You need to extract the variable codec from the event file. The codec has event code zero, which conveniently means it’s the first event in an MWK2 file. Here’s how you can use the codec to create a simple dictionary mapping integer codes to variable names:

code_to_name = {}
with MWK2Reader('my_data.mwk2') as event_file:
    for code, time, data in event_file:
        if code == 0 and not code_to_name:
            code_to_name = dict((c, data[c]['tagname']) for c in data)
        # Continue event processing
        ...

Cheers,
Chris