---
# System prepended metadata

title: Matlab | DEAP database

---

# Matlab | DEAP database

These are some implementation oriented notes on how to analyze data (reading, spectrum) for datasets given in `Matlab` format. The following code snippets have been tested for the **DEAP** database.

## How to read files

Downloading the `data_preproccessed.zip` file from [the official website](https://www.eecs.qmul.ac.uk/mmv/datasets/deap/download.html) giving the necessary credentials, we have 32 files for each participant. Each file contains two arrays:

- 40 videos x 32 electrodes EEG + 8 peripheral signals x 8064 samples of the segmented 30 seconds per video. The data is down-sampled to 256 Hz (sanity check: $\frac{1}{256} * 8064 = 31.5$ seconds). So we have 3D array, 40 x 40 x 8064.
- 40 videos x 4 labels. Each video has an emotional label. The indices of the video dimension of this array are the same with the indices of the video dimension of the previous array.

Across the 32 files of each participants the videos have the same order.

Now let's see how we can read these files in `Matlab`:

First, let's suppose to that we have download the unzipped data_preprocessed.zip to `/my/path/data_preprocessed`. Then we set our current/working directory to this path using the icon `Browse for folder` e.g.  ![image-20210617155926983](https://i.imgur.com/qOCGWMb.png).

```matlab
% first let's see the variables contained to the mat file
>> who -file s01.mat
```

We should get something like:

![whos](https://i.imgur.com/9kWMe4b.png)

Now we can see the arrays mentioned previously. So in a script we can have:

```matlab
load s01.mat

% EEG 1st channel
firstVideoFirstChannel = data(1,1,:)
plot(firstVideoFirstChannel(:))

% label
labels(1,1)
```



## How to create frequency spectrum

```matlab
% fft
```

## How to isolate frequency bands

```matlab
% filtering spectrum to alpha, beta, gamma, delta bands

```


