Export Time-Frequency to Fieldtrip


I have been trying to export time-frequency data to a fieldtrip structure with the function out_fieldtrip_timefreq.m. It works just fine until I try to compute a grand average with fieldtrip, when it says that dimord is not supported. With your process, data are exported as ‘chan_time_freq’ while I guess Fieldtrip is expecting ‘chan_freq_time’. Oddly though it does not seem to be a problem to compute statistics with ft_freqstatistics. Could you help with that?

Thanks a lot !

Hi Svetlana,

I’ll look into this in a few days, to check if I can easily switch the dimension order to ‘chan_freq_time’.
I was doing it the way it is now because I developed it for the stats and it was working, and it was easier to keep everything in the same format.

For the moment, I guess you can just permute the dimensions 2 and 3 and change or remove dimord.
ftData.freq = permute(ftData.freq, [1 3 2]);
ftData = rmfield(ftData, ‘dimord’)

Could you post here your entire script (Brainstorm export+FieldTrip average), it will help me test the modifications?


Sure, here it is:

% Path for brainstorm files
sFiles = {‘S1/@intra/timefreq_ersd_151126_1951.mat’, …
‘S2/@intra/timefreq_ersd_151126_1952.mat’, …
‘S3/@intra/timefreq_ersd_151126_1953.mat’, …
‘S4/@intra/timefreq_ersd_151126_1954.mat’, …
‘S5/@intra/timefreq_ersd_151126_1955.mat’, …

Subs = length(sFiles);
alldata_L = cell(1,Subs);

for s = 1:Subs

L = fullfile(sFiles{s});
alldata_L {s} = out_fieldtrip_timefreq(L);


cfg = [];
cfg.keepindividuals = ‘no’;
GA = ft_freqgrandaverage(cfg,alldata_L{:});


Thanks a lot ! I will tweak it for now…