[Eeglablist] eeglab Question on Bootstrap of ERSP plots
Makoto Miyakoshi
mmiyakoshi at ucsd.edu
Tue Jul 8 09:42:38 PDT 2014
Dear Hiten,
> Makoto, I can surely post this on the eeglab list serve. Do I just email
inquires to eeglablist at sccn.ucsd.edu?
Start from here.
http://sccn.ucsd.edu/eeglab/eeglabmail.html
Let me share my code with you. It may help. Use it at your own risk. No
guarantee.
%%%%%%%%%%%%%%%%%%%%%%%%
tmpITC = STUDY.cluster(1,6).erspdata{}
meanITC = mean(tmpITC,3);
surro = zeros(100,400,2000);
for n = 1:2000
n
bootFreq = randi(size(tmpITC,1),[size(tmpITC,1),1]);
bootLatency = randi(size(tmpITC,2),[size(tmpITC,2),1]);
bootIc = randi(size(tmpITC,3),[size(tmpITC,3),1]);
tmpSurro = mean(tmpITC(bootFreq,bootLatency,bootIc),3);
surro(:,:,n) = tmpSurro;
end
bootSurro = zeros(100,400,2000);
for n = 1:2000
bootIdx = randi(2000,[size(tmpITC,3),1]);
tmpSurro = mean(surro(:,:,bootIdx),3);
bootSurro(:,:,n) = tmpSurro;
end
% multiple comparison using bootstrap
figure; imagesc(mean(bootSurro,3))
pvalMap = stat_surrogate_pvals(bootSurro,meanITC,'one');
[p_fdr,p_masked] = fdr(pvalMap,0.01);
% debri removal
[labelMap,uniqueLabelNum] = bwlabeln(p_masked);
tmpDisp = sort(labelMap(:),'descend');
[occurrence,idx] = hist(tmpDisp,unique(tmpDisp));
sortOccurrence = sort(occurrence,'descend');
disp(num2str(sortOccurrence(2:10)));
threshold = 1000;
threshOccurrence = occurrence;
threshIdx = find(threshOccurrence<threshold);
kMask = ismember(labelMap,idx(threshIdx));
finalMask = p_masked-kMask;
figure
subplot(1,3,1)
imagesc(meanITC); axis xy
set(gca,'XTick', 1:50:400, 'XTickLabel',
round(STUDY.cluster(1,3).itctimes(1:50:400)),...
'YTick', [1 29 44 54 77 95], 'YTickLabel', [1 4 8 13 40 100])
set(get(gca,'XLabel'), 'String', 'Latency(ms)')
set(get(gca,'YLabel'), 'String', 'Frequency(Hz)')
title('Cluster 3 ITC');
subplot(1,3,2)
imagesc(p_masked); axis xy
set(gca,'XTick', 1:50:400, 'XTickLabel',
round(STUDY.cluster(1,3).itctimes(1:50:400)),...
'YTick', [1 29 44 54 77 95], 'YTickLabel', [1 4 8 13 40 100])
set(get(gca,'XLabel'), 'String', 'Latency(ms)')
set(get(gca,'YLabel'), 'String', 'Frequency(Hz)')
title('Cluster 3 ITC, p<0.022, corrected with FDR');
subplot(1,3,3)
imagesc(finalMask); axis xy
set(gca,'XTick', 1:50:400, 'XTickLabel',
round(STUDY.cluster(1,3).itctimes(1:50:400)),...
'YTick', [1 29 44 54 77 95], 'YTickLabel', [1 4 8 13 40 100])
set(get(gca,'XLabel'), 'String', 'Latency(ms)')
set(get(gca,'YLabel'), 'String', 'Frequency(Hz)')
title('Cluster 3 ITC, p<0.022, corrected with FDR, k>1000');
set(gcf,'Position', [1602 510 1604 322])
%%%%%%%%%%%%%%%%%%%%%%%%%%%
Makoto
On Wed, Jul 2, 2014 at 8:36 PM, Hiten Patel <hpatel90 at gmail.com> wrote:
> Thanks for the response Ramon and Makoto,
>
> I was asking specifically about how to plot significance between the ersp
> obtained from subtracting two conditions.
>
> For example:
> erspDiff=ersp1-ersp2;
>
> since erspDiff is not obtained from newtimef, it doesn’t have any
> bootstrap (or alpha values) associated with it.
> In order to mask an ersp in tftopo, the function requires erspboot (a two
> column vector with min and max level at each frequency.
> Is there any way to obtain such a matrix for erspDiff?
>
> I’ve tried a method using the function bootstat, and gotten some results.
> However, bootstat provides a max and min point at each time-frequency
> point, creating a 3D matrix.
>
> Makoto, I can surely post this on the eeglab list serve. Do I just email
> inquires to eeglablist at sccn.ucsd.edu?
>
> Hiten
>
> On Jul 1, 2014, at 2:47 PM, Ramón Martinez <nucleuscub at gmail.com> wrote:
>
> Hi Makoto and Hiten,
> The significance levels are used to mask out the non significant values
> in all the plots. This is showed by the green areas. For example, if you
> make newtimef without the significance level and then use the 'alpha'
> option you will see basically the same plots but masked by green values...
> the values that survived to the test. Not sure if this answer your
> question..
> Best,
> Ramon
>
> p.s. Note that in the previous revision of this function, this method was
> called 'bootstrap' though it is actually permutation....
>
>
>
> On Tue, Jul 1, 2014 at 11:19 AM, Makoto Miyakoshi <mmiyakoshi at ucsd.edu>
> wrote:
>
>> Dear Hiten,
>>
>> I would like to redirect you to the eeglab mailing list since other users
>> may have the trouble with the same issue. If you agree please reply it
>> including eeglablist address.
>>
>> Ramon, I see some potentials that this issue could be related to the
>> other issue you have worked on for a week... any comment?
>>
>> Makoto
>>
>>
>> On Mon, Jun 30, 2014 at 12:50 PM, Hiten Patel <hpatel90 at gmail.com> wrote:
>>
>>> Hi Makoto,
>>>
>>> I had a question regarding ERSP plots. I am working with two conditions
>>> and subsequently have two epoch files. In order to see the difference of
>>> the results between these two conditions, I am subtracting their ersp
>>> values (see script below). However, I am having a difficult time obtaining
>>> a bootstrap significance level for the new ersp plot, that is a subtraction
>>> between the two conditions. My plots come out fine, however they have no
>>> significance levels. Currently I am working with individual data sets, and
>>> in the future, I plan to work thru a study format.
>>>
>>> Do you have any suggestions on how to obtain a plot with bootstrap level
>>> of 0.05?
>>>
>>> My Code:
>>>
>>>
>>> figure;
>>> [ersp,itc,powbase,times,freqs,erspboot,itcboot] =
>>> newtimef(ALLEEG(11).data(26, :, :),...
>>> 4000, [-1000 2999], 1000,[3 0.5], 'freqs', [30:150], 'alpha', 0.01,
>>> 'plotitc','off');
>>>
>>> figure;
>>> [ersp2,itc2,powbase2,times2,freqs2,erspboot2,itcboot2] =
>>> newtimef(ALLEEG(12).data(26, :, :),...
>>> 4000, [-1000 2999], 1000,[3 0.5], 'freqs', [30:150], 'alpha', 0.01,
>>> 'plotitc','off');
>>> *%The first two plots above have alpha levels of significance 0.01,
>>> however none of the plots in the subplot below show significance levels.*
>>>
>>>
>>> figure;
>>> subplot(2,2,1);
>>> tftopo(ersp, times, freqs); title('Hits');
>>>
>>> subplot(2,2,2);
>>> tftopo(ersp2, times2, freqs2); title('Misses');
>>>
>>> subplot(2,2,[3:4]);
>>> erspDiff=ersp-ersp2;
>>> erspbootDiff=erspboot-erspboot2;
>>> tftopo(erspDiff, times, freqs); cbar; title('Hits-Misses');
>>>
>>>
>>>
>>>
>>> Thanks for your help,
>>>
>>> Hiten Patel
>>> Wayne State University
>>> Institute of Gerontology, Department of Neuroscience.
>>>
>>
>>
>>
>> --
>> Makoto Miyakoshi
>> Swartz Center for Computational Neuroscience
>> Institute for Neural Computation, University of California San Diego
>>
>
>
>
--
Makoto Miyakoshi
Swartz Center for Computational Neuroscience
Institute for Neural Computation, University of California San Diego
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20140708/4690c7c1/attachment.html>
More information about the eeglablist
mailing list