User Tools

Site Tools


analysis:rhythms:step1

This is an old revision of the document!


Step 1: from zero to loading and plotting Emotiv data

Installing MATLAB

Make sure you are on a Dartmouth network, such as Dartmouth Secure. Not KAF, Starbucks or eduroam. Then go here, click “Site License Downloads” and keep clicking the link at the bottom of the page until you get to the page for “R2014a”: this is the version you want. Follow the instructions in the PDF.

When the installation is done, see if you can run MATLAB. You should be faced with a screen containing a bunch of windows, including one called “Command Prompt” containing ».

If your MATLAB runs, great! Now decide if you'd rather:

  1. Familiarize yourself with MATLAB first. Go here.
  2. Dive right in, working with Emotiv data. Read on.

Obtaining some sample Emotiv data

Click here. Move this file to a location that shows you are careful with how you handle data. Something like \Documents\PSYC50\Data\TestData is a good choice, because it is clearly named and anticipates that you may have other data in the future beyond the file you grabbed just now. Something like \Downloads or \Desktop is bad because it'll get mixed in with lots of other files and maybe get deleted accidentally.

Notice that this file has the extension .edf. File extensions typically tell you about what type of file you are dealing with. In this case, our filetype is “EDF” (meaning it contains data arranged according the rules laid out in the European Data Format specification, which you can be happily ignorant about). All this means for you is that you need a file loader that can accept files of the EDF format, such as the one introduced in the next section.

Obtaining the code you need to load the Emotiv data

Pick one: the quick way, or the future-proof way.

The quick way: download the MATLAB loader (from here, use “Save Link As…” rather than opening this file in your browser), and place it in a sensible location like \Documents\PSYC50\Code\Loading. This will work for now. However, if you ever want to access an updated version of this file, or other code that I put up for use in the course, you'll have to do more downloading. The future-proof way, below, addresses this.

The future-proof way: I have added the code you'll need for loading EDF data, as well as for doing some other things, on a “GitHub repository”. Git is a system for “distributed version control”: put simply, a way to collaborate on a set of files that makes it easy to share and receive updates to those files. GitHub is a website that hosts those files in a convenient place so that the Git software can do its job.

Let's make sure you have Git on your computer. If you are a Mac user, you should already have git installed. Open up a Terminal, and type git to verify that your computer recognizes it. If you are on Windows, I recommend you download the GitHub desktop. Then, open a “Git shell” (you should have an icon and start menu item) and type git to check this command is recognized.

In your terminal/shell, navigate to a good place to put your GitHub code. I recommend going to /Documents and then creating a GitHub folder and entering it. (If these instructions don't make sense, review the information here or ask me).

From your GitHub folder, do this:

git clone https://github.com/mvdm/PSYC50Rhythms.git

If that worked, you should see a new folder called PSYC50Rhythms within your GitHub folder. If so you're ready for the next step.

Configuring MATLAB

The previous section ensured that you have the data loader file on your computer. However, that doesn't mean that MATLAB knows about it.

In the MATLAB command prompt, do the following (by 'do' I mean, type and press Enter):

addpath('\Documents\GitHub\PSYC50Rhythms');

(obviously, if you placed the code in some different place, substitute that.)

Now you've told MATLAB to add this new location to the list of places it looks for commands (the “path”). To check that MATLAB can find our shiny new EDF loader, do which edfread. If things are set up right, MATLAB should reply with the location of where the edfread.m file is located, and you're all set for the final step below.

Loading and plotting the data

In MATLAB, set its current (“working”) directory to where you placed your data. You can to this either using the cd command just like you would in a terminal, by pasting a path that you copied from Finder/Explorer into the path box, or by clicking the “Browse for Folder” button next to the path box. This important because otherwise MATLAB won't be able to find our data file.

Then, you can do:

fn = 'Seth1.edf';
[hdr,data] = edfread(fn);

(As an aside, it is a good idea to enter these commands into the MATLAB Editor, rather than into the Command Window directly. From the Editor, it is easier to save your work, and re-run code without having to re-type or copy and paste it. To start the Editor, type edit at the command line.)

Now, at last, you can plot the data:

plot(data')

You should get:

The traces you see include some signals recorded from the Emotiv's electrodes, positioned on the skull (the traces at the top), signals from the Emotiv's accelerometers (the signals in the middle), and some timing and event channels (at the bottom). The neural data traces don't look great: there are various features that we suspect are probably non-neural artifacts, such as the sharp spikes appearing on a few channels simultaneously. But it will do in having something to work with for now!

Structure of Emotiv data

Type whos data and note what MATLAB tells you about the size of the data variable: it's 37 x 8448, meaning it is a matrix with 37 rows, each containing 8448 samples (measurements). The mapping from these rows to electrode identifiers is given in this file, see the Emotiv manual for reference on where on the brain these identifiers correspond to.

Look at the horizontal (x) axis of the plot we made earlier. It contains labels that correspond to these samples. A more informative plot would contain time, in seconds.

☛ Construct a vector of timestamps containing the time, starting with 0, of each of the 8448 samples in this data. This requires knowing the sampling rate of the Emotiv; consult the manual or the file header to find this out. Then, replot the data using this time vector.

analysis/rhythms/step1.1459360911.txt.gz · Last modified: 2018/07/07 10:19 (external edit)