change Focus Widget to do band based neurofeedback?

edited May 25 in OpenBCI_GUI

A couple of questions about Focus Widget:
1. Where is the documentation for the Focus Widget located? Answers to such questions as how the "Metric Value" is calculated? What "Threshold" is/does?
2. Is there a way to customize the Focus Widget so that it responds (plays music, graphs metric) to specific waves (Theta only for example, vs. a combination of Alpha, Theta, Delta?)
Thank you.
3. How can I access the Focus Widget source code?


  • wjcroftwjcroft Mount Shasta, CA

    Ivan, hi.

    This is the source code:

    The Brainflow ML functions:

    Your 2nd question may be better addressed with apps tailored to neurofeedback applications, such as BrainBay, neuromore, BioEra, NeuroPype, etc. All of these accept OpenBCI data streams. Some of them are free, others paid. There are also BCI apps like OpenViBe that can be configured to give feedback but are not specifically geared to neurofeedback.

    Of course you can also just mod the W_Focus source code. It is written in the 'Processing Language' which is a superset of Java.


  • Great! Thanks, William.

  • Thanks again, William.

    I looked through everything you posted. My knowledge of programming is rather limited, but from what I can see, the cleanest way to do what I am after is to make a copy of the Focus Widget and then tweak the source code slightly.

    Right now it plays a tone as soon as you go into Alpha and continues playing it as long as you are in Alpha, Theta, or Delta - that is "relaxing". What I am interested in is playing a definitive tone when I am in Theta, or lower frequencies (Delta), so, I'd simply remove Alpha frequency from the equation, or use only the lower portion of Alpha range, perhaps. If I was to hire someone to do this, who would you recommend? Is it possible to hire you or someone from the open BCI team, as you are most familiar with the code?


  • wjcroftwjcroft Mount Shasta, CA
    edited May 19

    There are other apps that are more targeted for neurofeedback usage. And allow easy adjustment of feedback on certain characteristics of the incoming signal. In your case 'rewarding' the production of 1 through 8 Hz (delta and theta, no alpha). For example 'neuromore' can do this, with no 'programming' required, just using their VPL Visual Programming Language boxes. [click Basic EEG Classifier menu]

    Also see BrainBay, which uses similar VPL dataflow setup.

    The current Focus widget is calling on the Brainflow ML classifiers, which are not strictly EEG band based. But rather employ Machine Learning trained models.

  • edited May 20

    Thanks, William.

    I have the Ganglion board and tried BrainFlow (loaded from here:, just loaded and installed "Setup_BrainBay.exe") , but for some reasons get error following instructions in the link you sent:
    "To stream data live from your OpenBCI board within a BrainBay design, select Insert Element -> Source -> Biosignal/EEG Amplifier and one of the OpenBCI devices." I selected "Ganglion" and get the following:


  • wjcroftwjcroft Mount Shasta, CA

    BrainBay 'devices' are sometimes confusing. My understanding is that both the OLD OpenBCI devices based on the 'Hub' concept, AND the newer devices based on Brainflow library are both present. You must select the newer Brainflow based devices.

  • Ah, got it to work! Thanks, William.

  • edited May 22

    I went through this
    and was wondering:

    • What are the units of these numbers (0.0072, .1974, .0004, etc.) - likely percengtages, from what I can tell. But percentages calculated based on what? As far as I can see from personal experimintation it's not band power b/c they do not match the band power graph.
    • I assume "threshold" is where maximum relexation will be calculated. so if set to 0.8, for example, program will think that I have hit my maximum achiavable goal when metric is 0.8, correct?
  • Thanks, William. I am afraid I do not know how to read these, though, as I am not familial with these programming languages.

  • wjcroftwjcroft Mount Shasta, CA

    The Focus Widget is not working with band powers directly, but through a trained ML Machine Learning model. That model is documented at the links. The units are likely output values from the model.

    If you want to train on 1 through 8 Hz, use one of the VPL apps such as BrainBay, neuromore, etc.

  • edited May 22

    Ok, thanks. Yeah, that looks like the way to go. I was just wondering about Focus Widget out of curiosity. Do I understand that Neuromore is free from this (their website): "Licensing the neuromore Studio starts at $3K monthly. neuromore also offers bespoke professional services to rapidly accelerate how to add the latest best practices and tecchnologies to future-proof your applications, expeirence and ecosystems. For non-commercial purposes, access our open source offerings for free."

  • wjcroftwjcroft Mount Shasta, CA

    Neuromore is free. As is BrainBay, OpenViBE, etc.

  • Awesome! Thanks. Couple of followups regarding hardware setup:

    • If I was to use just one channel for this, maximum two channels, can I use one earclip vs. two?
    • If I was to do the absolute minimum setup, can I use one electrode on one side of the forehead, and a second electrode on other side if forehead, with the end of this second cable plugged into where the earclip would normally go?
  • wjcroftwjcroft Mount Shasta, CA

    If I was to use just one channel for this, maximum two channels, can I use one earclip vs. two?

    Typical setup for neurofeedback uses reference on one ear and Bias/Ground on the other. The location of the 'active' channel electrodes depend on your protocol. For increasing 1-8 Hz, I would start at Cz or C3 / C4.

    If I was to do the absolute minimum setup, can I use one electrode on one side of the forehead, and a second electrode on other side if forehead, with the end of this second cable plugged into where the earclip would normally go?

    Note that your 'reward 1-8 Hz' protocol is going to increase slow wave activity. Doing this frontally at the forehead may not be the result you are looking for.

    Central strip is a more neutral location.

  • Cool! Thanks, William. That helps a lot. I tried Cz location and the waves seem to appear more defined there, plus - the amplitude is greater. I see that this is a better location, but did not quite understand the adhd frontal slowing reference. What did you mean?

  • wjcroftwjcroft Mount Shasta, CA
    edited May 23

    Neurofeedback can have adverse effects.

    Normally neurofeedback is preceded by an assessment / acquisition phase where the client's current situation is mapped and potential protocols compared. By up training 1-8 Hz repeatedly in the frontal or prefrontal regions, you are reinforcing part of what happens in ADHD situations, where slowing of brainwaves occurs, particularly in that area.

    Theta: Slowed Brain Rhythms
    The most robust EEG feature associated with ADHD is elevated power of slow waves (4–7Hz “theta”) and/or decreased power of fast waves (14–30Hz “beta”), typically recorded over fronto-central electrodes, which are sometimes combined and quantified by the theta/beta ratio (TBR) [8, 9].

  • Aaahhh... Interesting. Good to know! Thank you.

  • William: quick question about your BrainBay example you gave above (located here:

    If I was to use 2 or more channels/electrodes to get the data for better "average" accuracy vs. just 1,
    1. is BrainBay logic as simple as just drawing another line from "exg2" to "in" of the ".5 to 40" Filter OR, do I have to:
    2. formulate another logical sequence out of "exg2", same as what you have coming out of "exg1", and then connect the two sequances at Expression Evaluator (Ax40 in screenshot attached), but do a formula in it similar to (A+B)/2X40 as opposed to just Ax40?

  • wjcroftwjcroft Mount Shasta, CA

    Ivan, hi.

    In your annotation (1), tying two separate outputs to one input is actually illegal in dataflow / VPL systems like this. BrainBay would have likely complained if you had tried to run this design. But the error message might be cryptic. Other VPL systems might catch this as you are making the connection.

    The way to combine (average) two channels would be to use an expression block with two inputs, A and B. Then the expression would be (A+B)/2 . The output of that expression can then go to your bandpass block (.5-40). Do note that your copy of the sample design is also copying the magnitude block's ranges of alpha and beta. Your intention is to reward 1-8 Hz as I recall. I guess you could go along with the same beta logic. (The intention of the sample design is to 'inhibit' beta and reward alpha.)

    In your note (2), the '40' figure is just a fudge factor to scale the output values to work well with the media player volume input.


  • edited May 24

    Ok, thank you...
    1. Is this what you mean - see attached w/ circled 1 next to it.
    2. For the time being I was going to change your Beta weight to 0 from the .65 you had. I may play with this later (try to suppress Beta and Alpha both) but for now not touching it.
    3. To target Theta, I was just going to change your setup in 2 places from "8 to 12" to "4 to 8"

    1. I am yet to figure out how to change these names. Can you give me a hint?
  • wjcroftwjcroft Mount Shasta, CA

    That looks ok. Note that the magnitude elements internal dialog works on a center and half width idea. So your theta band would be center 6, width 2.

    I'm blanking right now on how the captions are changed. You can always check the manual. I believe there is a difference between the different ways you select the element. For example with left click, double-click, or right-click. Or it's possible you need to somehow click the graph itself.

Sign In or Register to comment.