[FieldTrip] A question on fieldtrip cluster-based permutation test

mikkelcv at drcmr.dk mikkelcv at drcmr.dk
Fri Feb 25 13:13:04 CET 2022


Dear Jaewon

I will address your first question/issue:


When you call timelockHH    = ft_timelockanalysis(cfg, 'ERP_HH.mat'); the argument after cfg, should not be the filename, but the data structure that you imported and is in your MATLAB workspace.



The order in which you call the function in your example in your mail is out of order, in that it seems that you define the cfg for the statistical test already for the averaging procedure. ft_timelockanalysis is not, despite it’s name, for statistical analysis of timelocked responses, but a function to average/aggregate over single trials, i.e. calculate ERPs in this case. The function for the cluster-based permutation statistics is ft_timelockstatistics. The order should be:

  1.  Import from Analyzer.
  2.  Calculate average with ft_timelockanalysis for each subject
  3.  Do statistics with ft_timelockstatistics across all subjects.



Best regards

Mikkel


Fra: fieldtrip <fieldtrip-bounces at science.ru.nl> på vegne af "오재원" via fieldtrip <fieldtrip at science.ru.nl>
Dato: fredag, 25. februar 2022 kl. 11.14
Til: fieldtrip at science.ru.nl <fieldtrip at science.ru.nl>
Cc: "오재원" <ann0207 at snu.ac.kr>
Emne: [FieldTrip] A question on fieldtrip cluster-based permutation test





Hello. I'm Jaewon Oh.



I am struggling with cluster-based permutation test using my EEG data (ERP).



First, I have already preprocessed my data (including filtering, segmentation, base-line correction, artifact rejection, CSD, etc.) in BrainVision analyzer and then exported the data using 'generic export', and then imported them into matlab. I followed thsi way to import the data into Matlab : https://www.youtube.com/watch?v=wyLg40dLwJo



According to an explanation on the function 'BVA2Matlab' used in the video, the function transfroms data into the form of the output of 'ft_preprocessing'.



So I thought I could apply my data which had been analyzed in BrainVision analyzer to 'ft_tiemlockanalysis' and then to 'ft_timelockstatistics'.







Below are the codes:







>> cfg         = [];



cfg.channel = {'EEG'};



cfg.latency = [0 0.6];







cfg.method           = 'montecarlo';



cfg.statistic        = 'ft_statfun_depsamplesFmultivariate';



cfg.correctm         = 'cluster';



cfg.clusteralpha     = 0.05;



cfg.clusterstatistic = 'maxsum';



cfg.minnbchan        = 2;



cfg.tail             = 0;



cfg.clustertail      = 0;



cfg.alpha            = 0.025;



cfg.numrandomization = 500;







Nsubj  = 26;



design = zeros(2, Nsubj*2);



design(1,:) = [1:Nsubj 1:Nsubj];



design(2,:) = [ones(1,Nsubj) ones(1,Nsubj)*2];







cfg.design = design;



cfg.uvar   = 1;



cfg.ivar   = 2;











>> cfg = [];



cfg.keeptrials = 'yes';



timelockHH    = ft_timelockanalysis(cfg, 'ERP_HH.mat');



timelockHN     = ft_timelockanalysis(cfg, 'ERP_HN.mat');



timelockLH    = ft_timelockanalysis(cfg, 'ERP_LH.mat');



timelockLN     = ft_timelockanalysis(cfg, 'ERP_LN.mat');











% and the error I encountered :



다음 사용 중 오류가 발생함: ft_checkdata (538번 라인)



This function requires 'raw+comp' or 'raw' data as input, see ft_datatype_raw.







오류 발생: ft_timelockanalysis (98번 라인)



data = ft_checkdata(data, 'datatype', {'raw+comp', 'raw'}, 'feedback', 'yes', 'hassampleinfo', 'yes');











ft_datatype_raw says that it is typically obtained after calling after ft_definetrial and ft_preprocessing.



However, as I said, I used 'BVA2Matlab' function which modifies data into the form of the output of ft_preprocessing. But why did that kind of error come up?



Can't I apply the data which has already been analyzed in BrainVision analyzer to fieldtrip cluster-based permutation test?











I also tried to apply the original raw data (.eeg, .vmrk, .vhdr) to the very first step of preprocessing in fieldtrip using 'ft_definetrial'.



However, somehow, it was not possible. Below are the codes.







>> cfg                         = [];



cfg.dataset                 = 'p01.eeg';



cfg.trialfun                = 'ft_trialfun_general'



cfg.trialdef.eventtype      = '?';



cfg.trialdef.eventvalue     = [1 2 3 4];



cfg.trialdef.prestim        = 0.2;



cfg.trialdef.poststim       = 1;



cfg = ft_definetrial(cfg);













As a result, I got the following :







cfg =







  다음 필드를 포함한 struct:







     dataset: 'p01.eeg'



    trialfun: 'ft_trialfun_general'







경고: Your path is set up incorrectly. You probably used addpath(genpath('path_to_fieldtrip')), this can lead to



unexpected behavior. See



http://www.fieldtriptoolbox.org/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path



경고: cfg.trialdef.eventtype='?' is deprecated, please specify cfg.trialfun='ft_trialfun_show'



evaluating trial function 'ft_trialfun_show'



reading the events from 'p01.vhdr'



the following events were found in the data



event type: 'New Segment'



with event values: 1







event type: 'Stimulus'



with event values: 'S  1' 'S  2' 'S  3' 'S  4' 'S  5' 'S  6' 'S 10' 'S 11' 'S111'







no trials have been defined yet, see FT_DEFINETRIAL for further help



found 525 events



the call to "ft_definetrial" took 3 seconds















The event values are all correct and retried with the event type of 'Stimulus' :







>> cfg                         = [];



cfg.dataset                 = 'p01.eeg';



cfg.trialfun                = 'ft_trialfun_general'



cfg.trialdef.eventtype      = 'Stimulus';



cfg.trialdef.eventvalue     = [1 2 3 4];



cfg.trialdef.prestim        = 0.2;



cfg.trialdef.poststim       = 1;



cfg = ft_definetrial(cfg);











And what I got from this was like :







cfg =







  다음 필드를 포함한 struct:







     dataset: 'p01.eeg'



    trialfun: 'ft_trialfun_general'







경고: Your path is set up incorrectly. You probably used addpath(genpath('path_to_fieldtrip')), this can lead to



unexpected behavior. See



http://www.fieldtriptoolbox.org/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path



evaluating trial function 'ft_trialfun_general'



reading the header from 'p01.vhdr'



reading the events from 'p01.vhdr'



다음 사용 중 오류가 발생함: ft_definetrial (210번 라인)



no trials were defined, see FT_DEFINETRIAL for help







Why can't I use even 'ft_definetrial'? Do you see any problem in my codes?











In short, I have two questions.



The first one is troubleshooting in applying the data imported from BrainVision analyzer to fieldtrip cluster-based permutation test,



and the second one is troubleshooting with ft_definetrial.











Thank you for reading this long mail.



I will be waiting for your response.



Thank you and have a nice day :)







All your best,







Jaewon
[https://mail.snu.ac.kr:443/checkread/MTU2ODgyMTIyOA==/ZmllbGR0cmlwQHNjaWVuY2UucnUubmw=/]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20220225/7ab29698/attachment.htm>


More information about the fieldtrip mailing list