JavaFX GUI for Oddball Experiment and Passing Event Codes

Hi all. I want to run my own oddball experiment with my ganglion. So far, I can get EEG data into MATLAB and have ERPLab. But my EEG Data doesn't have event codes yet.

I am thinking of making a simple GUI that records (in Java) when a photo is shown on screen. Then I would pass that data to the .set file I have. Does anyone see a problem with this? Will Java's recorded time of image-shown-on-screen be too imprecise for me to use it for event codes?

If so, how can I add event codes to my EEG data with a self-run experiment?

Thank you,


  • Update: I now realize a few things from digging through the forum and other communities. The Java timer won't do due to imprecision, the Cyton allows for external triggering, and for the Ganglion I'd need an external photo trigger and voltage divider. I don't deeply know how the latter two things work so I will do some research. If anyone has any textbook recommendations or article recommendations to help me understand more about how EE relates to BCIs I think that would help me fill gaps in my understanding.

  • marles77marles77 Poland

    One quite simple way to synchronize two inputs (EEG and events) is to use LabStreamingLayer
    It provides API for different languages/technologies including Java and MATLAB (I guess there is also some plugin). It works for me at least.

  • retiututretiutut Louisiana, USA
    edited April 4

    FYI Here is a current project in active development that OpenBCI is involved with:
    EEG-Notebooks (Python)

    Maybe this has a paradigm you are already interested in.

    Also, here is a loosely documented example of how to setup an experiment with Cyton using a photodiode connected to an analog pin for time-locked events.

    Take Care,

  • @marles77 Thank you! I went ahead and tried to use LSL for my project.

    I posted about my plans in the LSL Slack and received this message from a member: "I think openbci lsl integration still uses their custom timetable which makes it impossible to synchronize with other devices, but please check their forums (link mentioned elsewhere in this Slack) to see if it has been resolved." I'm not fully sure what that means so, I just wanted to confirm if you think the synchronization issue the member is referring to has been resolved.

  • Thank you retiutut! I will look into both of these. Looks like I'll want to upgrade to a cyton soon.

  • marles77marles77 Poland
    edited April 6

    I believe that they refer to the mismatch between timestamps that I mentioned in this post. As far as I know this is no longer a problem, but the OpenBCI team will explain that better. Anyway, the above mentioned EEG-Notebooks project seems to be based on a library using lsl. Here is how I use my Cyton with lsl + Python:
    -Open an lsl outlet by openbci_lsl or (the best option but not tested on Ganglion) the script kindly provided by @retiutut, (both use pylsl library but there is also a Java library) to be able to stream EEG data.
    -Open another outlet in PsychoPy with an oddball experiment (you can use your own app for stimuli presentation):

    info = StreamInfo(name='my_markers', type='Markers', channel_count=1, channel_format='int32', source_id='example_stream_999')
    outlet = StreamOutlet(info)

    -Use LabRecorder to connect to both streams (they will be synchronized and merged into one XDF file)
    -Start pushing EEG samples
    -Push a sample containing markers each time an odd stimulus appears:

    outlet.push_sample(x=[1]) # 1 is a code of one type of markers

    -After finishing recording, open XDF file in MATLAB, extract epochs etc.
    If you have a full version of MATLAB you can probably skip the part containing LabRecorder and capture the streams using this viewer. A big advantage of lsl is that you can record multiple types of markers. Hope it helps.


Sign In or Register to comment.