Topographic plot

Most of the beginners of EEG analysis field is looking for this visualization. Generally, the topographic plot shows the energy variation over the electrodes placed on the head. You can see a sample image of this visualization. Even if the plot is not that much elegant you can get an idea of the collected data.

Topographic plot of 14 channel dataset

The Matlab code has been added below. Following code is created for 14 channel Emotiv EPOC+ headset electrode placement. But this code understandable and you can customize it for your own use. “xc” and “yc” contain coordinates of the electrodes. You have to edit those value according to your data. You can change the interpolation function to ‘linear’, ‘nearest’, ‘natural’, ‘cubic’, and ‘v4’ in line 30. Best function is ‘natural’ for this visualization.

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
function topoplot(data)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Author: Isuru Jayarathne %
% %
% Input: 14xn matrix %
% Output: Figure of the topographic plot %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Define electrodes placement according to the Emotiv Epoc+ headset
xc = [2.5; 1.5; 3; 2; 1; 2; 3; 5; 6; 7; 6; 5; 6.5; 5.5];
yc = [7; 5.7; 5.8; 5; 4; 2; 1; 1; 2; 4; 5; 5.8; 6; 7];
lbls = {'AF3','F7','F3','FC5','T7','P7','O1','O2','P8','T8','FC6','F4','F8','AF4'};

trlen = [];

% Calculating power of each electrode
for i=1:14
ftr = (data(i,:));
ftr = fft(ftr);
pow = ftr.*conj(ftr);
tpow = sum(pow);
trlen = vertcat(trlen,tpow);
end

xi=linspace(min(xc),max(xc),30);
yi=linspace(min(yc),max(yc),30);

[XI YI]=meshgrid(xi,yi);
ZI = griddata(xc,yc,trlen,XI,YI,'natural');

figure;
contourf(XI,YI,ZI,20);
hold on;
scatter(xc,yc,'b','filled');
text(xc+0.1,yc+0.1,lbls);

% Turn off the plot labels and axis
set(gca,'Visible','off');
colormap(jet);
hold off;
end

If you want to generate topographic plot for .edf file, please refer Github code.

References

Add Comment

Required fields are marked *. Your email address will not be published.

Loading Facebook Comments ...