[FieldTrip] error: Unexpected dimord. Unsure what is incorrect

Merlin Kelly merlinkelly75 at gmail.com
Tue Oct 17 14:23:43 CEST 2023


Hello
I am attempting to process my data to create timelockanalysis data for
later analysis. However when I run ft_preprocessing(cfg, Data), I get the
error:
Warning: could not determine dimord of "trial" in:

      label: {7×1 cell}
        hdr: [1×1 struct]
    fsample: 500
      trial: [240×7 single]
       time: [1 1 1 1 1 1 1]
     dimord: 'chan_freq'


Error using fixsampleinfo
unexpected dimord

Error in ft_datatype_timelock (line 152)
      timelock = fixsampleinfo(timelock);

Error in ft_checkdata (line 281)
  data = ft_datatype_timelock(data, 'hassampleinfo', hassampleinfo);

Error in ft_preprocessing (line 274)
  data = ft_checkdata(data, 'datatype', {'raw+comp', 'raw'},
'hassampleinfo', 'yes');

Error in Mean_data_prep (line 33)
        Data=ft_preprocessing(cfg, Data);

My code is based on literature that provide their fieldtrip code: "EEG
alpha–theta dynamics during mind wandering in the context of breath focus
meditation: An experience sampling approach with novice meditation
practitioners"

My data are Matlab 3D arrays of size 36 x 120 x 7, which represent subjects
x trial x channels where the data is the mean theta frequency of each
5-second trial and electrode. The code I'm using to convert data is present
below:
function [DATA, layout]=Mean_data_prep(data, Participant_index, index, Name)
load('electrode19.mat')
load('chanlocs.mat')
DATA = cell(1, max(unique(Participant_index)));
%for each participant, load data in struct form and prepare for
%fieldtrip
for i=1:max(unique(Participant_index))
if i == 1 || i == 3 || i == 6 || i == 9 || i == 10 %|| i == 4 || i == 7 ||
i == 5 || i == 8 || i == 21
continue
end
clear Data
Data=struct();
Data.label=electrode19;
Data.hdr.nChans=numel(electrode19);
Data.hdr.label=electrode19';
Data.hdr.Fs=500;
Data.fsample=500;
data_sel = data(Participant_index(index) == i, :,:);
if size(data_sel, 1) ~= 1
data_sel = reshape(data_sel, [], size(data_sel, 3));
else
data_sel = squeeze(data_sel);
end
Data.trial = data_sel;
Data.time=ones(1,size(data_sel,2));
Data.hdr.nSamples=1;
Data.dimord = 'chan_freq';
cfg=[];
Data=ft_preprocessing(cfg, Data);
Data = ft_timelockanalysis(cfg, Data);
%Data = ft_datatype_timelock(Data);
% Data.trialinfo=labels;
cfg.layout = 'biosemi32.lay';
Data.layout = ft_prepare_layout(cfg);
layout = ft_prepare_layout(cfg);
%Data.layout=Data;
DATA{i} = Data;
DATA{i} = NaN;
% else
% x = x - 1;
% end
end
end
I have changed the dimord and other factors of this code, but I believe the
issue is the Data.time variable as I have functioning code that is suitable
for a 4D array with time in the last dimension. If anyone knows how to
correct this error code, it would be appreciated.
Best
Merlin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20231017/0595144e/attachment.htm>


More information about the fieldtrip mailing list