[Eeglablist] Root mean square (rmsave) to calculate sleep spindle power from the EEG dataset

VARMA, MOHITH MUKUND mohith96 at connect.hku.hk
Wed Feb 27 01:20:08 PST 2019


Dear Arno,

I tried adapting your code for my dataset. However, I would prefer to first
detect the SOs (similar to setting the parameters in the GUI provided by
the detectevent plugin for sleep spindles) on each EEG dataset and then run
PSD analyses. The reason for doing so is because we plan to conduct some
exploratory analyses on the frequency and density of SOs and spindles
within the N2 and N3 sleep stages as well so it would be better if first I
detect the SOs in the dataset along with their duration and negative peak.

In the case of running sleep spindle PSD analysis (i.e. after performing
the sleep detection), I adopt a similar strategy. However, I noticed that
when I used the following code to generate the power spectra plot and
absolute power within the sigma (11-16 Hz) band, I get a negative log
transformed PSD distribution plots for my datasets. Is it because of the
prior bandpass filtering I do before spindle detection? The reason I do
such filtering is because I want the spindles to be detected within the
sigma band (based on the criteria set in the pop_detectevent). If I don't
do such filtering and run detectevent plugin, then I end up with more
detected spindles which could be from other frequency bands (that reminds
me to ask you, is it also possible to get information about the mean
frequency and amplitude of the detected spindle from the detectevent
plugin; this could be a way for me to cross-check that the detected
spindles are within the sigma band).
But not using the filter prior to spindle detection, produces positive log
transformed power values within the sigma band. So I am unclear as to why
filtering the dataset within the sigma band is giving me negative power
values.
Following is the code snippet from my script:

%% SPINDLE DETECTION AND PSD
        EEG = pop_loadset([subject '_N2_N3_COMBINED.set']);

        EEG.setname = [subject '_spindle'];

        EEG = pop_basicfilter( EEG,  1:10 , 'Boundary', 'boundary',
'Cutoff', [ 11 16], 'Design', 'butter', 'Filter', 'bandpass', 'Order',  2 );

        EEG = pop_detectevent(EEG);

        figure; [power_spindle{s}, freq_spindle{s}] =
spectopo(EEG.data(3:6, :), 0, 250, 'freqrange', [0 25], 'title', [subject
'_spindle'], 'freqfac', 2);

        %average power within the predefined frequency range
        meanPower_spindle{s} = mean(10.^(power_spindle{s}(freq_spindle{s}
>= 11 & freq_spindle{s} <= 16)/10));

I am using the spectopo function to calculate the power so is it that the
plot I see shows me the relative power (which I read in some papers could
be negative for sleep spindles; reference the 2017 Nature Communications
paper by Purcell and colleagues on sleep spindles) or is there something
wrong with my codes? Please note that when I calculate absolute power, the
value is positive but they are in the range of 0 (e.g. 0.02, 0.5 etc.)
which is weird because its not the typical score range of other sleep
spindle power studies. Your help is once again very much appreciated. I
will also cc: this mail to Eeglablist as well since I raise multiple issues
dealing with spindles, SO, PSD, and filtering in this email and some may
find it relevant to their research and help me solve these issues.

Regards,

On Wed, Feb 27, 2019 at 12:01 PM Arnaud Delorme <arno at ucsd.edu> wrote:

> Dear Mo,
>
> Yes, I think the plugin could do that with a function that computes power
> (instead of RMS over a window, it could compute power in that window and
> return power of the SO). I guess a simple wrapper on the spectopo function
> (disabling plotting) or even using Matlab FFT function would do. Something
> like
>
> function soPower = detectso(data)
>
> srate = 256;
> soFreq = 1;
>
> data = data .* hanning(length(data));
> data = fft(data);
> f     = linspace(0, srate/2, floor(length(data)/2));
> [~,ind] = min( abs(f-soFreq));
> soPower = data(ind)*conj(data(ind));
>
> Let me know if it works for you.
>
> Cheers,
>
> Arno
>
> > On Feb 26, 2019, at 7:46 PM, VARMA, MOHITH MUKUND <
> mohith96 at connect.hku.hk> wrote:
> >
> > Dear Arno,
> >
> > Thanks a lot with the help and providing the plugin for spindle
> detection! Since, I am also doing some slow oscillation (SO) power
> analysis, I wonder is there plugin or EEGLAB function to detect
> positive-to-negative crossings of EEG data points in order to mark SO
> events in the EEG sleep datasets? I am trying to detect SOs in my datasets
> using the criteria reported in the same 2018 Current Biology paper by
> Antony and colleagues (because it seems to be quite a robust and well-cited
> detection algorithm, and if there is an EEGLAB function/plugin based on it
> then that would be great and easy for researchers like me who have to do
> sleep physiology analyses). Currently I am using the fieldtrip z value
> calculations to detect slow oscillations, however, I would prefer to do all
> my analyses using EEGLAB filters and functions.
> >
> > In order to detect SOs first I need to identify successive
> positive-to-negative crossings of EEG data points that last for 0.75 to 2
> seconds. Once I can identify such data points then I think I will be able
> to apply the other two SO classification criteria which are as follows:
> > (a) there needs to be a negative peak of -40 microvolt within these
> series of data points and, (b) a peak-to-peak amplitude of 75 microvolts.
> The part that I am stuck at is detecting these zero crossings so yours or
> the expert researchers in this community help is very much appreciated.
> >
> > Regards,
> >
> > On Sat, Feb 23, 2019 at 5:25 AM Arnaud Delorme <arno at ucsd.edu> wrote:
> > Dear Mo,
> >
> > The function rmsave will not compute a moving average.
> > Try downloading the following plugin to detect spindles and place it in
> the EEGLAB plugin folder
> >
> > https://github.com/arnodelorme/detectevent
> >
> > When plotting the data, you can decide to plot event durations (menu
> Display > Plot event duration)
> >
> > Best wishes,
> >
> > Arno
> >
> > > On Feb 20, 2019, at 7:44 PM, VARMA, MOHITH MUKUND <
> mohith96 at connect.hku.hk> wrote:
> > >
> > > Dear all,
> > >
> > > I am trying to extract the sleep spindle power from my nap EEG
> datasets and I am trying to adopt the methodology adopted by Antony and
> colleagues (2018) in the Current Biology paper on sleep spindle
> refractoriness. Their method of detecting spindles in the raw EEG data and
> the subsequent power analysis involves computing the root mean square (RMS)
> at each time point on a specific channel using a moving window of +/- 0.2
> sec. I am using the rmsave function on EEGLAB to compute the RMS at each
> time point on a channel, however I am not able to implement the moving
> window criteria into my RMS calculation. Your help in debugging this
> problem is very much appreciated. Following is the code snippet:
> > >
> > > EEG = pop_biosig(['ub' subject 'scored.edf']);
> > >
> > > EEG.setname = [subject '_bsd'];
> > >
> > > EEG  = pop_basicfilter( EEG,  1:8 , 'Boundary', 'boundary', 'Cutoff',
> [ 11 16], 'Design', 'butter', 'Filter', 'bandpass', 'Order',  2 ); %filter
> the dataset within 11-16 Hz
> > >
> > > averms = rmsave(EEG.data, 400); %calculate RMS score for each channel
> > >
> > > trans = transpose(averms);
> > >
> > > After I have calculated the RMS scores for each channel separately, I
> want to calculate the spindle threshold criteria by multiplying the
> standard deviation of the entire channel signal (in RMS) to 1.5. I think I
> did this part correctly. However, in order to detect a sleep spindle I have
> a criteria which is that any RMS score that is above the threshold
> consecutively for 0.5 to 3 seconds will be considered as a spindle. I am
> having difficulty in implementing the IF condition for this part along with
> calculating the onset and offset for each detected spindle. Following is
> the remainder code that I have come up with so far:
> > >
> > > threshold = std(trans).* 1.5;
> > >
> > > for s=1:trans(: , 1)
> > >
> > > if s > threshold & %time condition for RMS scores being 0.5 to 3
> seconds
> > >
> > > %here the variable to store each spindle without replacing the
> previous detected one.
> > >
> > > %onset and offset time for the spindle along with its mean frequency
> and positive/negative peaks
> > >
> > > end;
> > >
> > > end;
> > >
> > > Thanks in advance for your help!
> > >
> > > Regards,
> > >
> > > --
> > > Mohith M. Varma (Mo)
> > > Graduate Research Assistant
> > >
> > > Social & Cognitive Neuroscience Laboratory
> > > Department of Psychology
> > > Faculty of Social Sciences
> > > The University of Hong Kong
> > > Tel: (+852) 52622875
> > > Email: mohith96 at connect.hku.hk
> > > _______________________________________________
> > > 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
> >
> >
> > --
> > Mohith M. Varma (Mo)
> > Graduate Research Assistant
> >
> > Social & Cognitive Neuroscience Laboratory
> > Department of Psychology
> > Faculty of Social Sciences
> > The University of Hong Kong
> > Tel: (+852) 52622875
> > Email: mohith96 at connect.hku.hk
>
>

-- 
Mohith M. Varma (Mo)
Graduate Research Assistant

Social & Cognitive Neuroscience Laboratory
Department of Psychology
Faculty of Social Sciences
The University of Hong Kong
Tel: (+852) 52622875
Email: mohith96 at connect.hku.hk


-- 
Mohith M. Varma (Mo)
Graduate Research Assistant

Social & Cognitive Neuroscience Laboratory
Department of Psychology
Faculty of Social Sciences
The University of Hong Kong
Tel: (+852) 52622875
Email: mohith96 at connect.hku.hk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20190227/be5f852a/attachment.html>


More information about the eeglablist mailing list