BCI Projects
From ESE497 Wiki
Jump to navigationJump to search<mediaplayer width=640 height=504>FILE:ESE297_BCI_FL15.flv</mediaplayer>
- Project3: BCI Offline Analysis - Signal Detection
- Plot R^2 for all Channels/Frequency Pairs
- Start with OfflineAnalysisSpectral.m. This is the file you will modify for this project.
- Open in Matlab.
- Click the Run arrow. Select eeg1_1.dat, eeg1_2.dat and eeg1_3.dat. Click Open
- Remove the DC (average) for all 64 channels
for ch=1:size(signal, 2) signal(:, ch)=signal(:, ch)-mean(signal(:, ch)); end
- Implement CAR Spatial Filtering using the BCI2000 funtion carFile
signal = carFilt(signal,2) ;
- For every channel, compute the power spectrum for every segment of 80 samples with 40 samples of overlap for both condition==0 and condition==2 and average them. Create two 3D array of PowerSpectra of size(NumFrequencies,NumChannels,NumTrials) for both conditions.
- Compute the R^2 function for all Channel/Frequency pairs the BCI2000 function calc_rsqu. Type "which calc_rsqu" at the matlab command prompt to locate calc_rsqu.m.
- Plot the R^2 values for all Channel/Frequency pairs using the Matlab function surf. It should look similar but not identical to the graph on the tutorial.
- Useful Matlab Functions:
- find
- spectrogram
- surf
- After calling surf, you should execute the following line to eliminate those pesky yellow lines
set(gcf,'Renderer','Zbuffer')
- The 64th channel is not displayed because of a problem with surf. We need to pad a column of 0s to the end of the matrix to make it work:
surf([ressq zeros(size(ressq,1),1)]') ;
- Project4: BCI Offline Analysis - Signal Classification
- Combine best Channel/Frequency pairs using eeg1_(1,2,3).dat (use lda.m)
- Plot the power in the 4 best Channel/Frequency pairs for the action and the rest conditions using the eeg1 data vs. trial
- Plot the action and rest results of the LDA vs. trial
- Plot the ROC for the 4 best Channel/Frequency pairs and the LDA
- Results
- Collect your own data using the Emotiv Headset (Instructions)
- Combine best Channel/Frequency pairs using your own data
- states.StimulusCode values for stimulus presentation
- 0: Gray Screen - Relax, blink, move around, etc.
- 1: Left - Clench left hand
- 2: Pause - Unclench
- 3: Right - Clench right hand
- states.StimulusCode values for stimulus presentation
- Combine best Channel/Frequency pairs using your own data
- Useful Matlab Functions:
- subplot
- save, load
- squeeze
- Combine best Channel/Frequency pairs using eeg1_(1,2,3).dat (use lda.m)
- Project 5: Move sbRIO robots based on BCI algorithm using Emotiv data
- Re-Package your Matlab code into 2 scripts that
- 1) Acquire the trials: Read the trials from the .dat file that you created in Project 4 with the Emotiv headset. Return 1 trial every time this script is executed in the LabVIEW while loop.
- 2) Process the trials: Compute the LDA measure from the current trial. This will also execute for every iteration of the LabVIEW while loop.
- The reason why you want to separate the processing of the trials from the acquisition of the trials is because in project 6, the trials will be acquired from the Emotiv headset.
- Call your matlab functions from inside BCI.vi and move the robots every time the action is detected. Verify that you get the number of errors you expected and that the LDA calculation matches from before.
- Re-Package your Matlab code into 2 scripts that
- Project 6: Implement in real-time with Emotive headset
- Download Emotiv LabVIEW code and extract all files to the folder with your other LabVIEW files.
- Emotiv.vi returns up to 128 samples (@ 128 Samples/sec) per channel. If your trials need to be longer than 1 second then you will need to buffer up the Emotiv.vi output.
- If you call Emotiv.vi once per second as in EmoTop.vi, it returns a 128x22 matrix. Look at the column headings in Emotiv.vi to see which columns correspond to your data.
- Don't forget to remove the mean and use the CAR filter on your emotiv data.
- For the final demonstration, we need to re-run the training session. Collect 5 minutes of data with the BCI2000 Stimulus Presentation for 5 minutes. Keeping the headset on, re-compute the R^2 graph, pick the best channels, and run a new LDA on this new data. Implement the new channel frequency pairs, lda scaling and threshold in your LabVIEW code. Then, with the headset still on, run your project 6 code.