Read fieldtrip epoch data: KeyError:'data'.

I tried to follow the tutorial to import fieldtrip epoch data into mne Importing data from MEG devices — MNE 0.24.1 documentation

My code is

original_data ='/home/s1.fif', preload=False)
original_info =
raw = mne.read_evoked_fieldtrip('/home/s1.mat',

But it will report an error
~/app/anaconda/envs/mne24/lib/python3.9/site-packages/mne/io/fieldtrip/ in read_evoked_fieldtrip(fname, info, comment, data_name)
     171 ignore_fields=['previous'],
     172 variable_names=[data_name])
--> 173 ft_struct = ft_struct[data_name].
     175 _validate_ft_struct(ft_struct)


I did not find any data_name related variables in the fieldtrip. I would like to ask how should I deal with this?
Thank you very much for your help!

  • MNE version: 0.24.0
  • operating system: Ubuntu 20.04

Hello @elvisjade,

with which version of FieldTrip was this file generated, and how was ist saved?


The saved code should look like this

save([‘sub2019’ subjectID{x} ‘_gradclean.mat’], ‘data_clean’, ‘-v7.3’) .

I’m not sure about the version of the FieldTrip, I didn’t find a way to find the version of the fieldtrip that handles this data, but it should be the 2019 version.

Hello @elvisjade, any chance you could share that file with me so I can take a closer look? My email address is


I have sent it to you, thank you very much for your help! :grinning:

You need to tell MNE in which HDF5 structure the data is stored. To get a list of structures in the file, you can run:

import h5py

f = h5py.File('datarandom.mat')

This will tell you that in your particular case, the key is data_eeg.

Now you can use that information when reading the file by providing the data_name parameter (btw the example data you provided me with was raw, not evoked data, so I’m using read_raw_fieldtrip() here):

raw =
    info=None,  # replace this with your info – I don't have any

This then successfully loads the raw:

(lots of information missing here because I didn’t provide an info; you should see more detailed output!)

Best wishes,