export / import data from Matlab (mTRF toolbox) back into MNE

Hi,

I need to use the mTRF toolbox in Matlab to compute TRFs and reimport that matrix back into MNE.
I essentially exported the model matrix and I get a 1001 x 129 matrix. The includes 1001 TRFs and 129 channels, including bad channels and stimulus channels. The MEG generally has sfrq=1000Hz, but the TRF matrix basically squeezes this to 1 (as far as I understand), when one TRF has tmin=0s and tmax=1s.

I can basically do:


import mne
from scipy import io

# Save the info parameters from a real MEG data file (.fif) to get the channels:
mne.io.write_info('meg_template.json', raw.info)
# read this file:
meg_template = mne.io.read_info('meg_template.json')

# Load the MATLAB file
mat_data = io.loadmat('/path/to/model.mat')
model = mat_data['savemodel2']
info_new = mne.create_info(ch_names=meg_template.ch_names, sfreq=1)

then:
raw2 = mne.io.RawArray(model.T, info_new)
Creating RawArray with float64 data, n_channels=129, n_times=1001
    Range : 0 ... 1000 =      0.000 ...  1000.000 secs
Ready.

with raw2.plot() this looks really broken.
When I give sfreq=1000 then I get something that looks like a proper TRF function, but obviously it’s 1s of “data”.

I also don’t have any proper meta data that would look like an MEG.
Has anybody solved this problem before and might be able to offer some advice?

I also tried to use the mTRFpy module, but could not get this to work at all…

thanks,
Dennis

I’m using MNE 1.6.1, MacOS 14.2.1.

I don’t have a lot of input for you unfortunately, other than: The sampling frequency of your data is not changed by whatever mTRF is doing, so changing the sfreq parameter to 1 is in all likelihood the wrong way to go.

This is something to communicate here: GitHub - powerfulbean/mTRFpy: a python3 version of matlab mTRF-Toolbox by Lalor Lab https://mtrfpy.readthedocs.io/ (opening an Issue on GitHub)

I don’t see the problem here :thinking: Could you elaborate for someone who does not routinely use mTRF methods?

1 Like

thanks for you answer. I think it was a misunderstanding on my side. I eventually managed to get the data imported with the help of a matlab module. After discussing this with my supervisor, it is okay to treat the whole TRF matrix as just 1000ms of MEG data. The TRF essentially condenses the whole experimental condition into just the TRF.

This is at times really confusing to me, because I consider myself a beginner in either neuroscience, MNE, Matlab, or mTRF analyses. It was my impression that I had to rescale the TRF to the length of the experiment when I try to analyze it in MNE, but apparently this was wrong.

2 Likes

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