Page 1 of 2

OpenBCI Channel Gain specification

Posted: 19 Mar 2024, 13:43
by parguello
Good morning,

I am trying to lower the channel gain on the OpenBCI amp using BCI2000.
Reason being is that the x24 default gain is too high for my active electrode system; it rails it.
Currently, I am using the OpenBCISource module to try and achieve this, but I'm having issues giving a valid parameter entry.

Within the parameter file are the following lines of interest:
Source:Signal%20Properties list SourceChGain= 1 auto // gain for each channel (allow_override)
Source:OpenBCIADC list ChannelsGain= 1 auto 1 1 % // The channel gains 1 2 4 6 8 24 (default)

First question is, which one would I have to edit to reduce the channel gain from x24 to x1?
I've been playing w/ the second line only, leading me to my second question: what would be a valid entry for this parameter?
Editing the line itself, I've tried changing 'auto' to 1; when I run BCI2000, it complains that I need to specify a gain for all channels.
I've also tried entering something like '1 1 1 1 1 1 1 1' in the GUI, assuming that I'm specifying a gain of 1 for each of the eight channels.

When I do that, BCI2000 complains that value at index 8 is out of range or something like that.
I've referred to https://www.bci2000.org/mediawiki/index ... Definition but I've had little success w/ it.

Thank you for any help and suggestions!

Re: OpenBCI Channel Gain specification

Posted: 19 Mar 2024, 16:27
by mellinger
When you edit a parameter line by hand, you need to be aware of the following rules:
* For list valued parameters (such as ChannelsGain and SourceChGain), you need to specify the number of entries first (8 in your case), and then the entries themselves.
* For matrix valued parameters, the number of rows is specified first, then the number of columns.

If you specify more than the exact number of entries, they may be interpreted as range information, resulting in error messages as the one you experienced.

Re: OpenBCI Channel Gain specification

Posted: 20 Mar 2024, 12:09
by parguello
Thank you so much for the prompt reply!

Alright, by default the parameter line reads:
Source:OpenBCIADC list ChannelsGain= 1 auto 1 1 % // The channel gain can be 1 2 4 6 8 12 24 (default)

I'd like to specify that all eight channels should be of gain 1.
Using your suggestion for list datatypes, as well as the documentation https://www.bci2000.org/mediawiki/index ... Definition, the line now reads:
Source:OpenBCIADC list ChannelsGain 8 1 1 1 1 1 1 1 1 1 1 % // The channel gain can be 1 2 4 6 8 12 24 (default)

The system log still spits out the same error: Row index 8 out of range when accessing parameter ChannelsGain.

Re: OpenBCI Channel Gain specification

Posted: 27 Mar 2024, 08:57
by mellinger
Source:OpenBCIADC list ChannelsGain 8 1 1 1 1 1 1 1 1 1 1 % // The channel gain can be 1 2 4 6 8 12 24 (default)
It seems you are missing an equals sign there, it should be

Code: Select all

Source:OpenBCIADC list ChannelsGain= 8 1 1 1 1 1 1 1 1 1 1 % // The channel gain can be 1 2 4 6 8 12 24 (default)

Re: OpenBCI Channel Gain specification

Posted: 12 Aug 2024, 12:12
by parguello
I've decided to try once more w/ active electrodes in my project. I am still working w/ 8 channels, trying to lower it to a gain of 1x. Unfortunately, I'm still running into the same issue as before, w/ BCI2000 complaining of:

Code: Select all

2024-08-12T08:58:55.397 - SignalSource error, DataIOFilter::AutoConfig: OpenBCIADC::AutoConfig:
Row index 8 out of range when accessing parameter ChannelsGain.
To no avail, I've tried several times editing the line that I thought controlled the gain for each channel, w/ it reading:

Code: Select all

Source:OpenBCIADC list ChannelsGain= 8 1 1 1 1 1 1 1 1 24 1 % // The channel gain can be 1 2 4 6 8 12 24(default)
However, I did notice that there is another place in the parameter file that mention something along the lines of channel gain:

Code: Select all

Source:Signal%20Properties list SourceChGain= 1 auto // gain for each channel (A/D units per physical unit) (allow_override)
On inspecting the original BCI2000 error, the complaint seems to be w/ respect to the following module: DataIOFilter. My parameter file doesn't have any such module implemented. Turning to the OpenBCI.prm parameter file that came by default, I noticed that it contains the following line my parameter file does not:

Code: Select all

Source:Signal%20Properties:DataIOFilter list SourceChGain= 1 auto // gain for each channel (A/D units per physical unit)
My questions are:
  • Is it necessary to include all three of these channel gain specifications in my parameter file?
  • How, exactly, do I specify that I want all 8 channels to have a gain of 1?
  • What is DataIOFilter?

Re: OpenBCI Channel Gain specification

Posted: 12 Aug 2024, 13:53
by parguello
Also, I cannot help but wonder if AutoConfig is leading to the index out-of-range-error.

Code: Select all

2024-08-12 09:51:25: Error: [SignalSource] DataIOFilter::AutoConfig: OpenBCIADC::AutoConfig: this value will be automatically setted.
2024-08-12 09:51:25: Error: [SignalSource] DataIOFilter::AutoConfig: OpenBCIADC::AutoConfig: source channel gain will be automatically calculated. This value can be change by changing ChannelsGain.
2024-08-12 09:51:25: Error: [SignalSource] DataIOFilter::AutoConfig: OpenBCIADC::AutoConfig: Row index 8 out of range when accessing parameter ChannelsGain.
I tried turning it off the AutoConfig protocol extension in the parameter file but it doesn't seem to work.

Re: OpenBCI Channel Gain specification

Posted: 13 Aug 2024, 18:13
by mellinger
Hi,

could it be that AutoConfig assumes more than 8 channels? What is your SourceCh parameter set to?

Sorry for the late reply.

Re: OpenBCI Channel Gain specification

Posted: 14 Aug 2024, 11:45
by parguello
No worries; I appreciate you taking the time to help me out!

My SourceCh parameters:

Code: Select all

Source:Signal%20Properties int SourceCh= 8 // number of digitized and stored channels (allow_override)
Source:Signal%20Properties:DataIOFilter int SourceCh= 8 // number of digitized and stored channels


Re: OpenBCI Channel Gain specification

Posted: 14 Aug 2024, 17:43
by mellinger
If the ShowLostPackages parameter is set to 1, the source module sets SourceCh to one more channel (9 in this case). You need to provide 9 values in SourceChGain and SourceChOffset then.

Re: OpenBCI Channel Gain specification

Posted: 15 Aug 2024, 12:01
by parguello
The ShowLostPackages parameter is set to 0. I am still getting errors.

But while on the subject of setting gain values, is it necessary to have 3 places to specify the channel gains in the parameter file?
I'm looking at the following:

Code: Select all

Source:Signal%20Properties:DataIOFilter list SourceChGain= 1 auto // gain for each channel (A/D units per physical unit)
Source:OpenBCIADC list ChannelsGain= 1 auto 24 1 % // The channel gain can be 1 2 4 6 8 12 24(default)
Source:Signal%20Properties list SourceChGain= 1 auto // gain for each channel (A/D units per physical unit) (allow_override)
The first and second I find in the parameter file for OpenBCI's amp. The third I found in the CursorTask_SignalGenerator parameter file. Because I am using OpenBCI's amp for the CursorTask, my parameter file has all three.

Re: OpenBCI Channel Gain specification

Posted: 15 Aug 2024, 12:28
by mellinger
Parameters with the same name (part before the = ) are identical. If you specify a parameter multiple times in a parameter with different values, the last ones will be accepted.

Re: OpenBCI Channel Gain specification

Posted: 15 Aug 2024, 12:36
by mellinger
Regarding the ChannelsGain parameter, I don't see why it exists. It seems the values of the SourceChGain parameter are constructed from the ChannelsGain parameter and carry essentially the same information.

Try setting SourceChGain to "auto" (i.e. SourceChGain= 1 auto // ) and set ChannelsGain to a list containing 8 entries.

Re: OpenBCI Channel Gain specification

Posted: 15 Aug 2024, 13:01
by parguello
mellinger wrote: 15 Aug 2024, 12:28 Parameters with the same name (part before the = ) are identical. If you specify a parameter multiple times in a parameter with different values, the last ones will be accepted.
Even if they have different Sections? (i.e. Source:Signal%20Properties:DataIOFilter versus Source:Signal%20Properties)
mellinger wrote: 15 Aug 2024, 12:36 Regarding the ChannelsGain parameter, I don't see why it exists. It seems the values of the SourceChGain parameter are constructed from the ChannelsGain parameter and carry essentially the same information.

Try setting SourceChGain to "auto" (i.e. SourceChGain= 1 auto // ) and set ChannelsGain to a list containing 8 entries.
Here is the pertinent part of my params file:

Code: Select all

Visualize:Property%20Sets matrix VisPropertySets= 0 1 // row titles are properties in the form "SRCD.Left", columns are property sets
System:Version matrix OperatorVersion= { Framework Revision Build Config Protocol } 1 3.6.7841.2 7841.2,%202024-02-15T14:10:10Z MSVC-19.39.33519.0-AMD64,%20release,%202024-02-21T17:48:19Z,%20xenou@DESKTOP-C68P0S5 USE_OPENMP:ON%20USE_PRECOMPILED_HEADERS:ON%20USE_ASSERTS_IN_RELEASE_BUILDS:OFF 2.3 // operator module version information (noedit)(readonly)
System:Protocol int AutoConfig= 1 1 0 1 // Use AutoConfig protocol extension (boolean)
System:Protocol int OperatorBackLink= 1 1 0 1 // Send final state and signal information to Operator (boolean)
System:Core%20Connections string OperatorIP= 127.0.0.1 127.0.0.1 % % // the Operator module's IP (noedit)(readonly)
Source:Signal%20Properties int SourceCh= auto // number of digitized and stored channels (allow_override)
Source:Signal%20Properties int SampleBlockSize= auto // number of samples transmitted at a time (allow_override)
Source:Signal%20Properties int SamplingRate= auto // sampling rate (allow_override)
Source:Signal%20Properties list SourceChGain= 1 auto // gain for each channel (A/D units per physical unit) (allow_override)
Source:Signal%20Properties list ChannelNames= 1 auto // list of channel names (allow_override)
Source:Signal%20Properties list SourceChOffset= 1 auto // Offset for channels in A/D units (allow_override)
Storage:Data%20Location string DataDirectory= ../data ..\data % % // path to top level data directory (directory)
Storage:Session string SubjectName= cursorTaskTest Name % % // subject alias
Storage:Session string SubjectSession= 001 001 % % // three-digit session number
Storage:Session string SubjectRun= 01 00 % % // two-digit run number
Storage:Documentation string ID_System= % // BCI2000 System Code
Storage:Documentation string ID_Amp= % // BCI2000 Amp Code
Storage:Documentation string ID_Montage= % // BCI2000 Cap Montage Code
Visualize:Timing int VisualizeTiming= 0 1 0 1 // visualize system timing (0=no, 1=yes) (boolean)
Visualize:Source%20Signal int VisualizeSource= 1 1 0 1 // visualize raw brain signal (0=no, 1=yes) (boolean)
Visualize:Source%20Signal int VisualizeSourceDecimation= 1 auto % % // decimation factor for raw brain signal
Visualize:Source%20Signal int VisualizeSourceBufferSize= auto auto % % // number of blocks to aggregate before sending to operator
Visualize:Source%20Signal int VisualizeSourceTime= 2s 8s 0 % // how much time in Source visualization
Visualize:Source%20Signal int SourceMin= auto // raw signal vis Min Value
Visualize:Source%20Signal int SourceMax= auto // raw signal vis Max Value
Source:OpenBCIADC string PortName= auto // This software can automatically detect connection
Source:OpenBCIADC list ChannelsGain= 8 1 1 1 1 1 1 1 1 24 1 % // The channel gain can be 1 2 4 6 8 12 24(default)
Source:OpenBCIADC intlist SourceChList= 1 auto 16 1 % // The default source channel list is 1 2 3 4 5 6 7 8
Source:OpenBCIADC int ShowLostPackages= 0 1 0 1 
This result in the following error:

Code: Select all

2024-08-15T09:59:06.158 - SignalSource error, DataIOFilter::AutoConfig: OpenBCIADC::AutoConfig:
Row index 8 out of range when accessing parameter ChannelsGain.

Re: OpenBCI Channel Gain specification

Posted: 16 Aug 2024, 11:58
by mellinger
There was a bug in the OpenBCIADC source code, which I fixed. Please update from SVN and recompile.

Re: OpenBCI Channel Gain specification

Posted: 19 Aug 2024, 12:56
by parguello
I updated from SVN, recompiled, and that seems to have worked!
BCI2000 is now accepting the parameter line:

Code: Select all

Source:OpenBCIADC list ChannelsGain= 8 1 1 1 1 1 1 1 1 auto 24 1 % // The channel gain can be 1 2 4 6 8 12 24(default)
And the EEG signals appear to be scaled accordingly.
Can't wait to swap out and test the active electrodes.

Thanks a ton Dr. Mellinger, really appreciate it! :D