REQ: gUSBampADC Bipolar Derivation

Forum for software developers to discuss BCI2000 software development
Locked
boulay
Posts: 382
Joined: 25 Dec 2011, 21:14

REQ: gUSBampADC Bipolar Derivation

Post by boulay » 17 Feb 2012, 00:45

I'm not very good at C++ so I'm asking for help putting bipolar derivation into the gUSBamp source module.

From the gUSBampSoftwareManual,

Code: Select all

Status = GT_SetBipolar(HANDLE hDevice, BIPOLAR bipoChannel);
Define the channels for a bipolar derivation.
The function returns true if the call succeeded otherwise it will return false.
Input:
hDevice         HANDLE       handle of the device
bipoChannel    BIPOLAR
                    Channel1     UCHAR define the channel number for the bipolar derivation with channel 1. If channel 2 is selected, g.USBamp performs a bipolar derivation between channel 1 and 2. Set the channel number to zero if no bipolar derivation should be performed.
                    Channel2    UCHAR set to channel number or 0
                    ...
                    Channel16   UCHAR set to channel number or 0

Output:
Status BOOL Status=0 command not successful
Status=1 command successful
It seems like this would be easy enough to add to the current module. I guess it is something like:

Code: Select all

BIPOLAR    BipolarDerivation
m_numdevices=Parameter("DeviceIDs")->NumValues();
int deviceChannelsOffset = 0;
for (int dev=0; dev<m_numdevices; dev++)
    {
    BipolarDerivation.Channel1=(int)Parameter("BipolarList")(deviceChannelsOffset + 0)
    .
    .
    .
    BipolarDerivation.Channel16=(int)Parameter("BipolarList")(deviceChannelsOffset + 15)

    GT_SetChannels(m_hdev.at(dev), BipolarDerivation)
    }
deviceChannelsOffset += 16;
I would prefer to iterate through the channels rather than have them typed out manually, but I don't know how to iterate through fields of a structure in C++. Also, when there's more than one device, must I have a unique BIPOLAR structure for each device (i.e., BipolarDerivation1, BipolarDerivation2, etc)? Finally, to make the module backwards compatible I would prefer to use a variable instead of directly accessing the Parameter, where the variable defaults to 0 for every device x channel and is changed only if the parameter is defined. I also do not know how to do this. Preflight would need to check that the parameter is empty or that it is the same length as SourceCh... that I can do.

So I can spend a day or so hacking something together for myself, or maybe someone else wants to do it properly and contribute it to the core? Is this a desirable feature?

-Chad

boulay
Posts: 382
Joined: 25 Dec 2011, 21:14

Re: REQ: gUSBampADC Bipolar Derivation

Post by boulay » 17 Feb 2012, 00:51

I should ask first: Is Bipolar derivation in the gUSBamp.dll different from using a [1 -1] spatial filter in BCI2000? I thought there might be some hardware tricks I don't know about.

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

Re: REQ: gUSBampADC Bipolar Derivation

Post by mellinger » 17 Feb 2012, 07:51

I should ask first: Is Bipolar derivation in the gUSBamp.dll different from using a [1 -1] spatial filter in BCI2000? I thought there might be some hardware tricks I don't know about.
A true bipolar derivation does not require an additional reference electrode. Apart from that, I'm not aware of any difference.
I would prefer to iterate through the channels rather than have them typed out manually, but I don't know how to iterate through fields of a structure in C++
It cannot be done in general, and it cannot be done in a portable way. Typically, there is no need to iterate over fields because one would use an array in this case. I don't understand why the g.tec header uses arrays in the _SCALE struct but not in the _CHANNEL struct -- that simply makes no sense to me at all, and forces you to type channels out manually.
Is this a desirable feature?
I rather don't think so. The parameterization of the problem is also confusing, because it provides way too many degrees of freedom, most of which are invalid (what does it do when you set Channel1 to 2, and Channel2 to 1? How does it select polarity? Or what does it do when you set Channel1 to 2, and Channel2 to 3?). So IMHO the effort outweighs the potential benefit, both for programming/maintaining that function, and for using it.

-Juergen

boulay
Posts: 382
Joined: 25 Dec 2011, 21:14

Re: REQ: gUSBampADC Bipolar Derivation

Post by boulay » 17 Feb 2012, 09:49

mellinger wrote:
I should ask first: Is Bipolar derivation in the gUSBamp.dll different from using a [1 -1] spatial filter in BCI2000? I thought there might be some hardware tricks I don't know about.
A true bipolar derivation does not require an additional reference electrode. Apart from that, I'm not aware of any difference.
BCI2000's spatial filtering occurs after gUSBamp's notch and band-pass filtering.
If I were to use gUSBamp's bipolar derivation, would that occur before or after gUSBamp's notch and band-pass filtering? If the bipolar derivation is after the filtering, then I agree there would be no difference.

You make a good point that parameterization is ambiguous and for that reason alone it shouldn't be included in the core. Yet if bipolar derivation occurs before 'hardware' filtering then I will hack something together for myself with the knowledge that no one else will ever get to misuse it.

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

Re: REQ: gUSBampADC Bipolar Derivation

Post by mellinger » 17 Feb 2012, 10:23

BCI2000's spatial filtering occurs after gUSBamp's notch and band-pass filtering.
If I were to use gUSBamp's bipolar derivation, would that occur before or after gUSBamp's notch and band-pass filtering? If the bipolar derivation is after the filtering, then I agree there would be no difference.
Sure, the bipolar derivation occurs before the filtering, but these filters are linear and have the same parameters, so I still don't think this make any difference.

Locked

Who is online

Users browsing this forum: Google [Bot] and 24 guests