LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

OpenEEG / EEG-SMT Serial Port Packet Capture and Analysis

Hi,

 

I´m working with the open source EEG device project: OpenEEG / EEG-SMT (https://www.olimex.com/Products/EEG/OpenEEG/)

 

The device samples the analog signals and builds a 17-byte packet which is transmitted at 256Hz,
using 1 start bit, 8 data bits, 1 stop bit, no parity, 57600 bits per second.
Minimial transmission speed is 256Hz * sizeof(modeeg_packet) * 10 = 43520 bps.

 

The packet structure is as follow:

 

    uint8_t        sync0;       // = 0xA5  (decimal 165)
    uint8_t        sync1;       // = 0x5A  (decimal 90)
    uint8_t        version;      // = 2
    uint8_t        count;        // packet counter. Increases by 1 each packet
    uint16_t      data[6];      // 10-bit sample (= 0 - 1023) in big endian (Motorola) format
    uint8_t        switches;   // State of PD5 to PD2, in bits 3 to 0

 

the 10-bit data byte is really the sample data from 6 channels, so the package is built like this:

 

1 - sync0 - 165

2 - sync1 - 90

3 - version - 2

4 - counter - 0 to 255

5 - ch1_hi - 0 to 3

6 - ch1_lo - 0 to 255

7 - ch2_hi - 0 to 3

8 - ch2_lo - 0 to 255

9 - ch3_hi - 0 to 3

10 - ch3_lo - 0 to 255

11 - ch4_hi - 0 to 3

12 - ch4_lo - 0 to 255

13 - ch5_hi - 0 to 3

14 - ch5_lo - 0 to 255

15 - ch6_hi - 0 to 3

16 - ch6_lo - 0 to 255

 17 - status - 0 to 15

 

here is an example of a captured data stream:

 

165,90,2,229,3,255,0,0,0,91,0,38,0,11,0,7,15,

165,90,2,230,3,255,0,0,0,91,0,38,0,11,0,7,15,

165,90,2,231,3,255,0,0,0,91,0,38,0,11,0,7,15,

165,90,2,232,3,255,0,0,0,91,0,38,0,11,0,7,15,

165,90,2,233,3,255,0,0,0,91,0,38,0,11,0,7,15,

165,90,2,234,3,255,0,0,0,91,0,38,0,11,0,7,15,

 

The device has only 2 channels implemented, so the other bytes are unused, and the data sampled is just noise.

 

Ok, now with this intro here's my issue:

 

I capture the data stream via serial port using VISA, then i search the sync bytes and split the values in 4 arrays for the CH1_HI and LO and CH2_HI and LO bytes as you see in the following images:

 

 buffer.jpg

 search and strip.jpg

 

charts.jpg

 

 I would like to get the HI and LO values of each channel array and display them in two chart graphs showing all the 255 values in each second.


I have tried but the search and graph process takes too long, how can i fix it?

 

In the end i need to analyze the EEG signal with a FFT to recognize the muscular noise produced by the eye or eyebrows movements.

 

Thank you for your help,

 

Gustavo

0 Kudos
Message 1 of 18
(6,616 Views)

That process to display data shouldn't take so long. Remember that graphs and charts are different elements in LabVIEW. Check this link:

http://digital.ni.com/public.nsf/allkb/95FEE9F5B252507E862562BA00007657?OpenDocument

 

How are you displaying this information that is taking too much time? Using arrays is good way.

 

Regards

 

0 Kudos
Message 2 of 18
(6,532 Views)

Hi Fromm8,

 

I have been working on this project and since then i haven´t checked this thread. Thank you for your response, but in the end i solve it like this:

 

Tree stages: read stream, divide channels and graph.

 

2013-10-29 14_34_58-OpenEEG_Example.vi Block Diagram.png

Inthe Read VI i got it like this:

 

2014-01-13 12_46_55-OpenEEG_Read.vi Block Diagram on OpenEEG.lvproj_My Computer.png

 

 

So in the end the Graph VI gets me somthing like this:

 

2014-01-13 12_48_37-EEGSerial_V4.vi Front Panel on OpenEEG.lvproj_My Computer.png

 

Eyebrow movement waveform depicted in the graphic, just like our friend The Rock is showing us:

 

peoples eyebrow6.jpg

0 Kudos
Message 3 of 18
(6,329 Views)

Now i´m stuck in other area, and it is the EMG waveform recognition.

 

As you know the EMG signals are much stronger than the EEG, its important to filter them in order to get a clean EEG signal.

 

But, there is another case (im interested in this now), where you want to capture and recognize the EMG signals instead of the EEG ones.

 

For instance, if you want to control a device using only your facial movements, lets say: blinking, eyebrow raising, jaw clenching, eye left/right movement, blinking, and eye winking.

 

Each one of them has a different waveform:

 

eyebrow raising:

2014-01-13 12_48_37-EEGSerial_V4.vi Front Panel on OpenEEG.lvproj_My Computer.png

 

 

 

 

 

 

 

 

 

 

jaw clench:

mordida.png

blinking:

parpadeo.png

 


So, i would like to know how can i get to recognize this waveforms out from noise or other stuff detected by the electrodes?

 

I would appreciate your help!

 

 

Regards

 

0 Kudos
Message 4 of 18
(6,324 Views)

Hello gustux

What format is your data in? If it's two waveforms, two arrays of doubles or even two dynamic data type that are generated by an express VI, you can actually subtract one set of data from the other to find the amplitude difference. The subtraction vi should be under Numeric->Subtract. If they are two waveforms and there's a phase shift between the two, you have to make sure to account for the phase shift. If they have different frequency, you'll also have to account for that. Basically when you do subtractions between waveforms, it subtract the value amplitutes at the time when data is acquired based on the time stamp on the waveform.


Hope this information helps!

Luis C.

National Instruments

Ingeniería de Aplicaciones

www.ni.com/soporte

Luis CT
0 Kudos
Message 5 of 18
(6,276 Views)

Hi Luis,

 

The data is a 1D int array, with 254 data samples between 0 to 1024, then is saved into a CSV file for later anaysis and signal recognition.

 

I attach a CSV file with a jaw clenching signal that you can graph by using any spreadsheet software.

 

As an example this is how does it look 3 jaw clenching signals which needs to be recognized.

 

jaw1.png

jaw2.png

jaw3.png

 

0 Kudos
Message 6 of 18
(6,196 Views)

Hello gustux,


I suggest you to have an average waveform so that you can use it as a template or as your main waveform reference for each facial move (Jaw Clench, Eyebrow Rising, etc). Then what you can do is every time you acquire a waveform perform an 1D array subtraction between the waveform reference and the acquired waveform, after that you can compare each array value and determine if the difference is big enough to be a Jaw Clinch, Eyebrow Rising etc. That could be one idea on how to tackle the problem; just make sure to have good acquisition hardware and a reference value in order to start capturing any facial move in order to avoid phase shifts between both waveforms.

 

Hope this helps!

 

Regards,

 

Luis C.

 

National Instruments

Ingeniería de Aplicaciones

www.ni.com/soporte

Luis CT
0 Kudos
Message 7 of 18
(6,187 Views)

I am also working on the same project.

EEG SMT & ElectricGuru,

But this Electricguru is pretty basic so, i started developing labview program which reads serial data using VISA drivers.

I am facing some problems related to reading raw ascii data etc., 

If possible please share you VI files so that i can save some valuble time.

 

0 Kudos
Message 8 of 18
(5,335 Views)

Hi, 

 

I tried aquiring data from EKG shield + Arduino with labview.

The same way i programmed as Gustux mentioned here.

But still i am unable to get right data from the board.

 

Could you suggest some changes to get proper signals?

0 Kudos
Message 9 of 18
(5,233 Views)

Sure,

 

Give me your email adress and i can send them to you.

 

Cheers

0 Kudos
Message 10 of 18
(5,222 Views)