-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_plot_imp_scalp.m
More file actions
57 lines (47 loc) · 1.85 KB
/
test_plot_imp_scalp.m
File metadata and controls
57 lines (47 loc) · 1.85 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
% Set path
curr_path = pwd();
analysis_type = 'P3';
chanlocs_path = fullfile(curr_path, 'datain', 'limo_chanlocs.mat');
maskingRes_path = fullfile(curr_path, analysis_type, 'Ablation', 'Channel Ablation');
chan_mean_path = fullfile(maskingRes_path, 'imp_chan_drop.mat');
% Create plot save folder
plotSaveFolder = fullfile(maskingRes_path, 'Scalp Plots');
if ~exist(plotSaveFolder, 'dir')
mkdir(plotSaveFolder);
end
% Load the adjacency matrix and data
chan_mean = load(chan_mean_path).all_imp_chan_drop;
expected_chanlocs = load(chanlocs_path).expected_chanlocs;
% Generate scalp plots for each beta
[nBeta, nSubject, nChan] = size(chan_mean);
chan_mean_norm = zeros(size(chan_mean));
eps_val = 1e-12;
for iBeta = 1:nBeta
X = squeeze(chan_mean(iBeta,:,:));
denom = max(X(:));
denom = max(denom, eps_val);
chan_mean_norm(iBeta,:,:) = X ./ denom;
end
beta_chan_mean = squeeze(mean(chan_mean_norm, 2));
final_chan_imp = mean(beta_chan_mean, 1)';
filename = sprintf('%s_Imp_scalp.png', analysis_type);
title_str = sprintf('%s | Aggregated Channel Importance', analysis_type);
fprintf('Saved scalp plot: %s\n', fullfile(plotSaveFolder, filename));
plot_chan_importance(final_chan_imp, expected_chanlocs, title_str, plotSaveFolder, filename);
function plot_chan_importance(val, expected_chanlocs, ...
title_str, plotSaveFolder, filename)
val_centered = val - mean(val);
c = max(abs(val_centered));
figure('Color','w','NumberTitle','off','Name','limo_best_electrodes.m');
val_plot = val;
cmax = max(val_plot);
opt = {'electrodes','on', ...
'maplimits',[0 cmax], ...
'verbose','off', ...
'colormap', limo_color_images(val_plot)};
topoplot(val_centered, expected_chanlocs, opt{:});
%colorbar;
title(title_str);
exportgraphics(gcf, fullfile(plotSaveFolder, filename));
close(gcf);
end