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.
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.
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