Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit d8fe886

Browse files
committed
overhauled
1 parent c10ad05 commit d8fe886

File tree

1 file changed

+132
-97
lines changed

1 file changed

+132
-97
lines changed

README.md

Lines changed: 132 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,136 +1,164 @@
1-
EmoMat
2-
======
1+
# Emotiv Matlab
32

4-
**Please note that this only works on 32-bit version of Matlab**
3+
> Note 1: Please note that this only works on 32-bit version of Matlab
54
6-
Emotiv connector for Matlab
5+
There are two ways to get the data from your Emotiv EPOC device
76

8-
eeglogger.m -> Copyright (c) May 2010 The Johns Hopkins University Applied Physics Laboratory (JHU/APL).
7+
[One](https://github.com/akshaybabloo/Emotiv-Matlab/tree/master/one) -> Copyright (c) May 2010 The Johns Hopkins University Applied Physics Laboratory (JHU/APL).
98

10-
EmotivEEG.m -> Copyright (c) 2012, Gavin
9+
[Two](https://github.com/akshaybabloo/Emotiv-Matlab/tree/master/two) -> Copyright (c) 2012, Gavin
1110

12-
You would need the following files to run these files:
11+
## 1 Structure
12+
13+
<pre>
14+
Emotiv-Matlab
15+
|
16+
+-- one
17+
| |
18+
| `-- eeglogger.m
19+
+-- two <-- I prefer using this
20+
| |
21+
| +-- EmotivEEG.m
22+
| `-- ExampleUsage.m
23+
+-- LICENSE
24+
`-- README.md
25+
</pre>
26+
27+
## 2 Requirements
28+
29+
You would need the following softwares:
30+
31+
1. Visual studion 2010 professional (for Matlab 2013a)
32+
2. Emotiv SDK v1.0 or v2.0
33+
34+
Emotiv SDk has the following files in `c:/ProgramFiles/Emotiv../doc/examples_Matlab`
1335

1436
1. edk.dll
1537
2. edk.h
1638
3. edk_utils.dll
1739
4. edkErrorCode.h
1840
5. EmoStateDLL.h
1941

20-
Other software/OS needed:
21-
22-
1. Emotiv SDKLite or Emotiv Research SDK
23-
2. Windows Desktop
24-
25-
All these are available with Emotiv SDK.
42+
> Note 2: To run these codes you would have to make sure `Emotiv Control Panel` is open and connected to Emotiv EPOC.
2643
2744
Go to [Emotiv](http://www.emotiv.com) website for more information.
2845

29-
30-
Installing `mex` compiler
31-
==========================
46+
## 3 Installing `mex` compiler
3247

3348
* Open Matlab (this has been tested on R2013a).
3449
* Use mex to install c/c++ compiler by doing the following
3550
* `mex -setup` (Please make sure the required compilers are installed eg: Visual Studio 2010 pro for Matlab R2013a or Microsoft Windows SDK 7.1)
3651
```
3752
Welcome to mex -setup. This utility will help you set up
3853
a default compiler. For a list of supported compilers, see
39-
http://www.mathworks.com/support/compilers/R2013a/win32.html
40-
41-
Please choose your compiler for building MEX-files:
42-
54+
http://www.mathworks.com/support/compilers/R2013a/win32.html
55+
56+
Please choose your compiler for building MEX-files:
57+
4358
Would you like mex to locate installed compilers [y]/n?
4459
```
4560
* Enter `y` and press enter
46-
* Then you should get the following
61+
* Then you should get the following
4762
```
48-
Select a compiler:
49-
[1] Lcc-win32 C 2.4.1 in C:\PROGRA~2\MATLAB\R2013A~1\sys\lcc
50-
[2] Microsoft Visual C++ 2010 in c:\Program Files (x86)\Microsoft Visual Studio 10.0
51-
52-
[0] None
53-
54-
Compiler:
63+
Select a compiler:
64+
[1] Lcc-win32 C 2.4.1 in C:\PROGRA~2\MATLAB\R2013A~1\sys\lcc
65+
[2] Microsoft Visual C++ 2010 in c:\Program Files (x86)\Microsoft Visual Studio 10.0
66+
67+
[0] None
68+
69+
Compiler:
5570
```
5671
* Enter the number of the compiler which you want to install and then press enter, eg: `2`; then you will get the following
5772
```
58-
Please verify your choices:
59-
73+
Please verify your choices:
74+
6075
Compiler: Microsoft Visual C++ 2010
61-
Location: c:\Program Files (x86)\Microsoft Visual Studio 10.0
62-
63-
Are these correct [y]/n?
76+
Location: c:\Program Files (x86)\Microsoft Visual Studio 10.0
77+
78+
Are these correct [y]/n?
6479
```
6580
* enter `y` and press enter. Then you will get the following
6681
```
67-
***************************************************************************
68-
Warning: MEX-files generated using Microsoft Visual C++ 2010 require
82+
***************************************************************************
83+
Warning: MEX-files generated using Microsoft Visual C++ 2010 require
6984
that Microsoft Visual Studio 2010 run-time libraries be
70-
available on the computer they are run on.
71-
If you plan to redistribute your MEX-files to other MATLAB
72-
users, be sure that they have the run-time libraries.
73-
***************************************************************************
74-
75-
76-
Trying to update options file: C:\Users\gollahalli\AppData\Roaming\MathWorks\MATLAB\R2013a\mexopts.bat
77-
From template: C:\PROGRA~2\MATLAB\R2013A~1\bin\win32\mexopts\msvc100opts.bat
78-
79-
Done . . .
80-
81-
**************************************************************************
82-
Warning: The MATLAB C and Fortran API has changed to support MATLAB
83-
variables with more than 2^32-1 elements. In the near future
84-
you will be required to update your code to utilize the new
85-
API. You can find more information about this at:
85+
available on the computer they are run on.
86+
If you plan to redistribute your MEX-files to other MATLAB
87+
users, be sure that they have the run-time libraries.
88+
***************************************************************************
89+
90+
91+
Trying to update options file: C:\Users\gollahalli\AppData\Roaming\MathWorks\MATLAB\R2013a\mexopts.bat
92+
From template: C:\PROGRA~2\MATLAB\R2013A~1\bin\win32\mexopts\msvc100opts.bat
93+
94+
Done . . .
95+
96+
**************************************************************************
97+
Warning: The MATLAB C and Fortran API has changed to support MATLAB
98+
variables with more than 2^32-1 elements. In the near future
99+
you will be required to update your code to utilize the new
100+
API. You can find more information about this at:
86101
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html
87-
Building with the -largeArrayDims option enables the new API.
88-
**************************************************************************
102+
Building with the -largeArrayDims option enables the new API.
103+
**************************************************************************
89104
```
90105
* This means you have successfully installed the compiler for Matlab.
91-
* (OR)
106+
* **(OR)**
92107
* If you select `1`, **Note: This is only applicable for Windows**, and you will get
93108
```
94-
Please verify your choices:
95-
96-
Compiler: Lcc-win32 C 2.4.1
97-
Location: C:\PROGRA~2\MATLAB\R2013A~1\sys\lcc
98-
99-
Are these correct [y]/n?
109+
Please verify your choices:
110+
111+
Compiler: Lcc-win32 C 2.4.1
112+
Location: C:\PROGRA~2\MATLAB\R2013A~1\sys\lcc
113+
114+
Are these correct [y]/n?
100115
```
101116
* Enter `y` then you will get
102117
```
103-
Trying to update options file: C:\Users\gollahalli\AppData\Roaming\MathWorks\MATLAB\R2013a\mexopts.bat
104-
From template: C:\PROGRA~2\MATLAB\R2013A~1\bin\win32\mexopts\lccopts.bat
105-
106-
Done . . .
107-
108-
**************************************************************************
109-
Warning: The MATLAB C and Fortran API has changed to support MATLAB
110-
variables with more than 2^32-1 elements. In the near future
111-
you will be required to update your code to utilize the new
112-
API. You can find more information about this at:
118+
Trying to update options file: C:\Users\gollahalli\AppData\Roaming\MathWorks\MATLAB\R2013a\mexopts.bat
119+
From template: C:\PROGRA~2\MATLAB\R2013A~1\bin\win32\mexopts\lccopts.bat
120+
121+
Done . . .
122+
123+
**************************************************************************
124+
Warning: The MATLAB C and Fortran API has changed to support MATLAB
125+
variables with more than 2^32-1 elements. In the near future
126+
you will be required to update your code to utilize the new
127+
API. You can find more information about this at:
113128
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html
114-
Building with the -largeArrayDims option enables the new API.
115-
**************************************************************************
129+
Building with the -largeArrayDims option enables the new API.
130+
**************************************************************************
116131
```
117132
* This means you have installed the compiler for Matlab.
118133

134+
## 4 Using `.m` files
135+
The `*.m` files are available in [one](https://github.com/akshaybabloo/Emotiv-Matlab/tree/master/one) and [Two](https://github.com/akshaybabloo/Emotiv-Matlab/tree/master/two).
136+
137+
### 4.1 Using `one` (EEG Logger)
119138

120-
Using `.m` files
121-
================
139+
When running this code make sure the files are in the proper structure
122140

123-
**EEG Logger (eeglogger.m)**
141+
<pre>
142+
your_folder_name
143+
|
144+
+-- eeglogger.m
145+
+-- edk.dll
146+
+-- edk.h
147+
+-- edk_utils.dll
148+
+-- edkErrorCode.h
149+
`-- EmoStateDLL.h
150+
<pre>
124151

125152
* Make sure your Emotiv Control Panel is open.
126153
* Plug in the USB Bluetooth and switch on the Emotiv EEG Headset.
127-
* Open Matlab, add eeglogger.m, *.dll and *.h files to the path.
128-
* Open eeglogger.m file and run it.
129-
* you should get the following
154+
* Open Matlab, add `eeglogger.m`, `*.dll` and `*.h` files in the same folder.
155+
* Open `eeglogger.m` file and run it.
156+
* You should get the following
157+
130158
```
131159
EDK library loaded
132160

133-
nf =
161+
nf =
134162

135163
'EE_CheckSecurityCode' 'EE_GetSecurityCode'
136164

@@ -146,19 +174,28 @@ sampFreqOut =
146174
128
147175

148176
Warning: The following error was caught while executing 'EmotivEEG' class destructor:
149-
Method 'delete' is not defined for class 'EmotivEEG' or is removed from MATLAB's search path.
177+
Method 'delete' is not defined for class 'EmotivEEG' or is removed from MATLAB's search path.
150178

151179
ans =
152180

153181
0
154182
```
155-
* And these as your out puts
156-
![alt tag](http://gollahalli.com/EmoMat/eeglogger.png)
157183

158-
159-
**Emotiv EEG (Other Ways/EmotivEEG.m)** <= I prefer using this
160-
161-
* Make sure you have opened EmotivEEG.m, ExampleUsage.m added all *.dll & *.h files to the path.
184+
### 4.3 Using `one` (Emotiv EEG)
185+
186+
<pre>
187+
your_folder_name
188+
|
189+
+-- EmotivEEG.m
190+
+-- ExampleUsage.m
191+
+-- edk.dll
192+
+-- edk.h
193+
+-- edk_utils.dll
194+
+-- edkErrorCode.h
195+
`-- EmoStateDLL.h
196+
<pre>
197+
198+
* Make sure you have opened `EmotivEEG.m`, `ExampleUsage.m` added all `*.dll` & `*.h` files in the same folder.
162199
* Open Emotiv Control Panel and connect your Emotiv headset.
163200
* I have commented a piece of code in that, I will tell you about this as we go further.
164201
```
@@ -169,23 +206,23 @@ ans =
169206
% pause(0.5);
170207
% end
171208
```
172-
* Now go to ExampleUsage.m file and run it (This will record your brain for the given seconds and show you the plot of it).
209+
* Now go to `ExampleUsage.m` file and run it (This will record your brain for the given seconds and show you the plot of it).
173210
* you should get this in the Matlab
174211
```
175212
>>ExampleUsage
176-
Warning: The function 'EE_GetSecurityCode' was not found in the library
213+
Warning: The function 'EE_GetSecurityCode' was not found in the library
177214
> In loadlibrary at 403
178215
In EmotivEEG>EmotivEEG.EmotivEEG at 73
179-
In ExampleUsage at 2
180-
Warning: The function 'EE_CheckSecurityCode' was not found in the library
216+
In ExampleUsage at 2
217+
Warning: The function 'EE_CheckSecurityCode' was not found in the library
181218
> In loadlibrary at 403
182219
In EmotivEEG>EmotivEEG.EmotivEEG at 73
183-
In ExampleUsage at 2
220+
In ExampleUsage at 2
184221
EDK library loaded
185222
Successfully connected to Emotiv Systems-5
186-
Warning: You should not run the timer and record simultaneously. Stopping the timer
223+
Warning: You should not run the timer and record simultaneously. Stopping the timer
187224
> In EmotivEEG>EmotivEEG.Record at 160
188-
In ExampleUsage at 13
225+
In ExampleUsage at 13
189226
Recording... recieved ,42 samples so far in0.004 secs. Still waiting for 1240 of 1280 samples
190227
Recording... recieved ,86 samples so far in0.356 secs. Still waiting for 1196 of 1280 samples
191228
Recording... recieved ,134 samples so far in0.72 secs. Still waiting for 1148 of 1280 samples
@@ -217,8 +254,7 @@ Recording... recieved ,1282 samples so far in9.699 secs. Still waiting for 0 of
217254
Recording complete. Saved to EEGlog20141125T140701.mat
218255
Successfully disconnected from Emotiv Systems-5
219256
```
220-
* And
221-
![alt tag](http://gollahalli.com/EmoMat/emotiveeg1.png)
257+
222258
* Now comment this
223259
```
224260
% lastfilename = h.Record(10);
@@ -244,5 +280,4 @@ EDK library loaded
244280
Successfully connected to Emotiv Systems-5
245281
Successfully disconnected from Emotiv Systems-5
246282
```
247-
* And multiple updated plots which should be something like this
248-
![alt tag](http://gollahalli.com/EmoMat/emotiveeg2.png)
283+
* you can also see that a plot is updated dynamically.

0 commit comments

Comments
 (0)