-
Notifications
You must be signed in to change notification settings - Fork 2
/
fp_pr_pac.m
47 lines (34 loc) · 921 Bytes
/
fp_pr_pac.m
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
function [pm] = fp_pr_pac(cc,iroi_amplt,iroi_phase)
% Copyright (c) 2023 Franziska Pellegrini and Stefan Haufe
%number of interactions
nints = numel(iroi_phase);
%number of regions
nroi = size(cc,1);
%true labels
label=diag(ones(nroi,1));
for iint = 1:numel(iroi_phase)
label(iroi_amplt(iint),iroi_phase(iint)) = 2;
end
lab = label(:);
cc = cc(:);
%remove diagonal entries
cc(lab==1)=[];
lab(lab==1)=[];
%index of true label
tr = find(lab==2);
%estimated scores
[~, idx] = sort(cc,'descend');
%rank of estimated scores
for it = 1:numel(tr)
r1(it) = find(idx==tr(it));
end
%% percentage rank
pm = mean(1 - (r1 ./ numel(lab)));
%normalize with perfect skill and noskill PR
for it = 1:nints
perfectPm(it) = 1 - (it / numel(lab));
noSkillPm(it) = 1 - (numel(lab)-it+1)/numel(lab);
end
perfectPm = mean(perfectPm);
noSkillPm = mean(noSkillPm);
pm = (pm-noSkillPm)/(perfectPm-noSkillPm);