Contents

Expanding the Simulink patch

Contents

In the last post we used Unity to send a `1` to Simulink. In Simulink this was received as the number 49. In this post we are going to expand the Simulink patch to make the number (49) more useful in our dataset and prepare for the use of EEG to measure P300.

We are going to use g.tec’s `gBSanalyze` to analyze P300 data and to do that we need a dataset. This dataset needs to contain a timeline, some EEG data and a trigger. The timeline is automatically added to our dataset, since Simulink will add timestamps to the file it generates. The EEG data will come in 8 channels from 8 different electrodes (we are going to use P3, P4, P08, P07, Fz, Cz, Pz and Oz).The trigger data needs to come from Unity and that’s why we made the UDP patch. Unfortunately we don’t want the number 49, we want the number 1. We can convert this using a few simple block in Simulink.

Let’s open up the last patch we made (available from github) and add a Constant, a Compare to Constant and a Product.

Running the Simulink patch and the Unity patch (available on github) and pressing space a few times, should now log `1` and not `49`.

To test it out we can run the matlab code:

1
2
3
4
5
6
load unity2simulink.mat
ans(1,:)=0;
values = unique(ans);
instances = histc(ans(:),values);
instances(2)
values(2)

`values(2)` will now show 1 and not 49. We can now use this as trigger data in gBSanalyze.

The new Simulink patch can be found on github.