forked from gmicros/MATLAB
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp300.m
More file actions
48 lines (33 loc) · 1.28 KB
/
p300.m
File metadata and controls
48 lines (33 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
%%%
% BCI INITIAL ASSIGNMENT
% P300 ANALYSIS
clear; clc
% read all session files
[signal, state, parameters] = load_data();
sample_time = .8; %s
sample_rate = 240; % Hz
num_channels = 64;
num_samples = sample_rate * sample_time;
% For all channels, collect a 800ms of signal samples after the start of each
% intensification, i.e., whenever state.Flashing changes from 0 to 1 (note: each
% character epoch of the data set starts at the first flash, i.e. state.Flashing=1 for the
% first data sample in each epoch).
flashing = state.Flashing(2:end);
flashing2 = state.Flashing(1:end-1);
changes =[0; flashing - flashing2];
index = find(changes); %location of sdifferent intensifications
data = zeros(num_samples, num_channels, length(index));
for j = 1: length(index)
data (:,:,j) = signal(index(j):index(j) + num_samples-1, :);
end
% Compute the correlation between the state.StimulusType and the response
% amplitude for each time sample and channel.
data = permute(data,[3 1 2]);
correlation = zeros(num_channels, num_samples);
for i = 1:num_channels
for j = 1:num_samples
correlation(i, j) = corr(squeeze(data(:, j, i)), double(state.StimulusType(index)));
end
end
datavector = correlation(:, .1*sample_rate);
topoplot(datavector,'eloc64.txt','EEG');