[Eeglablist] Plots of ERSP significance and 'cbar'

Arnaud Delorme arno at ucsd.edu
Mon Aug 19 20:33:26 PDT 2013


Dear Katherine,

as outlined by Makoto, you will need to compute the min/max accross all groups and condition and then constraint the color using these limits.

Best,

Arno

On 19 Aug 2013, at 15:26, Makoto Miyakoshi wrote:

> Dear Katherine,
> 
> Copy and paste below and run it. See how to set the color scales.
> 
> Makoto
> 
> % generate dummy data
> channels = [1 2 3];
> erspdata{1,1}=randn(50,200,3,2);
> erspdata{1,1}(:,:,2,:)=erspdata{1,1}(:,:,2,:)+1;
> erspdata{1,1}(:,:,3,:)=erspdata{1,1}(:,:,3,:)+2;
> ersptimes = [1:200];
> erspfreqs = [1:50];
> 
> % compute ersp and stats
> figure('Color',[1 1 1]);
> for chan=1:length(channels)    
>     e=channels(chan);
>     pvals=std_stat({erspdata{1,1}(:,:,chan,:) zeros(size(erspdata{1,1}(:,:,chan,:))) }', 'method', 'permutation', 'condstats', 'on', 'correctm', 'fdr');
>     groupersp=mean(erspdata{1,1}(:,:,chan,:),4);
>     maxersp=max(groupersp);
>     tmpersp=mean(erspdata{1,1}(:,:,chan,:),4); % average ERSP for all subjects
>     tmpersp(pvals{1}>0.05)=0; % zero out non-significant values
>     plotData(:,:,chan)=tmpersp;
> end
> 
> % compute max and min across all plots
> zmax = max(plotData(:));
> zmin = min(plotData(:));
> 
> % plot
> for chan=1:length(channels)
>     subplot(1,3,chan);
>     imagesc(ersptimes, erspfreqs, plotData(:,:,chan), [zmin zmax])
>     set(gca,'ydir','normal'); xlabel('Time (ms)'); ylabel ('Frequencies (Hz)'); %cbar;
>     hold on; title(['Channel ',num2str(e)]);
> end
> 
> 
> 2013/8/17 Katherine Naish <K.R.Naish at pgr.reading.ac.uk>
> Dear Arno and list,
> 
> I was hoping someone could advise on the code I am using to plot significant ERSPs for a group of subjects. Based on the code recommended to Alex previously, I am using the following code (to plot significance for a number of channels separately). It seems to be doing what I want it to, apart from the fact that the colour scale is rather crazy (see attached). I've played around with the 'cbar' function but can't figure out how to make it consistent across the different data sets.
> 
> figure('Color',[1 1 1]);
> for chan=1:length(channels)    
>     e=channels(chan);
>     pvals=std_stat({erspdata{1,1}(:,:,chan,:) zeros(size(erspdata{1,1}(:,:,chan,:))) }', 'method', 'permutation', 'condstats', 'on', 'correctm', 'fdr');
>     groupersp=mean(erspdata{1,1}(:,:,chan,:),4);
>     maxersp=max(groupersp);
>     tmpersp=mean(erspdata{1,1}(:,:,chan,:),4); % average ERSP for all subjects
>     tmpersp(pvals{1}>0.05)=0; % zero out non-significant values
>     subplot(3,2,chan);
>     imagesc(ersptimes, erspfreqs, tmpersp);
>     set(gca,'ydir','normal'); xlabel('Time (ms)'); ylabel ('Frequencies (Hz)'); %cbar;
>     hold on; title(['Channel ',num2str(e)]);
> end
> 
> 
> Any help very much appreciated!
> 
> Many thanks,
> katherine
> 
> From: eeglablist-bounces at sccn.ucsd.edu [eeglablist-bounces at sccn.ucsd.edu] on behalf of Arnaud Delorme [arno at ucsd.edu]
> Sent: 14 January 2013 15:26
> To: Aleksandra Vuckovic
> Cc: eeglablist
> Subject: Re: [Eeglablist] Ploting ONLY stat stignificant ERSP ina study
> 
> Dear Aleksandra,
> 
> then use the EEGLAB function imagesclogy instead of imagesc
> 
> imagesclogy(times, freqs, tmpersp); set(gca, 'ydir', 'log'); xlabel('Time (ms)'); ylabel('Frequencies (Hz)'); cbar; % plot ERSP
> 
> Best,
> 
> Arno
> 
> On 14 Jan 2013, at 05:31, Aleksandra Vuckovic wrote:
> 
>> Dear Arno,
>> 
>> Thank you very much for the code, it works but I am getting linear frequencies and logarithmic plot. When I compare ERSP figure with the one from GUI, they look the same (apart that values  for p>0.05 are missing) but frequency scales are different. I tired recalculating log10 but frequencies do no match.
>> 
>> I also tired replacing ‘nomal’ with ‘log’ in
>> 
>>  imagesc(times, freqs, tmpersp); set(gca, 'ydir', 'log'); xlabel('Time (ms)'); ylabel('Frequencies (Hz)'); cbar; % plot ERSP
>> 
>> but it only inverts scale from larger to smaller values
>> 
>> Could you please help me to get the right scale?
>> 
>> Many thanks,
>> 
>> Aleksandra
>> 
>> From: Arnaud Delorme [mailto:arno at ucsd.edu] 
>> Sent: 13 January 2013 15:55
>> To: Aleksandra Vuckovic
>> Cc: eeglab at sccn.ucsd.edu
>> Subject: Re: [Eeglablist] Ploting ONLY stat stignificant ERSP ina study
>> 
>>  
>> Glad to hear that.
>> 
>> Best regards,
>> 
>>  
>> Arno
>> 
>>  
>> On 13 Jan 2013, at 05:13, Aleksandra Vuckovic wrote:
>> 
>> 
>> 
>> 
>> Dear Arno
>> 
>> Thanks a lot I think that is exactly what I was looking for
>> 
>> Best regards
>> 
>> Aleksandra
>> 
>> Sent from my iPhone
>> 
>> 
>> On 13 Jan 2013, at 06:19, "Arnaud Delorme" <arno at ucsd.edu> wrote:
>> 
>>> Dear Aleksandra,
>>> 
>>>  
>>> no that does not change anything. I agree with Makoto that we should find a way to plot difference with baseline in ERSP. It is not too hard from the command line. Afer computing ERSP in the graphic interface for your STUDY, first retrieve ERSP results on one channel.
>>> 
>>>  
>>> [STUDY ersp times freqs ] = std_erspplot(STUDY,ALLEEG,'channels',{'T7'});
>>> 
>>>  
>>> size(ersp{1})
>>> 
>>>  
>>> ans =
>>> 
>>>  
>>>     30    40     1     12
>>> 
>>>  
>>> 30 frequencies, 40 time points, 1 electrode, 12 subjects.
>>> 
>>> Now to compare the baseline to 0, one simple way is to do this is
>>> 
>>>  
>>> % permutation statistics with FDR correction
>>> 
>>> pvals = std_stat({ ersp{1} zeros(size(ersp{1})) }', 'method', 'permutation', 'condstats', 'on', 'correctm', 'fdr');  
>>> 
>>>  
>>> Or
>>> 
>>>  
>>> % permutation statistics with cluster correction (note: use the latest SVN revision of EEGLAB 12)
>>> 
>>> pvals = std_stat({ ersp{1} zeros(size(ersp{1})) }', mode', 'fieldtrip', 'fieldtripmethod', 'montecarlo', 'condstats', 'on', 'fieldtripmcorrect', 'cluster'); 
>>> 
>>>  
>>> Note that only surrogate method is appropriate here (the array containing zeros array has 0 variance so cannot be used in parametric tests).
>>> 
>>> Now plot the ERSP masked for significance.
>>> 
>>>  
>>> tmpersp = mean(ersp{1},4); % average ERSP for all subjects
>>> 
>>> tmpersp(pvals{1} > 0.05) = 0; % zero out non-significant values
>>> 
>>> figure; imagesc(times, freqs, tmpersp); set(gca, 'ydir', 'normal'); xlabel('Time (ms)'); ylabel('Frequencies (Hz)'); cbar; % plot ERSP
>>> 
>>>  
>>> Best,
>>> 
>>>  
>>> Arno
>>> 
>>>  
>>> On 11 Jan 2013, at 04:25, Aleksandra Vuckovic wrote:
>>> 
>>> 
>>> 
>>> 
>>> Dear Makoto,
>>> 
>>> at the moment I am working simply with EEG data not ICA components (though that will be my next step).
>>> 
>>> Does that change anything?
>>> 
>>> Many thanks,
>>> 
>>> Aleksandra
>>> 
>>>  
>>> From: Makoto Miyakoshi [mmiyakoshi at ucsd.edu]
>>> Sent: 10 January 2013 23:12
>>> To: Aleksandra Vuckovic
>>> Cc: eeglablist at sccn.ucsd.edu; Muhammad Hasan; Arnaud Delorme; Scott Makeig
>>> Subject: Re: [Eeglablist] Ploting ONLY stat stignificant ERSP ina study
>>> 
>>> Dear Aleksandra,
>>> 
>>>  
>>> So you want to show simple effect of ERSP results after significance masking. Actually it is not possible for the current STUDY scheme (!) which is a shame. You need to write a code to extract those values from STUDY.cluster(1,x).icaersp. Type 'help std_readersp' and read the help for a start.
>>> 
>>> I strongly believe that this should be doable, so I cc this to Arno and Scott to draw their attention.
>>> 
>>> 
>>> Makoto
>>> 
>>> 2013/1/4 Aleksandra Vuckovic <Aleksandra.Vuckovic at glasgow.ac.uk>
>>> 
>>> Hi,
>>> 
>>> how can I plot only statistically significant ERSP (let's say p<0.05) in a study, in the same way as it can be plotted for a single subject? Currently I can only plot a separate figure with an area of statistically significant difference between two groups rather than statistically significant ERSP of a single group/single condition.
>>> 
>>> Many thanks,
>>> 
>>> Alex
>>> 
>>> 
>>> _______________________________________________
>>> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
>>> To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu
>>> For digest mode, send an email with the subject "set digest mime" to eeglablist-request at sccn.ucsd.edu
>>> 
>>> 
>>> 
>>> 
>>>  
>>> -- 
>>> Makoto Miyakoshi
>>> JSPS Postdoctral Fellow for Research Abroad
>>> Swartz Center for Computational Neuroscience
>>> Institute for Neural Computation, University of California San Diego
>>> 
>>>  
>> 
>>  
> 
> 
> _______________________________________________
> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu
> For digest mode, send an email with the subject "set digest mime" to eeglablist-request at sccn.ucsd.edu
> 
> 
> 
> -- 
> 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/20130819/b519b16f/attachment.html>


More information about the eeglablist mailing list