running g.USBamp with BCI2000 using Windows 11

This forum deals with BCI2000 configuration issues.
Post Reply
mellinger
Posts: 1341
Joined: 12 Feb 2003, 11:06

Re: running g.USBamp with BCI2000 using Windows 11

Post by mellinger » 15 Apr 2024, 13:02

The gUSBdemo output seems to be screen-shot at a lower resolution than the BCI2000 signal, and later enlarged to fit. Thus, it contains fewer details than the BCI2000 signal, which would explain why there is less noise visible.
Like when the application does a roundtrip from Source to DummySignal Generator, DummyAppliction, User and Operator. Can they introduce additional noises?
They cannot introduce additional noise because the source signal is displayed directly from the amplifier. Also, the recorded signal is directly from the amplifier. Signals are not processed in an roundtrip fashion. Rather, the incoming signal is stored to to disk, and then passed on to Signal Processing and Application modules.

whwilbur
Posts: 64
Joined: 04 Jan 2024, 15:38

Re: running g.USBamp with BCI2000 using Windows 11

Post by whwilbur » 15 Apr 2024, 18:12

mellinger wrote: 15 Apr 2024, 13:02 The gUSBdemo output seems to be screen-shot at a lower resolution than the BCI2000 signal, and later enlarged to fit. Thus, it contains fewer details than the BCI2000 signal, which would explain why there is less noise visible.
Like when the application does a roundtrip from Source to DummySignal Generator, DummyAppliction, User and Operator. Can they introduce additional noises?
They cannot introduce additional noise because the source signal is displayed directly from the amplifier. Also, the recorded signal is directly from the amplifier. Signals are not processed in an roundtrip fashion. Rather, the incoming signal is stored to to disk, and then passed on to Signal Processing and Application modules.
Ok thanks. I have 3 last questions. I'll ask them all here so you would know what they are.

1. First of all. I mentioned to you before. I couldn't change the default channel from 8 to 1. So whenever I ran BCI2000. I always have 8 channels at beginning and I have to lessen channels from 8 manually until 1 is left.

Image

This is the original 8 channel config in the original gUSBamp.prm.

Image

I manually changed it to 1 channel like the following and save the prm file. Note for Channelnames, i set it blank like original and also named it.

Image

But it won't run and always has the following error in Set Config.

Image

How to properly run in 1 channel? Why can't it run in 1 channel? My batch file is this:

#! ../prog/BCI2000Shell
@cls & ..\prog\BCI2000Shell %0 %* #! && exit /b 0 || exit /b 1
#######################################################################################
## $Id: StimulusPresentation_gUSBamp.bat 7195 2023-02-07 18:31:03Z mellinger $
## Description: BCI2000 startup Operator module script. For an Operator scripting
## reference, see
## http://doc.bci2000.org/index/User_Refer ... _Scripting
##
## $BEGIN_BCI2000_LICENSE$
##
## This file is part of BCI2000, a platform for real-time bio-signal research.
## [ Copyright (C) 2000-2023: BCI2000 team and many external contributors ]
##
## BCI2000 is free software: you can redistribute it and/or modify it under the
## terms of the GNU General Public License as published by the Free Software
## Foundation, either version 3 of the License, or (at your option) any later
## version.
##
## BCI2000 is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY
## - without even the implied warranty of MERCHANTABILITY or FITNESS FOR
## A PARTICULAR PURPOSE. See the GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License along with
## this program. If not, see <http://www.gnu.org/licenses/>.
##
## $END_BCI2000_LICENSE$
#######################################################################################
Change directory $BCI2000LAUNCHDIR
Show window; Set title ${Extract file base $0}
Reset system
Startup system localhost
Start executable gUSBampSource --local --FileFormat=GDF
Start executable DummySignalProcessing --local
Start executable DummyApplication --local
Wait for Connected
Load parameterfile "../parms/fragments/amplifiers/gUSBamp.prm"


2. My second question is. Can a user add a new SignalProcessing program in the BCILauncher box? Are the apps especially written for BCI2000 by a programmer?

3. Last question. Does the BCI2000 org have special license or permission with gtec to integrate the gUSBamp.dll and acquire data? I'm asking because if there is none, then I can approach any programmer and let them write a new software that can collect data from the gUSBamp.dll and say compete with gtec g.recorder? Not that I would do it, but just curious of it.

Many thanks for all help.

mellinger
Posts: 1341
Joined: 12 Feb 2003, 11:06

Re: running g.USBamp with BCI2000 using Windows 11

Post by mellinger » 16 Apr 2024, 05:26

1. First of all. I mentioned to you before. I couldn't change the default channel from 8 to 1. So whenever I ran BCI2000. I always have 8 channels at beginning and I have to lessen channels from 8 manually until 1 is left.
So solve this problem, you can either
* use the channel list (right-click on signal display, choose "Show channel list") to select which channels to display, this will be remembered across sessions
* configure the gUSBamp to record only one channel as you tried. This seems to be broken, I will forward it to my colleague who has access to a gUSBamp.
2. My second question is. Can a user add a new SignalProcessing program in the BCILauncher box? Are the apps especially written for BCI2000 by a programmer?
Yes, they are written specially for BCI2000 by a programmer. When you compile BCI2000 yourself, you will have access to a tool that helps you create modules by creating a project template so you can easily add your own functionality.
3. Last question. Does the BCI2000 org have special license or permission with gtec to integrate the gUSBamp.dll and acquire data? I'm asking because if there is none, then I can approach any programmer and let them write a new software that can collect data from the gUSBamp.dll and say compete with gtec g.recorder? Not that I would do it, but just curious of it.
I'm not an expert on the legal issues involved, so take my word with caution: BCI2000 is based on the gtec C api which comes with gUSBamp.dll. To write and distribute a commercial closed-source program that uses gUSBamp.dll, you would probably need to obtain a license for the C api from gtec.
BCI2000 is open source and GPLed, so any program that derives from BCI2000 must be open source as well, and cannot be licensed commercially.

whwilbur
Posts: 64
Joined: 04 Jan 2024, 15:38

Re: running g.USBamp with BCI2000 using Windows 11

Post by whwilbur » 16 Apr 2024, 10:33

mellinger wrote: 16 Apr 2024, 05:26
1. First of all. I mentioned to you before. I couldn't change the default channel from 8 to 1. So whenever I ran BCI2000. I always have 8 channels at beginning and I have to lessen channels from 8 manually until 1 is left.
So solve this problem, you can either
* use the channel list (right-click on signal display, choose "Show channel list") to select which channels to display, this will be remembered across sessions
* configure the gUSBamp to record only one channel as you tried. This seems to be broken, I will forward it to my colleague who has access to a gUSBamp.
How come when I right clicked the Source Signal screen, there was no "Show channel list" option? See below. I'm using the latest version 3.6.7385 . Is this option only removed for gUSBamp or others as well? I saw in the BCI2000 site the option was there in the documentation, but not in my actual copy. Thanks.

Image

https://www.bci2000.org/mediawiki/index ... tor_Module

mellinger
Posts: 1341
Joined: 12 Feb 2003, 11:06

Re: running g.USBamp with BCI2000 using Windows 11

Post by mellinger » 16 Apr 2024, 11:55

The current release is a bit outdated. We are building a new one. Please check the download page tomorrow.

mellinger
Posts: 1341
Joined: 12 Feb 2003, 11:06

Re: running g.USBamp with BCI2000 using Windows 11

Post by mellinger » 16 Apr 2024, 15:13

Regarding the crash with SourceCh=1, this is due to an error condition that has not been handled properly. The crash will go away if you set SourceChDevices=1 as well.

whwilbur
Posts: 64
Joined: 04 Jan 2024, 15:38

Re: running g.USBamp with BCI2000 using Windows 11

Post by whwilbur » 18 Apr 2024, 11:49

mellinger wrote: 16 Apr 2024, 15:13 Regarding the crash with SourceCh=1, this is due to an error condition that has not been handled properly. The crash will go away if you set SourceChDevices=1 as well.
Yes. It works now. Thanks.

There is a problem regarding saving. After pressing Start. I can save the GDF file. But it is not consistent. For example,I made a 20 minute or so recording. It didn't save the feed except with only 36 byte contents. Is there a maximum minutes where it can't save anymore?

Also while the recording is running after pressing Start and before stopping it. Where is the feed saving to? Because the file is still 0 bytes. It is only when you stop the recording that the feed is saved. However, it didn't save the long feeds. When I load it up at EEGlab. It has this error:

Image

Again the above was loading the saved file with only 36 bytes but recording made for 20 minutes.

In the following is saved file with recording made for 8 minutes.

Image

So why didn't the 20 minute recording saved except with only 36 byte contents? How can the feed get lost? Can't it save directly to the file during recording so no data would be lost? Because let's say the 20 minute has critical data. But it didn't save. So hope you can fix it where it can always save 100%. Many thanks.

mellinger
Posts: 1341
Joined: 12 Feb 2003, 11:06

Re: running g.USBamp with BCI2000 using Windows 11

Post by mellinger » 18 Apr 2024, 16:24

There is a problem regarding saving. After pressing Start. I can save the GDF file. But it is not consistent. For example,I made a 20 minute or so recording. It didn't save the feed except with only 36 byte contents. Is there a maximum minutes where it can't save anymore?
There is no limit I'm aware of. In my tests, the GDF file was always written correctly as verified by the SigViewer tool which is the reference implementation of the GDF data format.

You may not be aware that you need to press "Start" in order to start a recording. Pressing "Set Config" is not sufficient although a live signal is being shown.

whwilbur
Posts: 64
Joined: 04 Jan 2024, 15:38

Re: running g.USBamp with BCI2000 using Windows 11

Post by whwilbur » 18 Apr 2024, 18:24

mellinger wrote: 18 Apr 2024, 16:24
There is a problem regarding saving. After pressing Start. I can save the GDF file. But it is not consistent. For example,I made a 20 minute or so recording. It didn't save the feed except with only 36 byte contents. Is there a maximum minutes where it can't save anymore?
There is no limit I'm aware of. In my tests, the GDF file was always written correctly as verified by the SigViewer tool which is the reference implementation of the GDF data format.

You may not be aware that you need to press "Start" in order to start a recording. Pressing "Set Config" is not sufficient although a live signal is being shown.
I pressed Start as I was aware just using Config won't save it. But after 20 minutes of recording, only 36 bytes was saved. But with other tests using 20 minutes or more time. The recording saved. So it is not always same error. Please download the file I saved in google drive below. It is the one where only 36 bytes is saved in spite of 20 minutes of recording. What is the content of the 36 bytes that even Sigviewer won't load, but hex editor confirmed the file is related to BCI2000? Note that even when I pressed Start and Stop immediatly, the file saved with 0.8sec data is already 533 bytes. So for the 36 bytes. It's like the 20 minutes data was not saved even for 0.1 sec although the 36 byte file created. The instance of this happening is about one for every 6 recordings.


https://drive.google.com/file/d/1j4-3Qq ... MGAdK/view

Image

whwilbur
Posts: 64
Joined: 04 Jan 2024, 15:38

Re: running g.USBamp with BCI2000 using Windows 11

Post by whwilbur » 20 Apr 2024, 21:28

mellinger wrote: 13 Apr 2024, 10:44 I must apologize, the SignalType parameter was removed from the gUSBamp source a while ago.
So you need to use either GDF or BCI2000 as the output format.
I was using signal generator in the gUSBamp previously. But when I tried to actually connect EEG electrodes in the head to it today. I found out the dc offset is off by 6mV. In the gUSBdemo. You can adjust the offset. But in the BCI2000 display. The output is just blank, because the offset is off by 6mV or so.

And here is a big problem. Based on the following configuration page. SourceChOffset seems to require SignalType which you said was removed already.

https://www.bci2000.org/mediawiki/index ... gUSBampADC

"
SignalType
Defines the data type of the stored signal samples (int16 or float32). If the data type is int16, signal samples (which are produced by the amplifier in units of πœ‡π‘‰ are converted back into virtual A/D units (see Data Storage section below). If the data type is float32, the signals are stored in units of πœ‡π‘‰. In this case, SourceChOffset should be 0, and SourceChGain should be 1 (since the conversion factor from πœ‡π‘‰ into πœ‡π‘‰ is 1).".

The above description seems to indicate tht SourceChOffset can only be other than 0 if it is not in float32. Because if it is in float32, the SoureChOffset should be 0.

With Signaltype parameter gone and no way to set SignalType to int16, but only in float32. How do you set SoureChOffset to say 6mV, and not zero? Setting SourcechOffset to 6mV required the SignalType set to Int16 (whose parameter was removed as you said).

In the launcher. Setting the SourceChOffset other can zero can produce this error:

Image

If only zero is allowed and you can't adjust the offset. How can you display real EEG signal with DC offset?

whwilbur
Posts: 64
Joined: 04 Jan 2024, 15:38

Re: running g.USBamp with BCI2000 using Windows 11

Post by whwilbur » 22 Apr 2024, 00:52

whwilbur wrote: 20 Apr 2024, 21:28
mellinger wrote: 13 Apr 2024, 10:44 I must apologize, the SignalType parameter was removed from the gUSBamp source a while ago.
So you need to use either GDF or BCI2000 as the output format.
I was using signal generator in the gUSBamp previously. But when I tried to actually connect EEG electrodes in the head to it today. I found out the dc offset is off by 6mV. In the gUSBdemo. You can adjust the offset. But in the BCI2000 display. The output is just blank, because the offset is off by 6mV or so.

And here is a big problem. Based on the following configuration page. SourceChOffset seems to require SignalType which you said was removed already.

https://www.bci2000.org/mediawiki/index ... gUSBampADC

"
SignalType
Defines the data type of the stored signal samples (int16 or float32). If the data type is int16, signal samples (which are produced by the amplifier in units of πœ‡π‘‰ are converted back into virtual A/D units (see Data Storage section below). If the data type is float32, the signals are stored in units of πœ‡π‘‰. In this case, SourceChOffset should be 0, and SourceChGain should be 1 (since the conversion factor from πœ‡π‘‰ into πœ‡π‘‰ is 1).".

The above description seems to indicate tht SourceChOffset can only be other than 0 if it is not in float32. Because if it is in float32, the SoureChOffset should be 0.

With Signaltype parameter gone and no way to set SignalType to int16, but only in float32. How do you set SoureChOffset to say 6mV, and not zero? Setting SourcechOffset to 6mV required the SignalType set to Int16 (whose parameter was removed as you said).

In the launcher. Setting the SourceChOffset other can zero can produce this error:

Image

If only zero is allowed and you can't adjust the offset. How can you display real EEG signal with DC offset?

Anyway. The following is the default shown on screen after running it where the signal can't be seen (because the signal has offset).

Image

Why is there written a 7.02mV on the left? Is it the default or does it mean it can detect the offset of the signal near 7mV? For other amplifiers. Would 7mV be displayed too or other values?

If I used Autoscale, the signal can appear on top.

Image

Why is there written 7.49mV on the left? I can't find the info at google. The gUSBamp has 250mV + - range. If the offset is say 150mV. Can it also be displayed at the Source Signal. And even if the signal can't be displayed anymore at Source Signal screen. More important can BCI2000 save the entire 250mV range to the GDF or BCI2000 file? So no signal are lost even if the offset is say at 230mV (of the 250mV +- maximum range of the unit)?

Also I need to know something. Did the BCI2000 programmers create the gUSBampSource with all the parameters or was it default by by gtec gUSBamp.ddl itself? I'm asking because I'd like to know if SampleChOffset being set to 0 (owing to difficulty programming) is due to just difficulty on the part of the BCI2000 programmers or was it because gtec limit it with inability to adjust any offset in the open source? I kept wondering why they would allow any recording software to be open source, unless there is some limit in the function? Many companies like Brainmaster or others kept it a secret, and no one can create any open source program to record their units.

I guess this is the last question. Lol. Many thanks.

mellinger
Posts: 1341
Joined: 12 Feb 2003, 11:06

Re: running g.USBamp with BCI2000 using Windows 11

Post by mellinger » 24 Apr 2024, 15:01

How can you display real EEG signal with DC offset?
To display an EEG signal with offset, apply a High Pass filter to the display. You find it in the context menu (right-click).
Why is there written a 7.02mV on the left? Is it the default or does it mean it can detect the offset of the signal near 7mV?
The latter. This the the physical unit of the display.
Note that 7mV is a huge offset. Make sure you know how to properly ground your amplifier, and how to get proper impedances when applying EEG electrodes.
More important can BCI2000 save the entire 250mV range to the GDF or BCI2000 file?
Yes, it can.
I'm asking because I'd like to know if SampleChOffset being set to 0 (owing to difficulty programming) is due to just difficulty on the part of the BCI2000 programmers or was it because gtec limit it with inability to adjust any offset in the open source?
SampleChOffset is _not_ meant to compensate large physical offsets in the EEG signal. Rather, it is meant to adjust for digital or physical offsets in the digitizer (AD converter). In a proper EEG setup, you don't have large physical offsets in the EEG signal.

whwilbur
Posts: 64
Joined: 04 Jan 2024, 15:38

Re: running g.USBamp with BCI2000 using Windows 11

Post by whwilbur » 26 Apr 2024, 18:59

mellinger wrote: 24 Apr 2024, 15:01
How can you display real EEG signal with DC offset?
To display an EEG signal with offset, apply a High Pass filter to the display. You find it in the context menu (right-click).
Why is there written a 7.02mV on the left? Is it the default or does it mean it can detect the offset of the signal near 7mV?
The latter. This the the physical unit of the display.
Note that 7mV is a huge offset. Make sure you know how to properly ground your amplifier, and how to get proper impedances when applying EEG electrodes.
More important can BCI2000 save the entire 250mV range to the GDF or BCI2000 file?
Yes, it can.
I'm asking because I'd like to know if SampleChOffset being set to 0 (owing to difficulty programming) is due to just difficulty on the part of the BCI2000 programmers or was it because gtec limit it with inability to adjust any offset in the open source?
SampleChOffset is _not_ meant to compensate large physical offsets in the EEG signal. Rather, it is meant to adjust for digital or physical offsets in the digitizer (AD converter). In a proper EEG setup, you don't have large physical offsets in the EEG signal.
Thanks. All is well now. As for the GDF having only 34 bytes sometimes. It's not often, maybe lack of memory so I'll just use a faster PC.

For the past few days. I was trying to learn how to run FFT in Matlab using the GDF file loaded in EEGLab. But it is difficult. It's like programming a new code. I have another amplifier that can save in Audacity WAV file (but lower spec than the gUSBamp). I loaded the WAV up at SigView and got the following FFT. My application is EEG/EMG hence the higher frequency.

Image

Is there any way to convert the BCI2000 GDF and DAT file format into WAV? I've been looking for the converters online but didn't find any (that worked). That way. I can convert them to WAV and load up using SigView with the above kind of FFT detail. I can't find any converter that works for GDF to EDF. When I used EEGlab to convert GDF to EDF. The software EDFbrowser can't load the EDF file with the following error:

Image

Note SigView is different from SigViewer. Also do you know any FFT software that can directly load up BCI2000 GDF file and DAT file? In Sigview, only the following file format is allowed:

Image

mellinger
Posts: 1341
Joined: 12 Feb 2003, 11:06

Re: running g.USBamp with BCI2000 using Windows 11

Post by mellinger » 28 Apr 2024, 13:20

Thanks. All is well now. As for the GDF having only 34 bytes sometimes. It's not often, maybe lack of memory so I'll just use a faster PC.
Good to hear that things are working for you. As for GDF, I actually found and fixed a bug that would lead to short or corrupted data files. When the new build is out (which takes a bit longer than I thought), you should have working GDF files.
Is there any way to convert the BCI2000 GDF and DAT file format into WAV?
For DAT, you may use the load_bcidat() mex file to load the data into Matlab. AFAIK, Matlab then allows saving data as WAV.
Also do you know any FFT software that can directly load up BCI2000 GDF file and DAT file?
BCI2000 comes with an offline analysis tool called BCI2000Analysis that is able to segment data into trials, do an FFT, and compute the average over trials. You may then train a classifier on this data:
https://www.bci2000.org/mediawiki/index ... 00Analysis

When using Matlab, as mentioned above, you can use the load_bcidat() mex file that comes with BCI2000. Matlab has a FFT() function (you might be interested in log(abs(fft(x)).

whwilbur
Posts: 64
Joined: 04 Jan 2024, 15:38

Re: running g.USBamp with BCI2000 using Windows 11

Post by whwilbur » 28 Apr 2024, 22:36

mellinger wrote: 28 Apr 2024, 13:20
Thanks. All is well now. As for the GDF having only 34 bytes sometimes. It's not often, maybe lack of memory so I'll just use a faster PC.
Good to hear that things are working for you. As for GDF, I actually found and fixed a bug that would lead to short or corrupted data files. When the new build is out (which takes a bit longer than I thought), you should have working GDF files.
Is there any way to convert the BCI2000 GDF and DAT file format into WAV?
For DAT, you may use the load_bcidat() mex file to load the data into Matlab. AFAIK, Matlab then allows saving data as WAV.
Also do you know any FFT software that can directly load up BCI2000 GDF file and DAT file?
BCI2000 comes with an offline analysis tool called BCI2000Analysis that is able to segment data into trials, do an FFT, and compute the average over trials. You may then train a classifier on this data:
https://www.bci2000.org/mediawiki/index ... 00Analysis

When using Matlab, as mentioned above, you can use the load_bcidat() mex file that comes with BCI2000. Matlab has a FFT() function (you might be interested in log(abs(fft(x)).
I went to this BCI2000 mex reference page https://www.bci2000.org/mediawiki/index ... _MEX_Files

I was able to load testdata.dat like this as instructed (the testdata.dat is in the mex directly in BCI2000)

[ signal, states, parameters, total_samples, file_samples ] = load_bcidat ('testdata.dat')

However, I just learnt Matlab a week ago only and learnt how to do simple fft like Y = fft (X) by running the following example for instance:

Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
S = 0.8 + 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
X = S + 2*randn(size(t));
plot(1000*t,X)
title('Signal Corrupted with Zero-Mean Random Noise')
xlabel('t (milliseconds)')
ylabel('X(t)')

Y = fft(X);
plot(Fs/L*(0:L-1),abs(Y),'LineWidth',0.01)
title('Complex Magnitude of fft Spectrum')
xlabel('f (Hz)')
ylabel('|fft(X)|')

The above example can run (try it). When I changed it to X = signal, and Y = fft (X). It won't run anymore with the following error:

Error using plot
Vectors must be the same length.

If I used Y = fft (signal), the following is the error

Undefined function 'fft' for input arguments of type 'int16'.

How do you put the entire BCI2000 testdata.dat into X? Ok. It would be taxing to learn each step as it is complicated, and I know this thread and forum is not about Matlab tutorial. Can you please share the complete codes that would run the FFT of the BCI2000 dat file loaded into Matlab using the load_bcidat ('testdata.dat') with the same simple FFT like the output of the above codes I saw (pls run it to see the figure)? This is the only request for a code I'd ever ask. Hehe. From there I'd learn on my own. But I just need the completes code now how to run the FFT in Matlab of the data loaded from load_bcidat. The output must show the frequency from 0 to 1000Hz in the horizonal frequency range with the same linewidth of 0.01 so the peaks and noise floor can be distinguished. My signal is near the noise floor that is why i need FFT.

I actually tried asking about spectopo in eeglab in the whole internet but no one is even replying me in any matlab help forum as not much matlab people knows about eeglab. I can't log in Mathwork site to ask and can't join the eeglab mailing list. So I want to do the FFT pure Matlab way (so I learnt about it too without using eeglab which just uses the welsh method and not pure FFT showing the noise floor). Again I just learnt about Matlab a week ago so can't on my own put the entire BCI2000 *.dat into X to make Y = fft (X) even work in pure MATLAB. It would take months of learning Matlab just to do it. So kindly share the complete code, just this one request only, promise. Lol. Then let me end the thread after getting the codes so I can see the FFT.

Thank you!

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests