[FieldTrip] something wrong with my permutation test for ERP
蔡林
bertram0611 at pku.edu.cn
Thu Jan 16 10:27:40 CET 2014
Dear fieldtripers,
I have already understood the tuitorials about how to do a permutation test for ERP analysis.
I made some codes to do that. But I got some strange results and plots. And I couldnot find problems about my codes.
%%%%%%%%%%%Codes:
cfg = [];
cfg.keepindividual = 'yes';
cfg.channel = 'all';
avg_12 = ft_timelockgrandaverage (cfg, data_12(:).ERP);
avg_22 = ft_timelockgrandaverage (cfg, data_22(:).ERP);
clear data*;
outfil = strcat('/EEG/Discourse_Exp2/n16_grandavg_keeptrial_all_12vs22');
save(outfil, 'avg_12', 'avg_22');
load /EEG/Discourse_Exp2/n16_grandavg_keeptrial_all_12vs22;
load (sprintf('E:/EEG/Discourse_Exp2/neighbours_Lin.mat'));
% cfgneigh.neighbourdist = 42; %or 45, define the cluster neighbours % select all channels within 40 mm distance of the current channel as neighbours
% cfgneigh.elec = elec; % read channel locations and labels from this file
cfg.neighbours = neighbours_build;
% load J:/new_4_names/data_valence/fieldtrip/elec_60;
% cfgneigh.neighbourdist = 42; % select all channels within 36 mm distance of the current channel as neighbours
% cfgneigh.elec = elec; % read channel locations and labels from this file
% cfg.neighbours = ft_prepare_neighbours(cfgneigh);
cfg.channel = {'all'};
cfg.method = 'montecarlo';
% cfg.design = [1:24 1:24; ones(1,24), ones(1,24) * 2];
cfg.design = [1:16 1:16; ones(1,16), ones(1,16) * 2];
cfg.uvar = 1; % subject number (unit variable) on line 1 of the design matrix
cfg.ivar = 2; % condition number (independent variable) on line 2 of the design matrix
cfg.latency = [0.2 1];
cfg.avgovertime = 'no';%(default = 'no')
cfg.numrandomization = 1000;
cfg.correctm = 'cluster';
cfg.alpha = 0.05;
cfg.tail = 0; % one-or two-sided testing
cfg.clusterstatistic = 'maxsum'; % maximum sum of t-values within one cluster is the test statistic
cfg.clusterthreshold = 'parametric'; % paired-sample t-test for the uncorrected t-values
cfg.clusteralpha = 0.05;
cfg.clustertail = 0; % two-sided testing;
cfg.statistic = 'depsamplesT';
statis_all_12vs22 = ft_timelockstatistics(cfg, avg_12, avg_22);
outfil = strcat('/EEG/Discourse_Exp2/n16_statis_all_12vs22');
save(outfil, 'statis_all_12vs22')
%%%%%clustor plot
load /EEG/Discourse_Exp2/n16_grandavgERP_resp;
load /EEG/Discourse_Exp2/n16_statis_all_12vs22;
GA_RvsC = grandavg_12;
GA_RvsC.avg = grandavg_22.avg - grandavg_12.avg;
figure;
timestep = 0.05; %(in seconds)
sampling_rate = 500;
sample_count = length(statis_all_12vs22.time);
j = [0:timestep:1]; % Temporal endpoints (in seconds) of the ERP average computed in each subplot
m = [1:timestep*500:sample_count]; % temporal endpoints in MEEG samples
pos_cluster_pvals = [statis_all_12vs22.posclusters(:).prob];
pos_signif_clust = find(pos_cluster_pvals < statis_all_12vs22.cfg.alpha);
pos = ismember(statis_all_12vs22.posclusterslabelmat, pos_signif_clust);
neg_cluster_pvals = [statis_all_12vs22.negclusters(:).prob];
neg_signif_clust = find(neg_cluster_pvals < statis_all_12vs22.cfg.alpha);
neg = ismember(statis_all_12vs22.negclusterslabelmat, neg_signif_clust);
pos = statis_all_12vs22.posclusterslabelmat == 1; % or == 2, or 3, etc.
neg = statis_all_12vs22.negclusterslabelmat == 1;
for k = 1:16;
subplot(4,4,k);
cfg = [];
cfg.layout = 'Lin_use.lay';
cfg.xlim=[j(k) j(k+1)];
%cfg.zlim = [-1.0e-13 1.0e-13];
pos_int = all(pos(:, m(k):m(k+1)), 2);
neg_int = all(neg(:, m(k):m(k+1)), 2);
cfg.highlight = 'on';
cfg.highlightchannel = find(pos_int | neg_int);
cfg.comment = 'xlim';
cfg.commentpos = 'title';
ft_topoplotER(cfg, GA_RvsC);
end
Please help me.
Thanks a lot!
--
Lin Cai
Department of Psychology, Peking University, Beijing 100871, P.R.China
-------------- next part --------------
A non-text attachment was scrubbed...
Name: strange2.jpg
Type: image/jpeg
Size: 150724 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20140116/e0262f21/attachment-0002.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: strange.jpg
Type: image/jpeg
Size: 49512 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20140116/e0262f21/attachment-0003.jpg>
More information about the fieldtrip
mailing list