dealing with .mat files in MNE / how to extract the events or create the raw object ?

Hi , I am a new learner to MNE-Python . I am dealing with this sleep dataset , it is in .mat format and seems like MNE does not read .mat files into raw object so I can easily reach to the metadata in the data . anyone can help or advice me on this?

Hello,

Unless I’m mistaken, .mat files do not have a “standard” structure, thus a general reader can not be written. Instead, you can read the file with pymatreader (I think as a dictionary?), retrieve the information of interest (data array (n_channels, n_samples), channel information, events, …) and create an MNE raw with mne.io.RawArray.
More information in this tutorial: Creating MNE-Python data structures from scratch — MNE 1.5.1 documentation

Mathieu

1 Like

thanks alot , I tried your idea and it was helpful

You could also try loading your file with MNELAB. I’ve implemented a dialog where you can pick which data structure within your .mat file you would like to import. It also gives you the corresponding Python code (the call to read_raw()).

1 Like