-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunBrainExp.m~
More file actions
54 lines (44 loc) · 1.3 KB
/
runBrainExp.m~
File metadata and controls
54 lines (44 loc) · 1.3 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
subjects = 'ABCD';
load ../brainData/semantic_data.mat;
%% Coordinate Descent Code - Training
objFunc = @fusedObjective;
coordFuncs = {@fusedFusedUpdate; @fusedFusedSlack1Update; @fusedFusedSlack2Update; @fusedFusedSlack3Update};
paramOrder = [1 0 0 0 1]; %merrrh
betas = cell(length(subjects), 1);
for s = 1:length(subjects)
load(['../brainData/' subjects(s) '_data.mat']);
betas{s} = coordDescReg(X, Y, coordFuncs, objFunc, Psi, Theta, paramOrder);
fprintf('Subject %s complete\n', subjects(s));
end
save ../brainData/betasCoord.mat betas;
%% Coordinate Descent Code - Testing and Plotting
if ~exist('betas', 'var')
load ../brainData/beasCoord.mat;
end
N = size(Y,1);
S = length(subjects);
scores = zeros(S, S);
for s = 1:S
subplot(S/2, S/2, s);
imagesc(betas{s});
colorbar;
xlabel('Semantic Features');
ylabel('MEG Sources');
title(subjects(s));
for ss = 1:S
if ss ~= s
load(['../brainData/' subjects(ss) '_data.mat']);
Yhat = X*betas{s};
for n = 1:N
d = pdist([Yhat(n,:); Y], 'cosine');
[~,ind] = sort(d(1:N));
ranks(n) = find(n==ind);
end
scores(s, ss) = mean(1 - (ranks - 1)./(N -1));
end
end
end
figure;
imagesc(scores);
colorbar;
xlabel(S