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

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Tue Oct 17 16:23:30 CEST 2023


Hi Merlin,

I don’t care too much about code that has been provided by third parties :), so I will only comment on the screen output of your data structure:


      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'

This is inconsistent and indeed prone to give troubles.

The label field suggests that there are 7 channels in your data, which is in line with the second dimension (i.e. the numbor of columns) in the trial field. Assuming that the 240 rows correspond to the number of observations in your data, the appropriate dimord of the data structure should read ‘rpt_chan_<somethingelse>’. Given your context you seem to be working with spectral estimates (but without a time dimension per trial), so I don’t understand why in the reported data structure, there’s a ’time’ mentioned. Moreover, if the data matrix indeed is <number-of-observations> x <number-of-channels> the implicit third dimension (either ‘freq’, or ’time’, in your case ‘freq') seems to be singleton.

This would translate to a <data>.time, or <data>.freq field consisting of just a single element, with the appropriate value for the frequency.

As a side note, since you are dealing with frequency domain data, there’s no need to call ft_timelockanalysis, nor to call ft_preprocessing or ft_datatype_timelock

I suggest that you search the documentation on the website for information about the definition of a ‘freq’ structure (ft_datatype_freq) which is what you seem to be importing directly.

Good luck

Jan-Mathijs







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
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C01%7Cfieldtrip%40science.ru.nl%7C5e2be508ab3840b49dfc08dbcf1ca314%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638331494113455677%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=nBcHltwn40E11MmPIsreKqhzWwjt8g2fYmApIEFvQXs%3D&reserved=0>
https://doi.org/10.1371/journal.pcbi.1002202

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20231017/662f8a40/attachment.htm>


More information about the fieldtrip mailing list