[Eeglablist] Calculating PSD within scored sleep data

Tarik S Bel-Bahar tarikbelbahar at gmail.com
Tue Mar 5 16:27:01 PST 2019


Hi Mohith, quick notes below, best wishes.


*******************************
Overall, using eegh in the command window and reviewing the output of that
command will help you build your script.
If you haven't had a chance to, check out the eeglab wiki on scripting,
makoto's suggestions list, previous eeglab posts, and the full sequence of
the eeglab tutorial + tutorial data (all googlable),
In your case, it seems all that's needed is a little practice of each step
you want with the eeglab GUI, and then reviewing the eegh output after
doing those successful GUI steps, and then integrating that eegh knowledge
into your script.


Here's some suggestions about what to try before having
REM-only-epoch files/matrices for your spectral metrics computations

*********************************
Break your different conditions (periods of time) into separate files (or
separate duplicate EEG structures in matlab memory)
Do so by making a loop to load your original file
then use the epoching function from eeglab to break the file into REM
periods
and then ...save the file with a new name (like ID_01_REM_epochs.set)

because eeglab normal epoching (I believe) makes epochs of the same length
(it will cut the file into X number of epochs based on the REM event of Y
amount of time for each epoch) you may need to alternatively....

Generate a set of start and end times for each Rem period into a matlab
array,
and then select and save only the eeg data for just those periods, or as
it's own .set file, for spectral computation with spectopo.
These start/end times can be inserted into the eeglab time rejection
function to create new rem-only files.
or used as indices to build new rem-only EEG.data matrices.

*Some details about how to attempt to get and use the eegh information to
build your own version of the times and remove those times
*examine eegh output in command window after successfully rejecting some
time periods manually viewed in eeg plot. You will find the name of the
function used for rejecting time periods, the flags that were on or off,
and the start/end time periods that you selected in the gui.
*so, one would first make a list of start and end times for REM, insert
them into the rejection function correctly, and then save new
files/matrices that are ready for spectral computation












On Tue, Mar 5, 2019 at 5:28 AM VARMA, MOHITH MUKUND <mohith96 at connect.hku.hk>
wrote:

> Dear all:
>
> I am trying to run PSD analysis for each sleep stage within a scored sleep
> data. First of all I import the event file which contains the information
> on the latency for each sleep stage and I notice EEGLAB converts this
> latency information into EEG data points. I would like to run PSD for one
> specific sleep stage while ignoring the channel activity from other stages.
> I am not sure how to implement it using the if else statements. Basically I
> want to tell MATLAB that if the EEG.event.type == REM, then it should run
> PSD only for the data points that fall in the time period which is scored
> as REM. Along with running the PSD analysis, I also want to generate
> separate .set files for each sleep stage. Your help in solving this problem
> is highly appreciated.
>
> Following is the code snippet I have used so far:
>
> EEG = pop_loadset([subject '_filtered.set']);
>
> EEG.setname = [subject '_sleep_stages'];
>
> [EEG, indices] = pop_importevent( EEG, 'event',[subject
> '_event_info.txt'],'fields',{'latency' 'type'},'skipline',1,'timeunit',1);
>
> % Obtain event indices whose 'type' is 'N1, N2, N3, REM, ART'
> allEventTypes = {EEG.event.type}';
> N1 = find(strcmp(allEventTypes, 'N1'));
> N2 = find(strcmp(allEventTypes, 'N2'));
> N3 = find(strcmp(allEventTypes, 'N3'));
> REM = find(strcmp(allEventTypes, 'REM'));
> Art = find(strcmp(allEventTypes, 'Art'));
>
> % if EEG.event.type == 'REM'
>
>          %PSD analysis
>            figure; [power_whole{s}, freq_whole{s}] = spectopo(EEG.data(3:6,
> :), 0, 250, 'freqrange', [0 25],              'title', [subject],
> 'freqfac', 2);
>
> % ifelse EEG.event.type == 'N2'
>
>               %PSD analysis
>            figure; [power_whole{s}, freq_whole{s}] = spectopo(EEG.data(3:6,
> :), 0, 250, 'freqrange', [0 25],              'title', [subject],
> 'freqfac', 2);
>
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20190305/290fe481/attachment.html>


More information about the eeglablist mailing list