<div dir="ltr"><div dir="ltr">Dear Mohith,<div><br></div><div>Oops, I pasted a wrong one. Here is the right version, sorry for confusion. Please discard the last one and use this one. Note the second input arguments to spectrogram() is EEG.srate which means 1-s sliding window is being used.</div><div><br></div><div>Makoto</div><div><br></div><div><br></div><div><br></div><div><div>% Define the freq bins.</div><div>freqBins = 1:0.01:40;</div><div><br></div><div>% Create an empty PSD tensor (time & freq & IC).</div><div>PSD_tensor = [];</div><div><br></div><div>% Compute the PSD tensor.</div><div>for icIdx = 1:size(EEG.icaact,1)</div><div>    </div><div>    % Compute short-term Fourier Transform for 1-s window, 1-50 Hz, 0.1 Hz bin.</div><div>    if icIdx == 1;</div><div>        [~, freqs, times, firstPSD]      = spectrogram(EEG.icaact(icIdx,:), EEG.srate, round(EEG.srate/2), freqBins, EEG.srate);</div><div>        PSD_tensor = zeros(length(freqs), size(firstPSD,2), size(EEG.icaact,1));</div><div>        PSD_tensor(:,:,icIdx) = firstPSD;</div><div>    else</div><div>        [~, ~, ~, PSD_tensor(:,:,icIdx)] = spectrogram(EEG.icaact(icIdx,:), EEG.srate, round(EEG.srate/2), freqBins, EEG.srate);</div><div>    end</div><div>end</div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jan 10, 2019 at 6:53 PM Makoto Miyakoshi <<a href="mailto:mmiyakoshi@ucsd.edu">mmiyakoshi@ucsd.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Dear Mohith,<div><br></div><div>See my latest response to Panos (pasted below).</div><div>In EEGLAB, your time-series data are stored under EEG.data as channels x time. So, if you want to use spectrogram(), it will be something like this...see below. This is from my recent work so it works. Note I'm working on EEG.icaact which is one of ICA's results. Replace it with EEG.data if you want to work on sensor level.</div><div><br></div><div><div>Makoto</div><div><br></div><div><br></div><div><br></div><div>% Define the freq bins.</div><div>freqBins = 1:0.01:50;</div><div><br></div><div>% Create an empty PSD tensor (time & freq & IC).</div><div>PSD_tensor = [];</div><div><br></div><div>% Compute the PSD tensor.</div><div>for icIdx = 1:size(EEG.icaact,1)</div><div>    </div><div>    % Compute short-term Fourier Transform for 1-s window, 1-50 Hz, 0.1 Hz bin.</div><div>    if icIdx == 1;</div><div>        [~, freqs, times, firstPSD]      = spectrogram(EEG.icaact(icIdx,:), ceil(EEG.xmax), [], freqBins, EEG.srate);</div><div>        PSD_tensor = zeros(length(freqs), size(firstPSD,2), size(EEG.icaact,1));</div><div>        PSD_tensor(:,:,icIdx) = firstPSD;</div><div>    else</div><div>        [~, ~, ~, PSD_tensor(:,:,icIdx)] = spectrogram(EEG.icaact(icIdx,:), ceil(EEG.xmax), [], freqBins, EEG.srate);</div><div>    end</div><div>end</div><div><br></div><div>Makoto<br></div></div><div><br><br><br><div class="gmail_quote"><div dir="ltr">On Thu, Jan 10, 2019 at 3:57 PM Makoto Miyakoshi <<a href="mailto:mmiyakoshi@ucsd.edu" target="_blank">mmiyakoshi@ucsd.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">Dear Panos,<div><br></div>> 1) In addition to calculating the average absolute power (as your script nicely shows), I was also interested in calculating the average absolute (and relative) power at binned time intervals (e.g. avg power between 0-1sec, avg power between 1-2sec, etc) within the dataset. I tried to use the "spectra" output from spectopo but from what I gather it comes up with [(sampling rate)/2 + 1] points rather that one power-spectral point per timepoint. How would you recommend that I proceed?  <br><br>You can repeatedly apply EEGLAB spectopo() function to perform hand-made short-term Fourier transform (STFT), but alternatively you might want to use either EEGLAB newtimef() or Matlab spectrogram() function (the latter may require some additional Toolbox). The output will be frequency x time matrix. The interval of time bins needs to be calcualted. Basically, {(length of data) - (sliding window length)}/(number of steps) gives you the interval (step size). Adjust the (number of steps) so that you can obtain the desired interval. </div><div dir="ltr"><br></div><div dir="ltr">> 2) Is there a way to display how do topographic maps (scalp heat maps) change with time (I'm able to see how they change with different frequencies but I was interested in seeing how they also change with time)? Would the function timtopo be the best way to do that?<br><br>See this wiki page.<br><a href="https://sccn.ucsd.edu/wiki/Chapter_02:_Writing_EEGLAB_Scripts#Creating_a_scalp_map_animation" target="_blank">https://sccn.ucsd.edu/wiki/Chapter_02:_Writing_EEGLAB_Scripts#Creating_a_scalp_map_animation</a><br><br>> 3) A more general question:  If I write a matlab script that I would like to apply on a bunch of datasets (which in my case are just epochs of different lengths that I have extracted from my original dataset), should I put all said datasets  (which I have already pre-processed and applied ICA on) in a STUDY set and then apply the script there, or should I just write a for loop in matlab and apply the script in each individual dataset? In other words, does the STUDY set offer an advantage in this case?  (I apologize for the potential triviality of this one!)</div><div dir="ltr"><br></div><div>If you are a beginner, it is always a good idea to make things as simple as possible. I recommend you organize your own code to loop the single-subject process for all the subjects. After all, that's the only to learn the process!</div><div dir="ltr"><br></div><div>Makoto</div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jan 9, 2019 at 11:47 AM Fotiadis, Panagiotis <<a href="mailto:Panagiotis.Fotiadis@pennmedicine.upenn.edu" target="_blank">Panagiotis.Fotiadis@pennmedicine.upenn.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div id="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,Helvetica,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols"><div id="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308divtagdefaultwrapper" dir="ltr" style="font-size:12pt"><p style="margin-top:0px;margin-bottom:0px">Hi Makoto,</p><p style="margin-top:0px;margin-bottom:0px"><br></p><p style="margin-top:0px;margin-bottom:0px">Thank you for the really great advice! The two links you provided are extremely helpful.</p><p style="margin-top:0px;margin-bottom:0px"><br></p><p style="margin-top:0px;margin-bottom:0px">I had a few follow-up questions:</p><p style="margin-top:0px;margin-bottom:0px">1) In addition to calculating the average absolute power (as your script nicely shows), I was also interested in calculating the average absolute (and relative) power at binned time intervals (e.g. avg power between 0-1sec, avg power between 1-2sec, etc) within the dataset. I tried to use the "spectra" output from spectopo but from what I gather it comes up with [(sampling rate)/2 + 1] points rather that one power-spectral point per timepoint. How would you recommend that I proceed?  </p><p style="margin-top:0px;margin-bottom:0px"></p><p style="margin-top:0px;margin-bottom:0px"><br></p><p style="margin-top:0px;margin-bottom:0px">2) Is there a way to display how do topographic maps (scalp heat maps) change with time (I'm able to see how they change with different frequencies but I was interested in seeing how they also change with time)? Would the function timtopo be the best way to do that?</p><p style="margin-top:0px;margin-bottom:0px"><br></p><p style="margin-top:0px;margin-bottom:0px">3) A more general question:  If I write a matlab script that I would like to apply on a bunch of datasets (which in my case are just epochs of different lengths that I have extracted from my original dataset), should I put all said datasets  (which I have already pre-processed and applied ICA on) in a STUDY set and then apply the script there, or should I just write a for loop in matlab and apply the script in each individual dataset? In other words, does the STUDY set offer an advantage in this case?  <span style="font-size:12pt">(I apologize for the potential triviality of this one!)</span></p><p style="margin-top:0px;margin-bottom:0px"><br></p><p style="margin-top:0px;margin-bottom:0px">Thank you again in advance for your time and help!</p><p style="margin-top:0px;margin-bottom:0px"><br></p><p style="margin-top:0px;margin-bottom:0px">Best,</p><p style="margin-top:0px;margin-bottom:0px">Panos</p><p style="margin-top:0px;margin-bottom:0px"><br></p><div id="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308Signature"><div id="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308divtagdefaultwrapper" dir="ltr" style="font-size:12pt"><p style="margin-top:0px;margin-bottom:0px">Panagiotis Fotiadis</p><p style="margin-top:0px;margin-bottom:0px">PhD Student | Neuroscience Graduate Group</p><p style="margin-top:0px;margin-bottom:0px"><span style="font-size:12pt">Perelman School of Medicine, University of Pennsylvania</span><br></p></div></div></div><hr style="display:inline-block;width:640.875px"><div id="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Makoto Miyakoshi <<a href="mailto:mmiyakoshi@ucsd.edu" target="_blank">mmiyakoshi@ucsd.edu</a>><br><b>Sent:</b> Monday, January 7, 2019 2:48:37 PM<br><b>To:</b> Fotiadis, Panagiotis<br><b>Cc:</b> <a href="mailto:eeglablist@sccn.ucsd.edu" target="_blank">eeglablist@sccn.ucsd.edu</a><br><b>Subject:</b> [External] Re: [Eeglablist] Frequency-time spectrogram deconstruction</font><div> </div></div><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Dear Panos,<br><br>Welcome to the time-frequency world.<br><br>> Would I just need to bandpass filter my post-processed EEG signal to each frequency range of interest (i.e., alpha: 8-12Hz etc) and then plot the remaining EEG signal over time, or is there another way to do this?<br><div><br></div><div>That's one way to go. Nothing is wrong with that!</div><div><br></div><div>More convenient and established way to go is to perform time-frequency transform using short-term Fourier transform or Wavelet transform. Google EEGLAB time-frequency and you'll find many of our past workshop materials. For example, see Slide 21 of this file</div><div><a href="https://sccn.ucsd.edu/mediawiki/images/a/a6/C2_A3_Time-frequencyDecAndAdvancedICAPracticum_updateJan2017.pdf" id="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308LPlnk215353" class="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308OWAAutoLink" target="_blank">https://sccn.ucsd.edu/mediawiki/images/a/a6/C2_A3_Time-frequencyDecAndAdvancedICAPracticum_updateJan2017.pdf</a><br></div><div><br></div><div>You can also obtain bin-mean values from power spectral density. See below. </div><div><a href="https://sccn.ucsd.edu/wiki/Makoto's_useful_EEGLAB_code#How_to_extract_EEG_power_of_frequency_bands" id="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308LPlnk70051" class="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308OWAAutoLink" target="_blank">https://sccn.ucsd.edu/wiki/Makoto's_useful_EEGLAB_code#How_to_extract_EEG_power_of_frequency_bands</a><br></div></div></div><div dir="ltr"><br></div><div>Makoto</div><br><div class="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308x_gmail_quote"><div dir="ltr">On Mon, Jan 7, 2019 at 1:34 AM Fotiadis, Panagiotis <<a href="mailto:Panagiotis.Fotiadis@pennmedicine.upenn.edu" id="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308LPlnk798308" class="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308OWAAutoLink" target="_blank">Panagiotis.Fotiadis@pennmedicine.upenn.edu</a>> wrote:<br></div><blockquote class="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308x_gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div id="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308x_gmail-m_-5825005070605991825divtagdefaultwrapper" dir="ltr" style="font-size:12pt"><p style="margin-top:0px;margin-bottom:0px">Hello,</p><p style="margin-top:0px;margin-bottom:0px"><br></p><p style="margin-top:0px;margin-bottom:0px">I am fairly new to EEGLab and I had a question concerning the deconstruction of my EEG signal into its alpha/beta/theta/delta sub-components:</p><p style="margin-top:0px;margin-bottom:0px"><br></p><p style="margin-top:0px;margin-bottom:0px">After pre-processing some subjects with EEG data from 128 channels and performing ICA (using runica), I used eeglab and chronux to plot the power/frequency and frequency/time spectrograms of several epochs of interest. </p><p style="margin-top:0px;margin-bottom:0px"><br></p><p style="margin-top:0px;margin-bottom:0px">Is there a way to extract the alpha/beta/theta/delta frequencies of those epochs and quantify when they occur in time? I can visualize when each type of neuronal oscillation occurs by looking at the overall frequency/time spectrogram, but I was wondering whether there was a more robust way to actually plot each type of oscillation separately and/or quantify when it occurs.</p><p style="margin-top:0px;margin-bottom:0px"><br></p><p style="margin-top:0px;margin-bottom:0px">Would I just need to bandpass filter my post-processed EEG signal to each frequency range of interest (i.e., alpha: 8-12Hz etc) and then plot the remaining EEG signal over time, or is there another way to do this?</p><p style="margin-top:0px;margin-bottom:0px"><br></p><p style="margin-top:0px;margin-bottom:0px">Thank you in advance!</p><p style="margin-top:0px;margin-bottom:0px"><br></p><p style="margin-top:0px;margin-bottom:0px">Best,</p><p style="margin-top:0px;margin-bottom:0px">Panos</p></div></div>_______________________________________________<br>Eeglablist page: <a href="http://sccn.ucsd.edu/eeglab/eeglabmail.html" rel="noreferrer" id="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308LPlnk195671" class="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308OWAAutoLink" target="_blank">http://sccn.ucsd.edu/eeglab/eeglabmail.html</a><br>To unsubscribe, send an empty email to <a href="mailto:eeglablist-unsubscribe@sccn.ucsd.edu" id="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308LPlnk555489" class="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308OWAAutoLink" target="_blank">eeglablist-unsubscribe@sccn.ucsd.edu</a><br>For digest mode, send an email with the subject "set digest mime" to <a href="mailto:eeglablist-request@sccn.ucsd.edu" id="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308LPlnk881449" class="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308OWAAutoLink" target="_blank">eeglablist-request@sccn.ucsd.edu</a></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail-m_-6369755040534945308x_gmail_signature"><div dir="ltr">Makoto Miyakoshi<br>Swartz Center for Computational Neuroscience<br>Institute for Neural Computation, University of California San Diego<br></div></div></div></div></div></div></div></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_2141832489320766889gmail-m_1449681728198328185gmail_signature"><div dir="ltr">Makoto Miyakoshi<br>Swartz Center for Computational Neuroscience<br>Institute for Neural Computation, University of California San Diego<br></div></div></div></div></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_2141832489320766889gmail_signature"><div dir="ltr">Makoto Miyakoshi<br>Swartz Center for Computational Neuroscience<br>Institute for Neural Computation, University of California San Diego</div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jan 10, 2019 at 6:34 PM VARMA, MOHITH MUKUND <<a href="mailto:mohith96@connect.hku.hk" target="_blank">mohith96@connect.hku.hk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:"times new roman",serif">Dear all,</div><div class="gmail_default" style="font-family:"times new roman",serif"><br></div><div class="gmail_default" style="font-family:"times new roman",serif">I am trying to conduct PSD (Power Spectrum Density) analysis for each of the sleep stages across different frequency bands. I have scored the PSG data (edf format) on a Python toolbox called Sleep and obtained the hypnogram that I can use as time codes for each sleep stage. I imported this time code file as event file (it contains info on the latency and type of sleep stage) and now the thing I am stuck on is how to run PSD (possibly using spectopo) for the same event type across different frequency band. I think I cannot use the GUI to run this part so your help for setting up the parameters in the MATLAB command would be really helpful! My data's sampling rate is 250 Hz and FFT window size is 4 sec and other paramters I can go with the default settings provided by EEGLAB. I hope my question is clear enough, please let me know if you need further information.</div><div class="gmail_default" style="font-family:"times new roman",serif"><br></div><div class="gmail_default" style="font-family:"times new roman",serif">Regards,</div><div><br></div>-- <br><div dir="ltr" class="gmail-m_2141832489320766889gmail-m_-1075115558834025466gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><font size="2" face="times new roman, serif">Mohith M. Varma (Mo)</font></div><div><span style="font-family:"times new roman",serif;font-size:small">Graduate Research Assistant</span><br></div><div><font size="2" face="times new roman, serif"><br></font></div><div><font size="2" face="times new roman, serif">Social & Cognitive Neuroscience Laboratory</font></div><div><span style="font-family:"times new roman",serif;font-size:small">Department of Psychology</span></div><div><font size="2" face="times new roman, serif">Faculty of Social Sciences</font></div><div><font size="2" face="times new roman, serif">The University of Hong Kong</font></div><div><font size="2" face="times new roman, serif">Tel: (+852) 52622875</font></div><div><font size="2" face="times new roman, serif">Email: <a href="mailto:mohith96@connect.hku.hk" target="_blank">mohith96@connect.hku.hk<br></a></font></div><div style="font-size:small"></div></div></div></div></div></div></div></div>
_______________________________________________<br>
Eeglablist page: <a href="http://sccn.ucsd.edu/eeglab/eeglabmail.html" rel="noreferrer" target="_blank">http://sccn.ucsd.edu/eeglab/eeglabmail.html</a><br>
To unsubscribe, send an empty email to <a href="mailto:eeglablist-unsubscribe@sccn.ucsd.edu" target="_blank">eeglablist-unsubscribe@sccn.ucsd.edu</a><br>
For digest mode, send an email with the subject "set digest mime" to <a href="mailto:eeglablist-request@sccn.ucsd.edu" target="_blank">eeglablist-request@sccn.ucsd.edu</a></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_2141832489320766889gmail_signature"><div dir="ltr">Makoto Miyakoshi<br>Swartz Center for Computational Neuroscience<br>Institute for Neural Computation, University of California San Diego<br></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Makoto Miyakoshi<br>Swartz Center for Computational Neuroscience<br>Institute for Neural Computation, University of California San Diego<br></div></div>