Acquiring GSR signal in BCI2000

This forum deals with BCI2000 configuration issues.
ikara
Posts: 35
Joined: 25 Mar 2011, 08:18

Acquiring GSR signal in BCI2000

Post by ikara » 10 Jun 2011, 07:16

Hi,
I would like to know if it's possible to acquire GSR (Galvanic Skin Response) Signal in the BCI2000 platform.
I've tried the AppConnector Example application but although it seems to be calibrated fine (send=true receive=true)
and BCI2000 and Matlab (which records the GSR Signal) are appropriately configured (UDP IPs and Ports),
it crashes as soon as I hit the "Start" button in operator.

Is there any possible way to pass the GSR Signal from Matlab to BCI2000, in order to have it synced with the EEG Signals, so that I can have event labels/states of StimulusPresentation on the GSR Signal as well?

I've read the wiki extensively and some posts here concerning the App Connector, but I didn't have any success in what I'm trying to do. Any piece of advice would be helpful :)

Thank you in advance
Ioannis Karavasilis

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

Re: Acquiring GSR signal in BCI2000

Post by mellinger » 10 Jun 2011, 10:34

Hi,

the AppConnector interface is provided to link BCI2000 with external programs that can read and manipulate its internal state. It cannot be used to read in data from external devices.

The AppConnector example is provided to show how to access BCI2000 internal state from an external program. It cannot be used as a link itself, e.g. to Matlab.

I guess that your GSR device connects to Matlab via UDP as well, right? Then what you need to do is to write a small BCI2000 component, a so-called "logger", which maintains a UDP connection to the device, and writes the current device state into a so-called "bci event". Documentation for how to write a logger can be found at
http://www.bci2000.org/wiki/index.php/P ... put_Logger.
An example how to use the SockStream interface in BCI2000 to read and write via a UDP connection can be found at src/contrib/AppConnectorApplications/SimpleExample.

Hope this helps,
Juergen

ikara
Posts: 35
Joined: 25 Mar 2011, 08:18

Re: Acquiring GSR signal in BCI2000

Post by ikara » 11 Jun 2011, 04:14

Thanks Juergen, I will check it out this weekend!

But since I'm not to keen on programming let me ask you another question:
If I manage to acquire the GSR Signal through g.USBamp (they both come from g.tec and if I'm not mistaken with the proper cable you can connect g.GSRSensor to g.USBamp) is there a way in BCI2000 to define specific channels (EEG) on which the classification/p300 extraction will take place while at the same time being able to have additional channels (GSR) on which NO classification/p300 extraction will be performed?
Thus having the best of both worlds (EEG Signal and GSR Signal with state variables/event markers), without having to code?

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

Re: Acquiring GSR signal in BCI2000

Post by mellinger » 17 Jun 2011, 10:43

Yes, you may specify a subset of channels to process in the TransmitChList parameter of the online system. A similar option is provided in the P300Classifier program.

So you can record the GSR signal into an additional amplifier channel, and exclude that channel from P300 classification.

Regards,
Juergen

ikara
Posts: 35
Joined: 25 Mar 2011, 08:18

Re: Acquiring GSR signal in BCI2000

Post by ikara » 17 Nov 2011, 11:54

I'm using g.USBamp and g.GSRsensor in a speller experiment.
Both signals from the (8) active EEG electrodes AND the g.GSRsensor go through the g.USBamp amplifier.
System: WIN XP SP3, BCI2000 3.0.2

I'm having a hard time with the Source settings
I believe I've set up everything correctly (I'm posting the .prm file for a better insight)
In order for the GSR signal not to be taken account during the P300 Classification
TransmitChList must not contain the gsr channel

But I have some questions:
SourceChOffset must be 0 also for the GSR channel?
SourceChGain must be 0.019? (or 1)


I've only connected the GSR sensor to the amplifier to run some tests, and it seems to
generate a lot of artifacts in the other channels (even in the absence of electrodes)

Is there something wrong in the .prm file I'm using?
Has anyone else tried acquiring simultaneously EEG and GSR signal in BCI2000?
Any information? Any other settings I should look into?

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

Re: Acquiring GSR signal in BCI2000

Post by mellinger » 18 Nov 2011, 09:46

But I have some questions:
SourceChOffset must be 0 also for the GSR channel?
SourceChGain must be 0.019? (or 1)
With the current g.USBamp source module, these settings are arbitrary unless you use an integer format for data storage. When using "float32" for data storage, you may use any values here. They will be used to convert data from muVolts into virtual AD units, which will then be stored to disk. On reading data back (e.g. using load_bcidat in MATLAB with the '--calibrated' option), these values will be used again to convert data back into muVolts. This scheme was chosen to allow for efficient data storage in the "int16" format.

So, to minimize confusion, it is probably best to use the same values for the GSR channel as for the remaining channels. Then, when you have EEG data in muVolts, you will know that the GSR channel is in muVolts as well. From there, you may then use the g.GSRsensor specification to convert from muVolts into (presumably) kOhms.
I've only connected the GSR sensor to the amplifier to run some tests, and it seems to
generate a lot of artifacts in the other channels (even in the absence of electrodes)
You _always_ need to short-circuit the inputs of unused channels, i.e. for each channel, connect the positive input with the negative input, and both to ground. You should have got a special cable with your amplifier, which has a number of wired plugs all connected together, all in the same color (usually black).

Best regards,
Juergen

ikara
Posts: 35
Joined: 25 Mar 2011, 08:18

Re: Acquiring GSR signal in BCI2000

Post by ikara » 21 Nov 2011, 05:43

So if I'm not mistakes when I use float32 instead of int16
I can fill in the SourceChGain with "1" and no conversion will take place according to this formula:

Image
stored samples are gonna be identical to the acquired ones (in muVolts)
and from there I can convert muVolts to Siemens (for the gsr)

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

Re: Acquiring GSR signal in BCI2000

Post by mellinger » 21 Nov 2011, 07:32

The conversion will always take place. When using SourceChGain=1 and SourceChOffset=0, its result will just be identical to the original value.

ikara
Posts: 35
Joined: 25 Mar 2011, 08:18

Re: Acquiring GSR signal in BCI2000

Post by ikara » 29 Nov 2011, 10:24

I'm returning to this topic because I have some questions regarding the CommonReference and CommonGround values in the source tab. I'm using g.USBamp to acquire EEG signal (8 active electrodes + GND + REF) through GAMMAbox (GAMMAbox outputs are connected only to the first two blocks of the g.USBamp)

For the GSR Signal, I'm using a g.GSRSensor, that gives 1 signal channel (directly connected in channel 9 of the third block of the g.USBamp amplifier) as well as ground and reference (also directly connected to the respective GND and REF inputs of the third block)

My question therefore is:
Since I'm gonna be acquiring both EEG and GSR signals through g.USBamp, should I have the CommonGround and CommonReference values set to true? Or will that affect any of my signals? (having in mind that EEG and GSR signals have different references and grounds connected in the amplifier)
What is the suggested option in my case?

Thank you in advance,
Ioannis Karavasilis

ikara
Posts: 35
Joined: 25 Mar 2011, 08:18

Re: Acquiring GSR signal in BCI2000

Post by ikara » 07 Dec 2011, 12:07

Another question I'd like to ask is how can I apply different filters to different channels of the gUSBamp amplifier.
Since EEG signal needs a BP filter between 0.1-60Hz and GSR a LP filter with cutoff frequency at 1Hz, I was wondering
if it is possible to apply a different filter for my EEG Signal (channels 1-8) and another one for GSR signal (channel 9)

After contacting g.tec they told me that it is possible to use different filters for different channels, but since I'm using BCI2000
they told me that I should synch with you for further details on how this can be done.

As much as I digged into the wiki and forum, I couldn't find any information regarding the issue described above.
Can anybody shed some light in this area?

Thanks in advance
Ioannis Karavasilis

ikara
Posts: 35
Joined: 25 Mar 2011, 08:18

Re: Acquiring GSR signal in BCI2000

Post by ikara » 22 Dec 2011, 06:59

Anyone? :?: :roll:

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

Re: Acquiring GSR signal in BCI2000

Post by mellinger » 22 Dec 2011, 12:23

BCI2000 does not support different filter settings for different channels. You would need to introduce that support on your own.

Basically, there are two possibilities:
1) Use the filter inside the g.USBamp, You would need to add support for this in the g.USBamp ADC filter class. There, filter settings are handled already, just not individually for single channels. It should be straightforward to generalize the code, though.
The downside of this approach is that you lose information about the original signal, because it will be saved by BCI2000 in filtered form.
2) Create your own filter inside the BCI2000 signal processing module. To do this, you might start by adding the so-called SourceFilter to your signal processing module, by inserting
BCI2000_INCLUDE( "SOURCEFILTER" )
into your signal processing module's CMakeLists.txt file. Again, that filter does not support individual filter settings. As in option 1), generalization of the code will be straightforward.

Please ask on this forum if you need further help.

Regards,
Juergen

ikara
Posts: 35
Joined: 25 Mar 2011, 08:18

Re: Acquiring GSR signal in BCI2000

Post by ikara » 23 Dec 2011, 09:42

Thanks mellinger for the reply,
I was actually looking at the SourceFilter code, in my attempt to understand how it works,
but I couldn't find any explicit information regarding specific channels.
I looked on SourceFilter.cpp IIRFilterBase.cpp and FilterDesign.cpp

The idea is to obtain RAW signal from the g.USBamp and then bandpass just the EEG signal 0.1-60Hz
using SourceFilter (channels 1-8) while leaving GSR signal (channel 9) as it is. Could you provide me with
any insight on how can this be done (essentially which .cpp files and variables I'm gonna have to tweak)


Also a question which still remains unanswered, should CommonGround and CommonReference be set
to False (since I have 2 different grounds and 2 different references one for EEG and the other for GSR signal)

Looking forward to your reply,
And wish you all a Merry Christmas

Ioannis

gschalk
Posts: 615
Joined: 28 Jan 2003, 12:37

Re: Acquiring GSR signal in BCI2000

Post by gschalk » 23 Dec 2011, 09:53

You need to set the CommonGround and CommonReference parameters to false since they are connected externally and you do not want the amp to connect them together internally.

Gerv

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

Re: Acquiring GSR signal in BCI2000

Post by mellinger » 09 Jan 2012, 13:58

Could you provide me with
any insight on how can this be done (essentially which .cpp files and variables I'm gonna have to tweak)
You will need to modify IIRFilterBase.cpp such that the filter is applied only to specific channels, and data from remaining channels is just copied through.
You can do that by introducing a new member variable of type std::vector<bool>. In Initialize(), resize that variable to the number of channels present in the input signal. For channels that should be filtered, assign "true", for channels that should not be filtered, assign "false". You may want to read that from a parameter, but it is not necessary provided that your configuration does not change.
In Process(), there is a loop over channels. Use the channel's index to check for the value of the respective entry in the bool vector you created. Use an if-else construct within the channel loop to read output data from the filter output when that entry is set to "true", and to read output data directly from input data when that entry is set to "false".

If this proves too difficult, please ask someone with programming skills to help you.

Best regards,
Juergen

Locked

Who is online

Users browsing this forum: No registered users and 0 guests