negative SampleIndex? repeating: -29 to 0
I'm at the hackathon now, and having some trouble parsing the output from OpenBCI_GUI_simpler/SavedData
Most of the files are empty and look like this:
%OpenBCI Raw EEG Data
%
%Sample Rate = 250.0 Hz
%First Column = SampleIndex
%Other Columns = EEG data in microvolts
Some of them do something weird where the indexes start at -29 and move to 0, before going back to -29.
These look like this:
%OpenBCI Raw EEG Data
%
%Sample Rate = 250.0 Hz
%First Column = SampleIndex
%Other Columns = EEG data in microvolts
-29, 84792.34, 108628.17
-28, 65161.95, 83489.14
-27, 59106.45, 75716.46
-26, 68452.14, 87705.66
-25, 70581.50, 90436.42
-24, 62344.30, 79895.67
-23, 57696.71, 73947.23
-22, 56784.04, 72788.88
-21, 54148.61, 69429.67
-20, 52055.78, 66751.60
-19, 50621.60, 64909.21
-18, 49421.29, 63394.99
-17, 47789.21, 61300.32
-16, 45793.13, 58751.91
-15, 44741.04, 57391.16
-14, 44267.51, 56809.25
-13, 42779.54, 54899.25
-12, 39156.68, 50277.70
-11, 38010.88, 48804.92
-10, 35913.93, 46130.87
-9, 34333.75, 44112.01
-8, 33476.85, 43011.57
-7, 30334.22, 38988.25
-6, 29897.27, 38436.17
-5, 29216.10, 37566.84
-4, 27743.09, 35682.45
-3, 26431.25, 34002.05
-2, 25857.90, 33265.88
-1, 25258.36, 32508.02
0, 24070.52, 30983.09
-29, 22853.65, 29433.04
The final format that looks more reasonable, is what's contained in: openBCI_raw_2013-11-15_09-55-27.txt
%OpenBCI Raw EEG Data
%
%Sample Rate = 250.0 Hz
%First Column = SampleIndex
%Other Columns = EEG data in microvolts
0, -39.12, 0.00
1, 263.82, 0.00
2, 160.04, 0.00
3, -287.82, 0.00
4, -42.94, 0.00
5, 120.30, 0.00
6, 147.72, 0.00
7, -4.52, 0.00
8, 262.81, 0.00
9, -31.87, 0.00
10, -51.43, 0.00
11, 27.14, 0.00
12, -190.66, 0.00
13, -31.16, 0.00
14, 78.61, 0.00
15, -57.94, 0.00
16, -60.13, 0.00
17, 300.54, 0.00
18, -27.67, 0.00
19, 88.13, 0.00
20, 148.35, 0.00
21, -64.19, 0.00
22, 84.82, 0.00
23, 190.55, 0.00
24, 21.12, 0.00
25, 4.38, 0.00
26, 10.28, 0.00
27, 112.43, 0.00
28, -32.30, 0.00
29, 78.39, 0.00
30, 51.74, 0.00
31, 79.80, 0.00
32, 66.79, 0.00
33, 133.06, 0.00
34, -91.13, 0.00
Most of the files are empty and look like this:
%OpenBCI Raw EEG Data
%
%Sample Rate = 250.0 Hz
%First Column = SampleIndex
%Other Columns = EEG data in microvolts
Some of them do something weird where the indexes start at -29 and move to 0, before going back to -29.
These look like this:
%OpenBCI Raw EEG Data
%
%Sample Rate = 250.0 Hz
%First Column = SampleIndex
%Other Columns = EEG data in microvolts
-29, 84792.34, 108628.17
-28, 65161.95, 83489.14
-27, 59106.45, 75716.46
-26, 68452.14, 87705.66
-25, 70581.50, 90436.42
-24, 62344.30, 79895.67
-23, 57696.71, 73947.23
-22, 56784.04, 72788.88
-21, 54148.61, 69429.67
-20, 52055.78, 66751.60
-19, 50621.60, 64909.21
-18, 49421.29, 63394.99
-17, 47789.21, 61300.32
-16, 45793.13, 58751.91
-15, 44741.04, 57391.16
-14, 44267.51, 56809.25
-13, 42779.54, 54899.25
-12, 39156.68, 50277.70
-11, 38010.88, 48804.92
-10, 35913.93, 46130.87
-9, 34333.75, 44112.01
-8, 33476.85, 43011.57
-7, 30334.22, 38988.25
-6, 29897.27, 38436.17
-5, 29216.10, 37566.84
-4, 27743.09, 35682.45
-3, 26431.25, 34002.05
-2, 25857.90, 33265.88
-1, 25258.36, 32508.02
0, 24070.52, 30983.09
-29, 22853.65, 29433.04
The final format that looks more reasonable, is what's contained in: openBCI_raw_2013-11-15_09-55-27.txt
%OpenBCI Raw EEG Data
%
%Sample Rate = 250.0 Hz
%First Column = SampleIndex
%Other Columns = EEG data in microvolts
0, -39.12, 0.00
1, 263.82, 0.00
2, 160.04, 0.00
3, -287.82, 0.00
4, -42.94, 0.00
5, 120.30, 0.00
6, 147.72, 0.00
7, -4.52, 0.00
8, 262.81, 0.00
9, -31.87, 0.00
10, -51.43, 0.00
11, 27.14, 0.00
12, -190.66, 0.00
13, -31.16, 0.00
14, 78.61, 0.00
15, -57.94, 0.00
16, -60.13, 0.00
17, 300.54, 0.00
18, -27.67, 0.00
19, 88.13, 0.00
20, 148.35, 0.00
21, -64.19, 0.00
22, 84.82, 0.00
23, 190.55, 0.00
24, 21.12, 0.00
25, 4.38, 0.00
26, 10.28, 0.00
27, 112.43, 0.00
28, -32.30, 0.00
29, 78.39, 0.00
30, 51.74, 0.00
31, 79.80, 0.00
32, 66.79, 0.00
33, 133.06, 0.00
34, -91.13, 0.00
Comments
This is chip. I wrote the code that makes the text output, so I'm responsible for any weirdness. Sorry!
I looked at the relevant code ("OpenBCI_GUI_Simpler/OutputFile") in the method "writeRawData_txt". The line the writes the sample index is this one:
<code>output.print(Integer.toString(indexOfLastValue - nsamp + i));</code>
I can definitely see how it can write negative values...the "- nsamp" would cause the output to be negative if "indexOfLastValue" were not big enough. In my mind, though, indexOfLastValue should always be equal to or larger than nsamp. I'm looking into the main program now...maybe the problem is there...
Chip
Sadly, I can't seem untangle it right now. I'll hit it again this evening.
Chip
The Processing code assumes that the Arduino is keeping track of the number of EEG samples that it has collected. In the transfer of data from the Arduino to the PC, there is a field that I set aside so that the Arduino would tell the PC which sample is currently being sent. The Processing code has been written to use that sample value as the basis for the SampleIndex that gets written to the TXT file.
Great.
The problem is that I had modified the Arduino code to NOT transmit its current value of the sample counter. Instead it just sends a value of one. I did this because I had problems with my Processing code every time the Arduino's sample counter incremented to the point where one of its bytes was the same as the header byte or footer byte for the data packet. So, I just avoided the problem by not writing the actual sample counter anymore. Easy.
Unfortunately, you're now seeing the side-effect...the sampleCounter getting written to the text file is all wrong. You see it go from -29 to zero because the Processing code only writes to the text file every 30 data points. Since the sampleIndex from the Arduino is "1", and since the Processing code think that's the sampleIndex for the latest data point, the Processing code writes -29 to zero. So, yes, there is an "off by one" error here, but the bigger problem is that the Arduino code doesn't send the actual sampleCounter.
I'll look into the best way of fixing this. It's probably just best to ignore the first column in the text file for now. As far as I can tell, the EEG values themselves should be correct and in the right order. I'll try to confirm this experimentally later.
Chip
https://github.com/strob/openbci-python