-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdemo.m
More file actions
92 lines (73 loc) · 3.4 KB
/
demo.m
File metadata and controls
92 lines (73 loc) · 3.4 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
% This script demonstrates headplot for simple interpolation.
setup install
% Load in demo data.
demoDataPath = 'res/demo_data.mat';
data = load(demoDataPath, 'scalActivity');
A = data.scalActivity(:,1); % Forward model.
% Set location file filepath.
locationFilepath = 'res/96_EEG.loc';
% Demonstration of customizable headplot.
figure(1);clf
plotHandle1 = subplot(2,3,1);
plotHandle2 = subplot(2,3,2);
plotHandle3 = subplot(2,3,3);
plotHandle4 = subplot(2,3,4);
plotHandle5 = subplot(2,3,5);
plotHandle6 = subplot(2,3,6);
% Instantiate the HeadPlot object using eeglab's readloc.
locationInfo = readLocationFile(LocationInfo(), locationFilepath);
% If using custom source positions
% locationInfo = setCarteisianCoorPos(LocationInfo(), xPos, yPos)
% locationInfo = setPolarCoorPos(LocationInfo(), theta, radius, isRadian)
% isRadian - boolean (true or false). Indicate true if theta is in radians.
% Default (False)
% Start ScalpPlot via setting location info of the scalp sources.
scalpPlot = ScalpPlot(locationInfo);
% Ex 1. Draw the default headplot in the first plot.
scalpPlot.setPlotHandle(plotHandle1); % Set plot handle and plot axes
scalpPlot.draw(A); % Draw headplot.
title('Ex 1: default headplot')
% Ex 2. Head plot with contours.
scalpPlot.setPlotHandle(plotHandle2); % Set plot handle and plot axes
scalpPlot.draw(A);
scalpPlot.drawHeadContour();
title('Ex 2: w/ contour')
% Ex 3. Head plot with value of source points.
scalpPlot.setPlotHandle(plotHandle3); % Set plot handle and plot axes
scalpPlot.draw(A);
scalpPlot.drawSourcePoints();
title('Ex 3: w/ source location')
% Ex 4. Head plot with specified values on selective source points.
scalpPlot.setPlotHandle(plotHandle4); % Set plot handle and plot axes
scalpPlot.draw(A);
symbolStr1 = '^';
symbolStr2 = 'x';
sourceIndex = (rand(1,96) > .5);
markerHandle1 = scalpPlot.drawOnElectrode(sourceIndex, symbolStr1, [.5 .5 0],[1 .5 0]); % plot on siginficnt points
markerHandle2 = scalpPlot.drawOnElectrode(~sourceIndex, symbolStr2, [0 .5 .5], [0 .5 1]); % plot on siginficnt points
handles = [markerHandle1 markerHandle2];
scalpPlot.drawMarkerLegend(handles, {'marker 1', 'marker 2'} ,'southwestoutside');
title('Ex 4: w/ specified source markers')
% Ex5. Head plot with specified colormap and axis.
scalpPlot.setPlotHandle(plotHandle5); % Set plot handle and plot axes
scalpPlot.draw(A);
colorMapVal = flipud(hot); % Assign colormap scale
maxVal = max(A); minVal = min(A); % Set color min and max values.
colorAxisRange = [minVal maxVal];
cAxis = [minVal, mean(A), maxVal];
cAxisTickLabel = {num2str(minVal, '%0.3f'), '\muV', num2str(maxVal,'%0.3f')};
scalpPlot.setColorAxis(colorAxisRange, colorMapVal); % Set color scale.
scalpPlot.drawColorBar(cAxis, cAxisTickLabel, 'southoutside'); % Draw color bar.
title('Ex 5: w/ colorbar and alternate color scale')
% Ex6. w/Everything
scalpPlot.setPlotHandle(plotHandle6); % Set plot handle and plot axes
scalpPlot.draw(A);
scalpPlot.drawHeadContour();
scalpPlot.drawSourcePoints();
markerHandle1 = scalpPlot.drawOnElectrode(sourceIndex, symbolStr1, [.5 .5 0],[1 .5 0]); % plot on siginficnt points
colorMapVal = flipud(parula); % Assign colormap scale
scalpPlot.setColorAxis(colorAxisRange, colorMapVal); % Set color scale.
scalpPlot.drawColorBar(cAxis, cAxisTickLabel, 'eastoutside'); % Draw color bar.
scalpPlot.drawMarkerLegend(markerHandle1, {'marker'} ,'southoutside');
title('Ex 6: w/ Everything')
print('output/demo','-dpng','-r0');