Attempt at a Ganglion P300 Widget

lopezjuanma96lopezjuanma96 Argentina
edited November 2021 in Software

Hi! I'm currently working with OpenBCI Ganglyon to try to create a P300 Widget inside the OpenBCI GUI by working with the source code in the Processing IDE.

When we analyze the signals we not only can't get our classification model to distinguish between P300 and not-P300 states, we can't also identify the P300 wave visually. We believe the system works fine, as far as stimulation goes, but at the moment of indicating where each stimulus was lighted is where we encountered this problem: we are generating a new column on the CSV generated when recording a signal, which has a value of 99 when nothing is happening, and then varies between a value of 0 and 1 when a baseline or an oddball stimulus is presented, respectively. But measuring the time between the system "drawing" the marked stimulus and then writing the value on this tagging column, the time shifts through a range of 1 to 7 milliseconds on each stimulus. Since P300 detection generally requires averaging or adding up the time vectors of different epochs or stimulation, we think this shift is preventing us from reading the P300 signal (when summing or averaging, this shift in the waveform can cancel each with the other), even when it's probably being generated in the subject's brain by the stimulus. Reading some posts on the forum, we see most P300 with OpenBCI use other software to manage the stimulation process, is there any data on it being too complicated or maybe even impossible to correctly coordinate precise events in time using the OpenBCI Hardware/Software? I know it uses a complex method for sending the data through BLE connection (in the case of a Ganglion), maybe this generates these time shifts that are incompatible with this kind of application.

We had a similar issue when generating an SSVEP Stimulus inside a Widget, since when setting a certain frequency of stimulation, the period corresponding to that frequency wasn't accomplished on every cycle, generating a much slower frequency or even worst, a non stationary stimulation.

I'm barely new to the Processing IDE and Java Language, but I've been working on other programming languages for a couple of years now, and I can't whink of a method to overcome this shifts, but maybe there's something I'm missing. I was about to try using a matrix that accumulates the timepoints (with millis() ) where each stimmulus appears, but even if this works, the problem would resurface when working with online predictions.

By the way, I know many people is using the OpenVibe Software for P300 Stimulus. We've tried it but it only allows for Cyton boards (there's a way to connect Ganglion to the OpenBCI GUI and send data through LSL to the OpenVibe Acquisition System, but our guess is that that would become super slow and add more variance to the time shifts we were having trouble with in the beginning) and we are having some problems with our Cyton board. I'll make a post about that too and link it as a response below.

Comments

  • I'll make a post about that too and link it as a response below.

    said post.

  • wjcroftwjcroft Mount Shasta, CA

    Juan, hi.

    As you state, doing the P300 signal averaging requires very accurate stimulus epoch alignment. The recommended approach on Cyton, is with the External Trigger method,

    https://docs.openbci.com/Cyton/CytonExternal/

    Since Ganglion does not have the 3 extra Cyton 'Aux', channels, you could possibly sacrifice one of your 4 channels as a trigger recording channel. Using the similar ideas from the above link. Some experiments use a photo-sensor taped to the screen, which is briefly illuminated at trigger points; and thus recorded simultaneously with the data stream.

    You did not mention what electrodes you were using. Wet (Paste, gel, saline) electrodes give the best signal quality.

    There are other threads on the forum, explaining why SSVEP, xVEP monitor screen timing stability is so important:

    https://www.google.com/search?as_q=ssvep+timing&as_sitesearch=openbci.com

    William

  • retiututretiutut Louisiana, USA

    We have successfully integrated OpenBCI hardware with the EEG Notebooks project, which happens to contain the P300 experiment, in addition to many others. I would take a serious look at this open-source project, since this is an active collaboration with OpenBCI.

    https://github.com/NeuroTechX/eeg-notebooks

    Enjoy!
    -RW

  • Hi! Fisrt of all, thanks to both of you for such quick responses.

    .. you could possibly sacrifice one of your 4 channels as a trigger recording channel. Using the similar ideas from the above link.

    Just to see if I got this right, this would mean I would have to generate a trigger say with a USB connection and connect it to one of the Ganglion pins, with something similar to the optoisolator circuit in the link you sent. Then since I can't set that to digital read, is the resistance of 1k in the output side of the optoisolation circuit enough to reduce the downward pulse to something readable by the ganglion board? Or does that setup only work with the Cyton digital read? The thing with this setup is we'd loose the wireless advantage right? Maybe it's something we can afford, but we'd have to take this into account.

    You did not mention what electrodes you were using.

    We are using dry spiked electrodes to manage the hair problems. I know wet would be a better choice in regards of quality, but we are trying to achieve a setup where anyone can put on the headset quick and easily, and conductive gel delays the process and it's quite a mess when you finish using them.

    We have successfully integrated OpenBCI hardware with the EEG Notebooks project

    I'll take a look and get back at you wether I get good results or I find any problems.

  • wjcroftwjcroft Mount Shasta, CA

    Richard also mentioned this link on a private message, with more details on a Cyton P300 tutorial, using a pushbutton and photo sensor.

    https://docs.openbci.com/Examples/VideoExperiment/

    The schematic shown could be adapted for Ganglion, by sacrificing 2 Ganglion channels to record the button and photosensor channels. The breadboard shown outputs two levels: 0 volts or 3.3 volts to the Cyton Aux channel pins (running in Digital or Analog Board mode). These Aux channels already use the 3.3V logic levels, so no conversion is needed.

    On Ganglion, you could use a "voltage divider", two resistors, which convert the 3.3V level to say 33 microvolts, which can then be easily registered on a Ganglion channel. One divider for the button output, one divider for the sensor output. See this voltage divider tutorial / calculator:

    https://www.allaboutcircuits.com/tools/voltage-divider-calculator/

    By choosing R1 as 1,000,000 (1 megohm), and R2 as 10 ohms, a 3.3 volt input becomes 33 microvolts output. You want the output to be a fairly small number of microvolts, because large swings of microvolts do not get handled by the Ganglion compression algorithm very well (cause artifacts). With only the two levels, 0 microvolts and 33 microvolts, that will not be an issue.

    Regards, William

  • Hello,

    Sorry for the delayed response, we are a small working team so when the end of the year starts approaching us we are suddenly covered with work, so I couldn't read you sooner.

    Richard also mentioned this link on a private message, with more details on a Cyton P300 tutorial, using a pushbutton and photo sensor.

    I'll take a look at this too, it seems useful but having the user press a button when they see the stimulus seems even more randomized than marking the stimulus within OpenBCI, I see the post is for a setup where the user marks when they see a dog or a cat, in which cases the stimulus could be much more time separated (since there's only two classes) but it might not work for a full speller. But I might be getting the idea wrong so feel free to correct me.

    @retiutut I've been also taking a look at the EEG notebooks, I see they have compatibility with the Ganglyon Board, but I also saw the development uses the Brainflow library. We attempted connecting our Ganglyon Board with Brainflow but we discovered it's only available for the BLE112 dongle, which we still haven't been able to get (we are still working with a CSR in the previous version of the GUI, we are from Argentina and here importing stuff is really complicated, and there's no shop, at least not that we found, that sells it here). My concern is if the EEG notebooks package would require the BLED112 too, in which case we'll have to wait a little longer to try it out.

    We'll probably find a way sooner or later, I'm sure. Thanks in advance.

    Regard, Juan

  • wjcroftwjcroft Mount Shasta, CA

    @lopezjuanma96 said:
    ...

    Richard also mentioned this link on a private message, with more details on a Cyton P300 tutorial, using a pushbutton and photo sensor. https://docs.openbci.com/Examples/VideoExperiment/

    I'll take a look at this too, it seems useful but having the user press a button when they see the stimulus seems even more randomized than marking the stimulus within OpenBCI, I see the post is for a setup where the user marks when they see a dog or a cat, in which cases the stimulus could be much more time separated (since there's only two classes) but it might not work for a full speller. But I might be getting the idea wrong so feel free to correct me.

    Please read the actual link experiment setup and circuit diagram. TWO digital inputs trigger / timing inputs are used for the Cyton experiment. A photocell is recording the start time of each stimulus, using an area of the screen which lights up at that time point. The button input only records the subjects response.

    ...
    @retiutut I've been also taking a look at the EEG notebooks, I see they have compatibility with the Ganglyon Board, but I also saw the development uses the Brainflow library. We attempted connecting our Ganglyon Board with Brainflow but we discovered it's only available for the BLED112 dongle, which we still haven't been able to get (we are still working with a CSR in the previous version of the GUI, we are from Argentina and here importing stuff is really complicated, and there's no shop, at least not that we found, that sells it here). My concern is if the EEG notebooks package would require the BLED112 too, in which case we'll have to wait a little longer to try it out.

    Mouser electronics distributor in Argentina may stock the BLED112, according to this page,

    https://ar.mouser.com/new/silicon-labs/silicon-labs-bled112-dongle/

    re: "... but it might not work for a full speller..."

    P300 BCI paradigm CAN be used for a speller, but it is very slow and inefficient. A much faster and more user friendly paradigm, is using cVEP, code based Visual Evoked Potentials. And this free open source solution has expressly been designed with Ganglion in mind.

    https://openbci.com/forum/index.php?p=/discussion/2783/mindaffect-announces-open-source-release-of-their-cvep-bci-speller-games-etc

    Regards, William

Sign In or Register to comment.