C-sharp app, signal processing libs
Hi,
I'm trying to write my own application in C#. When my app is ploting samples, wierd samples appear from time to time. Does anyone have any idea what is going wrong? Thanks for your help.
Comments
Your photo did not come thru. Can you try putting it on another site or say Google Drive? Also if you post (Github) your C# program, other .NET programmers may be helped.
William
https://drive.google.com/file/d/0BwCCA0mNmuFJQzNWTHdXRjdwX1U/view?usp=sharing
Now I'm trying to implement filter function, but i have also some troubles. What is the length of array used for filtering? 5 or longer?
Thanks for setting up your Github here's a tree view of it,
https://github.com/nekrodezynfekator/OpenBCI-C-/tree/master/OpenBCI
The Google Drive image you posted in last entry I THINK is past history now. This was the original image you posted, but no longer relevant now that you have corrected your 24 bit integer conversion. Correct?
re: filtering. I would not try to implement your own, instead use one of the existing C# libs,
https://www.google.com/search?q=c#+dsp+library
Digital filters are passed an ongoing time series of samples, and produce a corresponding output time series.
William
http://robburke.net/mle/
http://robburke.net/projects/symphony/
http://robburke.net/mle/CodeZone.pdf
CodeZone article
HOWEVER, looking around I don't see any online code for this, he has since moved on from MLE, Microsoft. So this could be a dusty relic.
---
Signal Processing
An important component of Symphony is a real-time signal processing framework that has been used in our applications to process everything from live video to brainwaves. The framework provides a visual interface that allows a designer to drag and drop atomic signal processors that perform operations ranging from wavelet transforms to image differencing. These can be assembled into real-time signal processing networks that are used by an application.
(filterIIR function etc.). Maybe you suggest to do it in another way?
If you want to just convert the filters here into C#, that's fine,
https://github.com/OpenBCI/OpenBCI_Processing/blob/master/OpenBCI_GUI/EEG_Processing.pde
https://github.com/OpenBCI/OpenBCI_Processing/tree/master/OpenBCI_GUI
But as you can see from the source, the filter coefficients were derived from another program (I think Matlab). So for example if you wanted to build another type of filter, that involves a fair amount of steps and knowledge of that other app.
The existing C# DSP libraries likely allow you to specify filters in a more intuitive way, e.g. Butterworth bandpass filter, order 4, from 15 to 20 hz. (A beta band filter).
https://www.google.com/search?q=math.net+signal+processing
http://filtering.mathdotnet.com/
http://filtering.mathdotnet.com/api/
William
I took a quick look at your code in,
https://github.com/nekrodezynfekator/OpenBCI-C-/blob/master/OpenBCI/Form1.cs [serialPort1_DataReceived() function]
It does not look to me like this will handle serial receive buffers that are of arbitrary size (less than OpenBCI packet size), or alignment. There are no guarantees that Windows serial input operations align on packet boundaries, or have a given size. As another point, it could reference buffer[-1] if the data received did not begin with an End byte, etc.
Have you considered a simple state machine approach, see parse_byte_OPENBCI() function ~ line 750 in,
https://github.com/ChrisVeigl/BrainBay/blob/master/src/ob_eeg.cpp
William
A minor comment on your state machine derived from the ob_eeg.cpp (BrainBay OpenBCI driver). That original code kept track of sync loss situations by bumping a counter. And then that counter was made available on the user interface. This is a feature you may want to include in a future revision, as it gives a sense of the 'quality' of the radio link between board and dongle. If the link is noisy or too far away, the counter will increment more often.
Can you also upload a screen shot of your program in action, so others can see what that looks like?
Thanks for making this available.
William