Reading .mat file in MNE

from scipy.io import loadmat
import mne

mat_file_name = "EEG.mat"

raw = loadmat(mat_file_name)
print(raw['EEG'])

dict_keys([‘header’, ‘version’, ‘globals’, ‘EEG’])

It can be received in dictionary form. However, when reading only the EEG here, only the NumPy array is spit out. When I output the raw['EEG] shape, it comes out as (1,1). What should I do?

Usually, loading the file with simplify_cells=True already makes the structure a bit less complex. Can you try and see if this helps in your case?

2 Likes

notimplementederror: please use hdf reader for matlab v7.3 files, e.g. h5py

data = {}
f = h5.File('test.mat')
for k, v in f.items():
    data[k] = np.array(v)

print(data.shape)

image

In this case, need to read it with h5py, but what should do if only measured items exist in the index and cannot see the values ​​of the measured items?

I think it should have the shape (41, n).

You created a dictionary with 41 keys. Instead, you probably want a list and then use np.vstack (or was it hstack?) or something. Not sure why data.shape even works for you, this actually should raise an exception.

Best wishes,
Richard

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.