# [Eeglablist] Calculating Alpha Asymmetry

Tarik S Bel-Bahar tarikbelbahar at gmail.com
Fri Jan 6 23:14:33 PST 2012

```some sample code that might help below, from the searchable EEGLAB list
archive

[spec439 frq439] = spectopo (EEG.data, 250, 250, 'overlap', 125,
'winsize', 250,'plot', 'off', 'chanlocs', 'GSN129.sfp');
xlswrite('spec439.xls', spec439(:,1:256));
xlswrite('frq439.xls', frq439);

or

left= 24;
right = 25;
[spec_24 freqs ] = spectopo(EEG.data(right,:), 250, 250, 'plot', 'off')
[spec_25 freqs ] = spectopo(EEG.data(left,:), 250, 250, 'plot', 'off')
[tmp alpha_ind] = min( abs(freqs-8));
asymmetry1 = spec_24(alpha_ind) - spec_25(alpha_ind);
asymmetry2 = spec_25(alpha_ind) - spec_24(alpha_ind);
f439= fopen('439.xls', 'w+');
dlmwrite('439.xls', asymmetry1);

On Fri, Jan 6, 2012 at 8:24 PM, Arnaud Delorme <arno at ucsd.edu> wrote:

> Dear Kathryn and Andero,
>
> the eeg_regepochs is the command line function you want to use to epoch
> the data into regular (possibly overlapping) segments. For example
>
> EEG = eeg_regepochs(EEG, 'recurrence', 1, 'limits', [0 2]);
>
> Then you may go back to the EEGLAB interface using the code
>
> [ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET);
> eeglab redraw
>
> Note that this function can also be used to insert events without
> extracting epochs. We will try to make a menu for it.
> Best regards,
>
> Arno
>
> On Jan 5, 2012, at 6:24 AM, Andero Uusberg wrote:
>
> >
> > Dear Kathryn,
> >
> > all of your pipeline can be done in EEGLAB, but a few steps require
> > using Matlab command line interface.
> >
> > For the segmentation of data EEGLAB has a function called
> > pop_importevent which does what the name suggests and thus allows you to
> > import event-markers for the 2-second epochs you'll need. As I'm not
> > quite sure how the function would cope with overlapping segments, I've
> > created non-overlapping ones at this phase and asked the spectral
> > analysis function pop_spectopo to apply overlapping during subsequent
> >
> > Here is a piece of code that adds 2-second event-markers to a loaded
> > EEGLAB dataset.
> > dur = 2; % the required duration of the new events
> > name = 'M'; % name of the new events that appears in EEGLAB scroll plot
> > newEvent = {name 0 dur}; % initiate the new event list (see help
> > pop_importevent for details)
> > % the following loop will populate the list with required information
> > for k = 2:round((EEG.xmax-dur)/dur) % the loop runs until the end of the
> >     newEvent = cat(1, newEvent, {name newEvent{k-1,2}+dur dur}); %
> > specs of one event are added on each run of the loop
> > end
> > EEG = pop_importevent( EEG, 'event','externalEvent','fields',{'type'
> > 'latency' 'duration'},'timeunit',1,'optimalign','off'); % import the
> > created event list to the loaded dataset
> > eeglab redraw % update the GUI to reflect the command line changes
> >
> > After running this code you can use the GUI-based tool to actually
> > segment the data (Tools -> Extract epochs).
> >
> > The FFT can be calculated by the pop_spectopo function (Plot -> Plot
> > channel spectra and maps). See help pop_spectopo to learn how to tell
> > the algorithm to use overlapping in FFT calculations as well as which
> > kind of windowing to use.
> >
> > Finally, you'll need to turn to the command-line again to perform the
> > subtraction of right and left power estimates. One way to do this
> > involves adding output variables to the pop_spectopo or spectopo
> > function (again, see help) and then performing the subtraction  on this
> > output. With some struggling the subtracted data can then be plotted
> > using EEGLAB or Matlab tools (e.g. plot) and exported (e.g. xlswrite).
> >
> > Regards,
> > Andero Uusberg
> > Tartu, Estonia
> >
> >
> > On 19.12.2011 3:51, Campbell, Kathryn wrote:
> >> Hi,
> >>
> >> any that answer all of my questions. I am completely new to using MATLAB
> >> and EEGLAB and am a bit overwhelmed.
> >>
> >> The steps I have taken in the past to calculate alpha asymmetry were
> >>
> >> 1)Segment continuous EEG data into 4 one minute blocks based on events
> >> markers
> >>
> >> 2)For each block create a series of 2.048 second epochs overlapping by
> 50%
> >>
> >> 3)Reject epochs with ocular or other artefacts (either manually or
> >> automatically)
> >>
> >> 4)Calculate mean alpha power at each electrode site for each block using
> >> FFT with Hanning window.
> >>
> >> 5)Use these figures to calculate alpha asymmetry (1n (R/L)
> >>
> >> Unfortunately the system I now use to record EEG ( a very old version of
> >> neuroscan) doesn’t seem have all of these functions available.
> >>
> >> I am able to complete the first step using EEG lab but can’t find a way
> >> to create overlapping epochs to move on to the next steps.
> >>
> >> Is anyone able to help me? Please bear in mind I’m not that familiar
> >> with MATLAB.
> >>
> >> Thanks
> >>
> >> Kathryn
> >>
> >>
> >>
> >> _______________________________________________
> >> 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
> >
> >
> >
> >
> > _______________________________________________
> > 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
>
>
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20120106/ae0dc4e2/attachment.html
```