Sunday, May 11, 2014

EEG as WAV Files, Go Spectrograms!

OK, let's say that I just finished some cool new EEG experiment where I recorded my EEG response to watching cat videos while listening to the Pink Panther at half speed.  My next step would be to take a quick look at the data to get the overall big picture.  My favorite way of getting that overall view is to make a spectrogram (see example below).  My love for these oh-so-colorful plots runs deep.  The question is, how does one make spectrograms?  Well, in my opinion, if you don't have Matlab (and are afraid of Python), the next best way to make spectrograms is to use one of the multitude of audio editing software packages out there.  Many audio edit programs provide a spectrogram view.  This post is about getting EEG data into an audio program so that you can see your data.

A Spectrogram of EEG data that was Made in Matlab.  This shows data from my previous post,
where I was watching a movie with two different blink rates.  You can see how my brainwaves
entrained with the changing blink rate in the movie.

Converting to a WAV File:  The first step in using an audio program for EEG analysis is to convert one's EEG data into an audio file.  Since I usually work in Windows, I tend to convert all of my EEG data into WAV files.  I choose WAV because it is uncompressed.  I never choose MP3 because it is very unclear what its "perceptual coding" would do to my precious brainwave data.  So, a WAV file is what I would recommend.  But how do you get EEG data into a WAV format?  If your EEG data is in text format (such as is logged by the OpenBCI GUI), you could use my Processing sketch "ConvertToWAV".  This sketch will read in an OpenBCI log file and write each EEG channel out as its own WAV file. You can get the sketch on my GitHub.

Audacity:  Once the data is in WAV format, you can open it in any audio program.  A popular (and free!) audio editing program is Audacity.  While it is not my favorite audio editing program, it is perfectly sufficient for working with EEG data.  After opening your EEG data, the trick is to figure out how to switch the display from waveform to spectrogram.  The screen shot below shows how to do it.

Changing to Spectrogram View in Audacity

Once Audacity is in spectrogram mode, you need to zoom in on the vertical axis in order to see the interesting EEG features, which are usually focused in the lower frequencies.  In Audacity, you zoom simply with a click-and-drag on the vertical axis.  Then, after manipulating the spectrogram settings under the "Preferences" menu, you can get a spectrogram like the one shown below. While the color scheme hurts the eyes a bit, this spectrogram is good enough to see the same kind of EEG entrainment as seen in my original Matlab plot. Furthermore, the tools in Audacity let you further analyze the EEG data through zooming, filtering, amplifying, and (if you change the file's sample rate to increase the playback speed) you can use Audacity to listen to your own brain waves!  Audacity is definitely a useful tool for working with EEG data.

In Audacity, a Spectrogram of my EEG Data

The spectrogram settings that I used are shown in the screen shot below.

My Display Settings for Making EEG Spectrograms in Audacity.  I changed
the Window Size, the Gain, and the Range.

Cool Edit Pro:  I first started getting into spectrograms in the late 90's because this is when I started working with audio and music on the computer. What got me hooked on spectrograms was a piece of shareware called Cool Edit.  It was a stupid name for an otherwise outstanding program.  It was so useful that I spent the extra dollars and bought its upgrad -- Cool Edit Pro. Cool Edit Pro has a *great* spectrogram display, as shown below.  Unlike Audacity, which requires lots of manipulation of the spectrogram settings to get a useful view, the Cool Edit Pro display always seems just right.  Unfortunately, Cool Edit Pro isn't available anymore -- it was bought by Adobe in the early 2000s and became Adobe Audition.  Audition is also fine for making spectrograms (I have only used up to Audition 3.0), but it is expensive.

An EEG Spectrogram in Cool Edit Pro V1.2a.  It's an old school program that totally rocks.

In Cool Edit Pro, the only display parameter that you need to change is the "Resolution" (ie, FFT size).  You do that under the "Settings" menu.

My settings for viewing EEG spectrograms in Cool Edit Pro.
I changed the Resolution value.

Raven Lite:  A third option for making spectrograms is a bit more obscure.  A bunch of years ago, I came across a program called "Raven Lite", which is produced by the Ornithology Lab (ie, bird science) at Cornell University.  The "Lite" version is free.  You can download it and immediately use it for spectrograms, though it is crippled in other ways until you email them for a free (non-commercial) key. What I really like about Raven is that, as shown in the screen shot below, its spectrogram controls are right on the main window for easy manipulation.  Also, I like its color map options way better than what is available in Audacity.  Finally, Raven is one of the few programs that let you see both the spectrogram view and the waveform view at the same time (not shown).  It is really nice to have that capability.

Raven Lite 1.0 from the Cornell Laboratory of Ornithology. It's a pretty good viewer.  The settings for
the display or right here in the main window.

Other Options:  Because I have Matlab and Cool Edit Pro (and Audacity and Raven) I haven't spent a lot of time looking at other options.  Does Garage Band offer a spectrogram view?  Is there a plug-in for iTunes or Windows Media Player that gives spectrograms?  I'm curious to hear what you folks use.  Drop a comment and let me know!


  1. How do you normally make those spectrograms you post here?

    1. Hey, thanks for reading!

      I usually use Matlab because I have access to that (expensive!) package through my workplace.

  2. Chip, All of the VPL (visual programming language) style EEG apps give fairly decent spectrogram and spectrum displays. I use Bioexplorer and BioEra. Brainbay has this. On the high end, National Instruments LabVIEW, which I know you've used as well. (It does come in an inexpensive student version).

    These also allow you to see the displays while the data is being recorded live, and record to a file if you wish. Later you can play back from that file and see the same displays.

    1. I don't know much about Bioexplorer and BioEra. It looks like they're a couple of hundred dollars each. Do you like them sufficiently to recommend them over BrainBay or other software that one might home-brew?


    2. Bioexplorer is in use by I would estimate hundreds of neurofeedback practitioners. Pete Van Deusen (the teacher and wizard at, uses it for all his protocols, designs, assessments. Although the support level by the Bioexplorer developer is minimal, (no new features are being added) and I think he only makes new releases for adding new hardware devices.

      I havent used the free Brainbay yet, but from looking over the documentation, it seems capable of many of the Bioexplorer features. I could guess that with advent of the OpenBCI hardware, it's popularity will take off.

      BioEra on the other hand is a different animal. Many commercial products (Cygnet, LENS) are using it as the foundation of their applications. So it has quite a toolbox of functionality. But the learning curve is substantially more steep than Bioexplorer. There are things you cannot do with Bioexplorer that are possible with BioEra, such as InfraLow Frequency protocols.

      I wonder that if National had a version of LabVIEW that was reasonably priced, it might have been a major player in this field. But of course that is not the case. One vendor (Zengar) did go with a LabVIEW base. Can't think of any others.

      Sorry I'm rambling here... One disadvantage of the VPL style tools is that once your design gets sufficiently complex and nested, it becomes challenging to track your incremental changes. Source code and diff tools, git etc. do have an advantage here. :-) If you had an language API framework geared toward biofeedback applications, say with the same sorts of tools available as BioEra, I think that would have a lot of appeal.

  3. If you don't have MATLAB, and you're afraid of Python, the best alternative is... to stop being afraid of Python!! :)


    2. Hey Rob, Thanks for the pointer to the EEG Viewer code. I'm checking it out now...

      ...though, statements in its documentation like "Currently, there are several dependencies that need to be installed before installing the pbrain software"...well, that makes me a bit nervous.

      Maybe it's time to put on my big-boy pants and wrestle with the Python. Maybe it's time to take my medicine and become stronger for it...

    3. Here are install instructions for Windows... If you use Python(x,y), it should be quite easy to install.

  4. Another free package that is used quite a bit by QEEG practitioners is EDFBrowser. EDF is a standardized way to interchange EEG data (EEG Data Format). So many amplifier software packages use EDF as an interchange format. The EDFBrowser has some cool features. And it is actively maintained by the author.

  5. could you possibly shoot me a brain .wav file? I've been visualizing 'sound' waves made exported from ableton in a 3d program called Houdini. I've made an asset that can accurately visualize soundwaves in 3d. it would be cool to see what brain waves look like in 3 dimensions. you can contact me at

  6. hey, it's a great thing you worked on. can we some how control the volume using the same set of data that we are getting from our brain ?