[Eeglablist] plotting and calculating stats on study difference waves

Hamish INNES-BROWN HINNES-BROWN at bionicsinstitute.org
Tue Jun 28 16:47:05 PDT 2011


Hi Alexandre, I have thought about using ERPLAB, but as you say, the group analysis/stats is much better in EEGLAB, as long as you don't need to do any subtractions...  In ERPLAB, as far as I can see the subtraction is handled easily, but then you need to do the stats and plotting externally anyway (back in matlab, or SPSS, signaplot etc), so I figured it would be easier just to do the subtraction in matlab/EEGLAB anyway, and then figure out how to send the results to the EEGLAB plotting and stats functions.

I have a solution, but it's not very elegant. I have four conditions (A1 A2 B1 B2), and want to calculate DIFF1 = A2 - A1, and DIFF2 = B2 - B1, and then do plots and stats on DIFF1 vs DIFF2

1) Proceed as if making an "old-style" (before the STUDY.design feature) study. IE epochs for each condition are saved in separate .set files.
2) Loop though all the set files, making an EEG.erp variable, which is  mean(EEG.data, 3).  You might need to make that double(mean(EEG.data,3)) if you have previously used the option to use single precision only in the options.eeg file.
3) Now you have an ERP in each set file, one for each subject and condition.
4) Now make separate STUDYs for A1 and A2, and B1 and B2 (2 studies, with 2 conditions in each - STUDYA and STUDYB).  Then if you like you can get plots and stats of A1 vs A2 and B1 vs B2.

5) Load STUDYA, and make a loop doing the subtraction as follows:

>	for ss = 1:length(STUDY.subject)
>		erp_DIFFA(:,:,ss) = EEG(ss*2).erp  - EEG((ss*2)-1).erp;
>	end

This will subtract all the odd (which should be A1) from even (A2) ERPs you previously made.  

6) Do the same for STUDYB

You then have a matrix (time, chans, subjects) for DIFFA and DIFFB.  To get the grand average you just get the mean across the third dimension.

DIFFA (time, chans, ss)
DIFFB (time, chans, ss)

> GAVG_A = mean(DIFFA, 3);
> GAVG_B = mean(DIFFB, 3);


7) Then to get the nice plots and stats from the STD functions is a bit tricky. You no longer have these DIFF waves in the STUDY structure, so you cannot use the GUI, and have to fiddle around to get the data in a format that the STD functions like.  I have only just worked this out so some things could be wrong, but what I have done is set up DIFFA and DIFFB in a cell array like this:

> erpdata  = {DIFFA;  DIFFB};

Then I have used  
> pvals = std_stat(erpdata, 'option', 'value');   to calculate stats between DIFFA and DIFFB.

The you feed those pvals into the plotting function:
> std_plotcurve(times, erpdata, 'condstats', pvals, 'endless', 'options', 'go', 'here');

And if you give that the right options and channel locations, you will get a head-shaped plot of your XX channels, with two lines per plot (one for each difference wave), and the grey boxes indicating the significant differences.


I hope that is of some help, however I suspect some of the more experienced users might be cringing at this, it's probably not the most efficient way...   Probably there is a way to use STUDY.design for instance.

-hamish-





-----Original Message-----
From: alexandre.lehmann at gmail.com [mailto:alexandre.lehmann at gmail.com] On Behalf Of Alexandre Lehmann
Sent: Tuesday, 28 June 2011 1:59 AM
To: Hamish INNES-BROWN
Subject: Re: [Eeglablist] plotting and calculating stats on study difference waves

Hello Hamish,

I also have trouble comparing difference waves, I couldn't find any clean way to do it.
I am now trying to do it with ERPLAB which easily allows to compute and plot difference waves.
http://www.erpinfo.org/erplab/erplab-documentation/erplab-manual/Bin_Operations.htm

What I haven't found out yet is whether it offers the same powerful group analysis as the STUDY does.

Looking forward to knowing if you found another more practical solution,

Regards

--
Alexandre Lehmann, Phd
Postdoctoral research fellow
Laboratory for Brain, Music & Sound Research BRAMS - Université de Montréal Pavillon 1420 boul. Mont Royal Case Postale 6128, Station Centre-Ville Montreal (QC)  H3C 3J7


On Sun, Jun 19, 2011 at 9:13 PM, Hamish INNES-BROWN
<HINNES-BROWN at bionicsinstitute.org> wrote:
> Sorry for re-posting but I realised the last time I posted this in HTML format and it got scrubbed..
>
>
> Hello again, I have recently been working with two STUDYs (12 subjects, two conditions in each study) in which I have calculated some new data for each participant and condition (MGFP), as well as calculated a difference ERP and difference MGFP between the two conditions.
>
> So I have:
> STUDY1 - cond1 & cond2, calculated DIFF1
> STUDY2 - cond3 & cond4, calculated DIFF2
>
> My general approach has been
> 1.      Load STUDY 1 and calculate the ERP for each condition (I have actually done this by looping through an EEG(x).erp variable I inserted earlier, though I now realise I could have got the same info more easily from STUDY.changrp.erpdata)
> 2.      Do the subtraction DIFF1 = ERPcond2 - ERPcond1
> 3.      Load STUDY 2 and do the same
>
> I'm then left with DIFF1 and DIFF2 (each 60 elecs x 500 pts x 12 ss)
>
> What I'd like to do is use the std_erpplot function to plot, compare and do the stats on these two new waves, but I don't have the a whole new 'STUDY' structure to go with them. Looking at the the help for std_erpplot it looks like you do need a STUDY as an input.
>
> I then had a look through std_erpplot.m to see if I could find an internal plotting function that could work with a [elecs, points, ss] matrix,  and I found std_plotcurve. Am I heading in the right direction?
>
>
>
>
>
>
> Hamish Innes-Brown
> Research Assistant
> The Bionics Institute of Australia
>
> t: +61 3 9667 7529
> f: +61 3 9667 7518
> e: hinnes-brown at bionicsinstitute.org
> w: http://www.bionicsinstitute.org/profiles/HamishInnes-Brown.html
> w2: http://musicalbionics.wordpress.com/
>
> 2nd International Medical Bionics Conference, Phillip Island, 20-23 Nov 2011
> http://www.iceaustralia.com/medicalbionics2011/
>
>
> _______________________________________________
> 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
>




More information about the eeglablist mailing list