Configuration for Cursor Task (Motor Imagery)
-
athanoid
- Posts: 17
- Joined: 30 Jul 2014, 11:36
Configuration for Cursor Task (Motor Imagery)
Hi all,
I'm using g.mobilabplus and I'm trying to use the Cursor Task example for left and right control only.
I've completed the offline analysis acquiring all the appropriate information needed for the classifier but I need some help because I don't seem to get good results from the Cursor Task sessions.
Here is my electrode montage with 8 channels: From my offline analysis CP4 was selected for left movement at 15Hz and CP3 for right movement at 18Hz based on the r^2 values.
I would appreciate if i could get some help in adding the weights in the spacial filter (see attached) and more importantly some help in the BufferConditions: So far the feedback I get from the CursorTask seems still random and I'm not sure if it's optimized through these settings.
Thanks in advance.
I'm using g.mobilabplus and I'm trying to use the Cursor Task example for left and right control only.
I've completed the offline analysis acquiring all the appropriate information needed for the classifier but I need some help because I don't seem to get good results from the Cursor Task sessions.
Here is my electrode montage with 8 channels: From my offline analysis CP4 was selected for left movement at 15Hz and CP3 for right movement at 18Hz based on the r^2 values.
I would appreciate if i could get some help in adding the weights in the spacial filter (see attached) and more importantly some help in the BufferConditions: So far the feedback I get from the CursorTask seems still random and I'm not sure if it's optimized through these settings.
Thanks in advance.
-
boulay
- Posts: 382
- Joined: 25 Dec 2011, 21:14
Re: Configuration for Cursor Task (Motor Imagery)
Your spatial filter is a bit curious. I think you are trying to emulate the Laplacian approximation that is common in EEG, but in your case is not relevant because you do not have the channel coverage. You may still re-reference, but it might be better to find the channel weights using a machine learning algorithm rather than guess at it. If this is unfamiliar to you, then maybe you should keep CP3 as +1 and the other columns as 0, this way it will use the ear reference. This is probably what was used for the offline analysis.
Spatial Filter docs.
Your BufferConditions seem fine, assuming TargetCode==2 is your 'right hand' condition, and TargetCode==1 is your 'left hand' condition.
Normalizer docs.
I like to convert my spectral amplitude to power in dB using the ExpressionFilter before passing it off to the normalizer (because EEG power in dB tends to be more normally distributed than amplitude).
You can also play around with your smoothing time constants to see if that helps. Some people like the feedback to be fast, even if noisy, while others like the feedback to be smooth, even if that adds a delay.
Spatial Filter docs.
Your BufferConditions seem fine, assuming TargetCode==2 is your 'right hand' condition, and TargetCode==1 is your 'left hand' condition.
Normalizer docs.
I like to convert my spectral amplitude to power in dB using the ExpressionFilter before passing it off to the normalizer (because EEG power in dB tends to be more normally distributed than amplitude).
You can also play around with your smoothing time constants to see if that helps. Some people like the feedback to be fast, even if noisy, while others like the feedback to be smooth, even if that adds a delay.
-
athanoid
- Posts: 17
- Joined: 30 Jul 2014, 11:36
Re: Configuration for Cursor Task (Motor Imagery)
Thanks for the prompt reply.
Do i get from somewhere the classification %?
Also, how can i have a continuous cursor control (without trials) in order to have online control of an external application (e.g. VR).
Do i get from somewhere the classification %?
Also, how can i have a continuous cursor control (without trials) in order to have online control of an external application (e.g. VR).
-
boulay
- Posts: 382
- Joined: 25 Dec 2011, 21:14
Re: Configuration for Cursor Task (Motor Imagery)
Some of the application modules keep track of online performance then give you a % accuracy. I believe the Cursor task does this. Maybe there's a parameter to turn this on? I'm sorry, I never used it. Offline analysis techniques can also tell you what the accuracy could have been, but that is a complicated thing involving signal processing and machine learning.athanoid wrote:Do i get from somewhere the classification %?
A couple of us are working on a way to make this easier. I'd rather not spend time describing how to get it done now seeing as we hope to have a better way to do it in about 1 month. Truthfully, we haven't spent much time on it because we don't have our VR hardware yet and (at least for me) my project hasn't called for me to work on it yet, but it will in about 2 weeks.athanoid wrote:Also, how can i have a continuous cursor control (without trials) in order to have online control of an external application (e.g. VR).
Our first target engine is Unreal Engine 4. What do you plan to use for VR?
-
athanoid
- Posts: 17
- Joined: 30 Jul 2014, 11:36
Re: Configuration for Cursor Task (Motor Imagery)
I'm using Unity3D and I'm currently getting data via UDP for virtual hand movement but I need continuous control.boulay wrote: Our first target engine is Unreal Engine 4. What do you plan to use for VR?
-
boulay
- Posts: 382
- Joined: 25 Dec 2011, 21:14
Re: Configuration for Cursor Task (Motor Imagery)
BCI2000 sends data in blocks. Is the rate that the blocks are being sent insufficient, is that why it appears non-continuous? I don't think there's anyway to get real continuous control unless you set your block size to 1, but I'm sure your hardware can't handle that.
I used (py)OGRE for BCI2000-controlled virtual reality. Setting the position of the virtual hand (libhand, FYI) with the BCI signal was rather jarring. Instead, we used animations for a much better effect. Don't use the control signal from BCI2000 to set the position of the virtual object, use it to set the speed of the object's animation.
I used (py)OGRE for BCI2000-controlled virtual reality. Setting the position of the virtual hand (libhand, FYI) with the BCI signal was rather jarring. Instead, we used animations for a much better effect. Don't use the control signal from BCI2000 to set the position of the virtual object, use it to set the speed of the object's animation.
-
athanoid
- Posts: 17
- Joined: 30 Jul 2014, 11:36
Re: Configuration for Cursor Task (Motor Imagery)
Yes, that's a good idea for using the animation speed instead of the position, i was thinking something similar.boulay wrote:BCI2000 sends data in blocks. Is the rate that the blocks are being sent insufficient, is that why it appears non-continuous? I don't think there's anyway to get real continuous control unless you set your block size to 1, but I'm sure your hardware can't handle that.
I used (py)OGRE for BCI2000-controlled virtual reality. Setting the position of the virtual hand (libhand, FYI) with the BCI signal was rather jarring. Instead, we used animations for a much better effect. Don't use the control signal from BCI2000 to set the position of the virtual object, use it to set the speed of the object's animation.
Would you think that if i move Cz, Pz to FC3, FC4 (see figure below) i will get better results for left/right hand movement? I Still a get a bad performance on the cursor task.
-
boulay
- Posts: 382
- Joined: 25 Dec 2011, 21:14
Re: Configuration for Cursor Task (Motor Imagery)
With the references so close to the "active" channels, you might be missing the SMR if it is not directly below C3.
Probably one of the more common montages for sensorimotor rhythm is the large laplacian approximation over C3 and another over C4.
C3_OUT = C3 - 0.25*(F3+T7+Cz+CP3)
C4_OUT = C4 - 0.25*(F4+Cz+T8+P4)
This can be further enhanced by actually weighting each channel by its physical distance to the active channel. If you don't have the actual distance measurements, you can use a model. See EEGLAB's default channel locations map to get physical coordinates of each channel in a model.
The above requires 9 channels. Do you only have 8 channels? If so, you can come up with another montage but try to get reference channels in each direction. In the figure you attached, C3 does not have a medial reference, thus any signal originating near the midline -- or even contralaterally -- will be larger in C3 than in the other channels and thus will be enhanced by this spatial filter. Simply moving CP3->CP1 and CP4->CP2 might be better.
If you are still having trouble then I would do the following:
-Put all 8 of your channels over one hemisphere's sensorimotor cortex, e.g. on and around C3.
-In task 1, do actual movements (not motor imagery). Try rolling a ball in your hand.
-In task 2, count backwards from 100 in steps of 7.
-Derive bipolar channels using every possible pairwise combination of channels.
-Also get a few more channels using various Laplacian approximations.
-View the spectra (+ error bars) for both tasks for each new channel derivation. If you find some channels work better than others, try to see if that correlates with a position on the scalp. Maybe your (subject's) SMR is not directly below C3.
-Try drinking caffeine before the recording.
If all that fails, try a different person. Not everyone has an accessible SMR. I'm not sure why. It could be due to the physical properties of that individual's brain + skull + scalp.
Do you have the ability to check your electrode impedances? If you don't have a lot of experience looking at EEG then feel free to post an image of your raw signal (time scale and y-scale clearly visible) as well as its PSD. Maybe I can tell if the signal quality is good.
Probably one of the more common montages for sensorimotor rhythm is the large laplacian approximation over C3 and another over C4.
C3_OUT = C3 - 0.25*(F3+T7+Cz+CP3)
C4_OUT = C4 - 0.25*(F4+Cz+T8+P4)
This can be further enhanced by actually weighting each channel by its physical distance to the active channel. If you don't have the actual distance measurements, you can use a model. See EEGLAB's default channel locations map to get physical coordinates of each channel in a model.
The above requires 9 channels. Do you only have 8 channels? If so, you can come up with another montage but try to get reference channels in each direction. In the figure you attached, C3 does not have a medial reference, thus any signal originating near the midline -- or even contralaterally -- will be larger in C3 than in the other channels and thus will be enhanced by this spatial filter. Simply moving CP3->CP1 and CP4->CP2 might be better.
If you are still having trouble then I would do the following:
-Put all 8 of your channels over one hemisphere's sensorimotor cortex, e.g. on and around C3.
-In task 1, do actual movements (not motor imagery). Try rolling a ball in your hand.
-In task 2, count backwards from 100 in steps of 7.
-Derive bipolar channels using every possible pairwise combination of channels.
-Also get a few more channels using various Laplacian approximations.
-View the spectra (+ error bars) for both tasks for each new channel derivation. If you find some channels work better than others, try to see if that correlates with a position on the scalp. Maybe your (subject's) SMR is not directly below C3.
-Try drinking caffeine before the recording.
If all that fails, try a different person. Not everyone has an accessible SMR. I'm not sure why. It could be due to the physical properties of that individual's brain + skull + scalp.
Do you have the ability to check your electrode impedances? If you don't have a lot of experience looking at EEG then feel free to post an image of your raw signal (time scale and y-scale clearly visible) as well as its PSD. Maybe I can tell if the signal quality is good.
-
athanoid
- Posts: 17
- Joined: 30 Jul 2014, 11:36
Re: Configuration for Cursor Task (Motor Imagery)
I will try to shift CP3->CP1 and CP4->CP2 and see what i can get.
For C3 - 0.25*(F3+T7+Cz+CP3), should I will use EEGLAB's location values?
For C3 - 0.25*(F3+T7+Cz+CP3), should I will use EEGLAB's location values?
-
boulay
- Posts: 382
- Joined: 25 Dec 2011, 21:14
Re: Configuration for Cursor Task (Motor Imagery)
Here is an excerpt from EEGLAB's location files website:
There are 3 coordinate systems:
theta,radius are polar coordinates on a 2D projection. Cz is at the origin.
X,Y,Z are 3-D cartesian coordinates (not sure if on a sphere or on a template head). Cz is at 0,0,1. Every other electrode is below Cz in the Z direction.
sph_theta, sph_phi, sph_radius are 3-D polar coordinates on a sphere. Since it's a sphere, all electrodes have a radius of 1.
If you wanted to use X,Y,Z, you'd do the following in Matlab.
Code: Select all
Number labels theta radius X Y Z sph_theta sph_phi sph_radius
15 F3 -39 0.333 0.673 0.545 0.5 39 30 1
35 T7 -90 0.511 6.12e-17 0.999 -0.0349 90 -2 1
37 C3 -90 0.256 4.4e-17 0.719 0.695 90 44 1
39 Cz 90 0 3.75e-33 -6.12e-17 1 -90 90 1
48 CP3 -118 0.278 -0.36 0.676 0.643 118 40 1
theta,radius are polar coordinates on a 2D projection. Cz is at the origin.
X,Y,Z are 3-D cartesian coordinates (not sure if on a sphere or on a template head). Cz is at 0,0,1. Every other electrode is below Cz in the Z direction.
sph_theta, sph_phi, sph_radius are 3-D polar coordinates on a sphere. Since it's a sphere, all electrodes have a radius of 1.
If you wanted to use X,Y,Z, you'd do the following in Matlab.
Code: Select all
locs = [0.673 0.545 0.5; 0 1 -0.0349; 0 0 1; 0.278 -0.36 0.676];
c3 = [0 0.719 0.695];
dists = nan(size(locs, 1), 1); % Will contain the distances between C3 and the other electrodes F3, T7, Cz, CP3
for el = 1:size(locs, 1)
dists(el) = sqrt(sum((c3 - locs(el, :)).^2)); % equivalent to norm(c3-locs(el,:), 2)
end
weights = 1./dists; % Instead of scaling by the inverse of the distance, you could scale by the square of the inverse or some other law.
weights = weights ./ sum(weights);
fprintf('C3 - %f*F3 - %f*T7 - %f*Cz - %f*CP3\n', weights)
C3 - 0.286097*F3 - 0.264091*T7 - 0.264465*Cz - 0.185348*CP3
-
athanoid
- Posts: 17
- Joined: 30 Jul 2014, 11:36
Re: Configuration for Cursor Task (Motor Imagery)
You think is better to use CAR or Full Matrix in the Spatial Filter?
Btw, here's a screenshot of the signals
Btw, here's a screenshot of the signals
-
boulay
- Posts: 382
- Joined: 25 Dec 2011, 21:14
Re: Configuration for Cursor Task (Motor Imagery)
CAR means common average reference. The signals from all channels are averaged together and the result is then subtracted from each signal. This is more commonly used when your electrodes have equal coverage over the entire head. It is not so common when you have electrodes focused over a specific area.
Full Matrix and Sparse Matrix do essentially the same thing, except with full matrix you have to define the weights for every channel. i.e., even if you use a surface Laplacian and you only need 4 reference channels, you still have to set the weights to 0.0 for all the other channels.
I remember reading somewhere that one or the other is faster, but I can't remember which.
By the way, Dennis McFarland recently published a paper on using the surface Laplacian in BCI. Check it out.
If you look in BCI2000\parms\fragments\spatial_filters\ you should see parameter files for LargeLaplacian and SmallLaplacian. You can import these into BCI2000 (either in a batch file or after). I believe these are the same weights that Dr. McFarland used in his study.
Full Matrix and Sparse Matrix do essentially the same thing, except with full matrix you have to define the weights for every channel. i.e., even if you use a surface Laplacian and you only need 4 reference channels, you still have to set the weights to 0.0 for all the other channels.
I remember reading somewhere that one or the other is faster, but I can't remember which.
By the way, Dennis McFarland recently published a paper on using the surface Laplacian in BCI. Check it out.
If you look in BCI2000\parms\fragments\spatial_filters\ you should see parameter files for LargeLaplacian and SmallLaplacian. You can import these into BCI2000 (either in a batch file or after). I believe these are the same weights that Dr. McFarland used in his study.
-
athanoid
- Posts: 17
- Joined: 30 Jul 2014, 11:36
Re: Configuration for Cursor Task (Motor Imagery)
would you think that is a good idea to simplify the montage with less electrodes for left/right hand imagery?
Something like this: http_nospam_sccn.ucsd.edu/~yijun/pdfs/EL07.pdf
Something like this: http_nospam_sccn.ucsd.edu/~yijun/pdfs/EL07.pdf
-
boulay
- Posts: 382
- Joined: 25 Dec 2011, 21:14
Re: Configuration for Cursor Task (Motor Imagery)
It depends what your goal is. If you are making something for general use then yes, simplest is best.
If you want to learn something about the brain* then I think more electrodes are better, limited by cost (time & money). You can always re-reference offline. Unfortunately, the best spatial filter is often subject-, hardware- and environment-dependent. I can't recommend one over the other. Though when talking about techniques to determine the best spatial filter, my ordered preference is: ICA > large Laplacian > bipolar > CAR.
*Here I mean about the networks, electrophysiological function, certain types of plasticity, i.e., things where your outcome is something measured from the brain. If you are doing a psychological study that measures behaviour or subjective responses then the electrodes are less important as long as you get 'good enough' accuracy to do your test.
If you want to learn something about the brain* then I think more electrodes are better, limited by cost (time & money). You can always re-reference offline. Unfortunately, the best spatial filter is often subject-, hardware- and environment-dependent. I can't recommend one over the other. Though when talking about techniques to determine the best spatial filter, my ordered preference is: ICA > large Laplacian > bipolar > CAR.
*Here I mean about the networks, electrophysiological function, certain types of plasticity, i.e., things where your outcome is something measured from the brain. If you are doing a psychological study that measures behaviour or subjective responses then the electrodes are less important as long as you get 'good enough' accuracy to do your test.
-
athanoid
- Posts: 17
- Joined: 30 Jul 2014, 11:36
Re: Configuration for Cursor Task (Motor Imagery)
I'm interested about the plasticity and the electrophysiological functions since I'm going to use it in neurorehabilitation through neurofeedback.
Would it be wise if I use few electrodes (maybe 3) for control (in a closed loop VR) in order to reduce complexity for classifying simple left/right hand imagery but keep the 8 electrode montage for offline analysis?
Would it be wise if I use few electrodes (maybe 3) for control (in a closed loop VR) in order to reduce complexity for classifying simple left/right hand imagery but keep the 8 electrode montage for offline analysis?
Who is online
Users browsing this forum: No registered users and 0 guests
