Mar 052016

During one EEG recording session, a subject was asked to first meditate by following her breath for 7 minutes, then to start worrying about something for the next 7 minutes. She chose to worry about work. We see in the spectrogram below, around t=420 seconds (7-min), there is a distinct increase in low frequency oscillations at the delta and theta levels.

spectrogram of meditating, then worrying

A spectrogram is in effect a three-dimensional graph: time on the horizontal axis, frequency on the vertical axis and color patches to indicate the amplitude of each frequency component at successive times. Here we see greater intensity (indicated by orange and red color) in the lower frequencies after the 420-second mark.

We can also use radar charts to examine the relative power for each of the five frequency bands. the following two charts apply to the initial 7-minutes of meditating and to the next 7-minutes of worrying.

following breath



What is going on here? Why should the relative delta power be so strong when the subject is worrying? Aren’t delta waves associated with deep sleep?

Before continuing, we should examine the possible effects of certain artifacts in the EEG signal, especially those due to blinking the eyes. Motor impulses to the eye muscles produce electrical signals that are picked up by the EEG sensors, but these signals tell us nothing about activity in the cortex.


One possible explanation of the exceptionally high amplitude of low frequencies is that during the interval of worrying the subject blinked frequently while in the preceding interval of following her breath, she blinked only occasionally.

To explore this further, we made a recording in which another subject (S1) blinked deliberately at a rate of about once every two seconds for 20 seconds. Below are the spectrogram and immediately below it the time series graph of eye blinks. During this 40-second interval of interest, the subject blinked 11 times in 20 seconds.

spectrogram for eye blinks

It is quite clear that eye blinks result in low frequency oscillations that are readily visible in the corresponding spectrogram.

Could it be that our worrying subject was blinking her eyes more frequently during worrying than she was while meditating? Selecting time series plots of eye blinks for intervals of meditating (following the breath) and worrying, we see a distinct difference.

 S3-rec66-following-blink-PSD  S3-rec66-worrying-blink-PSD

This seems to be the most plausible explanation of the high levels of delta oscillations observed: our subject blinked her eyes much more often when worrying than when meditating. These signals probably originated in eye muscles rather than in neurons in the brain.

Jan 272016

With new graphing tools available in the Physiology Viewer 2.0, previous recordings can be reexamined and studied in more detail.

September 10, 2015 was the 5th day of a 7-day sesshin (meditation retreat) at Tahoma Monastery. At the end of the day, after the last round of formal meditation, I recorded my brainwaves, as I did each day of the retreat.

Below is a graph that was derived from an EEG recording of fifteen minutes of meditation. It shows signal power for beta and gamma frequency bands measured at the left front sensor.

absolute power - full session


We note that for a period of about 400 seconds near the beginning, there is a gradual and relatively uniform increase in beta and gamma power. Let us focus on a region of interest, the interval from 50-450 seconds.

We replot the graph for the region of interest and then label two sub-regions, each two minutes long, “first 2 min” and “4 min later”. The purpose of this is simply to have an earlier and a later region to compare.

absolute power - zoomed in

Characteristics of the two intervals can also be compared by examining the two radar charts below.  In these charts, absolute band power for all four sensors is included.


The signal at the left front sensor is of particular interest as it shows a significant increase in beta and gamma power. The Physiology Viewer, shown below provides new ways of examining the data. In particular, a spectrogram and a Power Spectral Density (PSD) graph are part of the suite data visualization tools.

Physiology Viewer 2.0


We have chosen to identify two 120-second intervals with the names “zazen – first 2 min” and “zazen – 4 min later”. Selecting these individual intervals allows us to examine the EEG signal in more detail.

A spectrogram is a graph of frequency vs. time. Frequency is plotted on the vertical axis and time along the x-axis.

We select the Spectrogram for the left front sensor (lf) during the entire session. The result is a frequency vs. time graph where the intensity of each frequency is indicated by color. Here, yellow indicates greater intensity than blue. The associated color bar serves as a legend.


Note that during the “first 2 min” interval, there is less yellow in the frequency range from 12-50Hz (and hence, less power in the beta and gamma bands) than there is during the “4 min later” interval.

In addition, a horizontal yellow band runs through the entire session at a frequency value of about 8 Hz. This is in the alpha band. It will be readily apparent when we view these data using PSD graphs.

Note: Regarding the ‘vertical bands’ in the spectrogram, see a later post, Correlations of brain waves with respiration cycle.

Power Spectral Density (PSD) Graph

The PSD graph displays a spectrum of the signal. Frequency (Hz) is plotted on the horizontal axis and intensity of the signal (dB/Hz) on the vertical axis. The graphs below show the spectral composition of the two selected intervals with frequency bands indicated in color.

PSD - first 2 min

PSD - 4 min later

We see clearly how the beta and gamma intensity have increased over the course of a few minutes. While there are several peaks in the beta and gamma bands, it is unclear at this time whether a given peak is characteristic of an individual over a long time, as the alpha peak seems to be, or whether different individuals display commonly identifiable peaks.


Jan 272016

This post is directed to programmers who are interested in seeing the code I’ve written to display graphs. Others may want to skip ahead.

The Physiology Viewer program has undergone a reorganization that makes it faster and more stable. In addition, there are two new features for visualizing signals in the frequency domain: spectrograms and graphs of power spectral density (PSD). Finally, it is now possible to overlay the breath signal over a spectrogram, which provides a new tool for investigating the correlation between brain waves and breath.

Physiology Viewer 2.0 Main tab

The combo box just beneath the title is used to select a particular recording. The text box displays comments referring to that recording.

There are up to four lines to the right of the text box indicating which kind of data was recorded and at what sampling rate (EEG, heart, breath and button press).

The check boxes to the right of Time Series, d, t, a, b, g correspond to the frequency bands delta, theta, alpha, beta and gamma. Data can be displayed either as absolute band power or relative. Median or mean values can be superimposed on the graph as desired.

Check boxes p and v refer to respiration (pressure) and electrocardiogram (voltage) signals. The check box s refers to input from a button device ( a custom current probe connected to the LabQuest logging device).

The letters c and m represent the Concentration and Mellow values that are automatically computed from a Muse proprietary algorithm. Since we don’t know what this algorithm is, I have not used it in my research, but have made it available in case we want to compare our results with these functions later.

Check boxes j and k are used to indicate jaw clench and eye blink events, which are detected by the Muse headband. Jaw clench and eye blinks may be a useful way for subjects to indicate internal mental states.

On the right-hand side is a graphic representing the subject’s head (nose facing upward, ears to the side). The four radio buttons surrounding the head graphic are used to select the sensor of interest.

Clicking on the Display button brings up a graph or chart corresponding to current selection of Time Series, Spectrogram, PSD vs. frequency, Raw EEG, Radar Chart and Table. Checking the Overlay breath check box next to Spectrogram brings up a spectrogram with the breath signal superimposed. The dropdown list box next to Table provides options for mean, median, standard deviation and mean combined with standard deviation.

The rows beneath Intervals, t_initial and t_final can be used to assign arbitrary names to time intervals within the session. Any region of interest can be named. The Save button must be clicked to save these data into the Excel workbook, EEG_CardioRespSessions.xls.

Below is an example of a spectrogram for an interval of zazen which shows the typical alpha signal around 8 Hz and an unusually strong signal in the beta band.


Below is the PSD spectrum for the same interval, showing the beta peak to be centered around 28 Hz.

PSD showing unusually strong beta peak

Both spectrograms and PSD graphs use the Fast Fourier Transform (FFT) algorithm operating upon sequential series of 1024 samples within the time series data. Spectrograms are generated using the specgram() function in the matplotlib library.

Our PSD graphs are generated using the psd() function from the matplotlib library. It uses Welch’s method with NFFT=1024, noverlap=512, the default ‘hanning’ window and a sampling rate of 220 samples/s. Color patches were added using the add_patch method of figure subplots.

The Physiology Viewer, written in Python 3.4 and is available at