[FieldTrip] cluster-based permutation test ft_timelockanalysis error w/ for-loop issue

Elisabeth Freund elisabeth.freund at tu-dresden.de
Mon Jul 11 16:18:27 CEST 2022


Hello Jeawon,

I think if you use cfg.inputfile, this field needs to contain the path to a .mat file, not a variable in the matlab working space. If you want to load the data into the matlab working space and then run timelock analysis on this data, you can create a cfg structure without a field named ‘inputfile’. Instead, you put the variable containing the data as the second input variable of ft_timelockanalysis.

Your code would then look like this:


load input

cfg = [];

cfg.channel = 'eeg';

cfg.keeptrials = 'yes';

HH_timelock = ft_timelockanalysis(cfg, input);

save HH_timelock HH_timelock;



Alternatively, you change the field ‘inputfile’:



cfg = [];

cfg.channel = 'eeg';

cfg.inputfile = ‘input.mat’;

cfg.keeptrials = 'yes';

HH_timelock = ft_timelockanalysis(cfg);

save HH_timelock HH_timelock;





I hope this fixes your issues!



Best,

Elisabeth


Von: fieldtrip <fieldtrip-bounces at science.ru.nl> Im Auftrag von "???" via fieldtrip
Gesendet: Montag, 11. Juli 2022 14:21
An: fieldtrip at science.ru.nl
Cc: "오재원" <ann0207 at snu.ac.kr>
Betreff: [FieldTrip] cluster-based permutation test ft_timelockanalysis error w/ for-loop issue






Hello,



My name is Jaewon and I was trying to conduct a cluster-based permutation test with EEG data.

Before that, I faced a problem in running ft_timelockanalysis.

I wanna know :

1. What is wrong with my code and how I can solve these errors.

2. How I can alter my code using for-loop. (I know using for-loop is not essential but just optional.. but I wanna make this code shorter and simpler with for-loop)


To use for-loop, I tried strcat function in for-loop but this made the names of the structures a series of characters and eliminated the contents of the data.

I attach my matlab code and errors I got below.

Subj_(number)_ERP_CSDdata are structures containing the data of each subject.







input = table(Subj_01_ERP_CSDdata, Subj_02_ERP_CSDdata, Subj_03_ERP_CSDdata,Subj_04_ERP_CSDdata,Subj_05_ERP_CSDdata,Subj_06_ERP_CSDdata,Subj_07_ERP_CSDdata,Subj_08_ERP_CSDdata,Subj_09_ERP_CSDdata,Subj_10_ERP_CSDdata,Subj_11_ERP_CSDdata,Subj_12_ERP_CSDdata,Subj_13_ERP_CSDdata,Subj_14_ERP_CSDdata,Subj_15_ERP_CSDdata,Subj_16_ERP_CSDdata,Subj_17_ERP_CSDdata,Subj_18_ERP_CSDdata,Subj_19_ERP_CSDdata,Subj_20_ERP_CSDdata,Subj_21_ERP_CSDdata,Subj_22_ERP_CSDdata,Subj_23_ERP_CSDdata,Subj_24_ERP_CSDdata,Subj_25_ERP_CSDdata,Subj_26_ERP_CSDdata);

input = table2cell(input);

save input input



load input

cfg = [];

cfg.channel = 'eeg';

cfg.inputfile = input;

cfg.keeptrials = 'yes';

HH_timelock = ft_timelockanalysis(cfg);

save HH_timelock HH_timelock;



Error: loadvar (line 11)

file name should be a string



Error: ft_preamble_loadvar (line 89)

        assign(preamble_argin{i}, loadvar(cfg.inputfile{i}, preamble_argin{i}));



Error: ft_preamble (line 83)

evalin('caller', full_cmd);



Error: ft_timelockanalysis (line 88)

ft_preamble loadvar data


Thank you so much and have a nice day:)



Best,



Jaewon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20220711/44caacb0/attachment.htm>


More information about the fieldtrip mailing list