-
Notifications
You must be signed in to change notification settings - Fork 27
/
limo_getclustersum.m
40 lines (31 loc) · 1.28 KB
/
limo_getclustersum.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
function maxclustersum = limo_getclustersum(f,p,channeighbstructmat,minnbchan,alphav)
% limo_getclustersum finds clusters of significant F values, computes the
% sum of each cluster, and return the maximum sum across all clusters.
%
% FORMAT: maxclustersum = limo_getclustersum(f,p,channeighbstructmat,minnbchan,alpha)
%
% INPUTS: f = 2D/3D matrix of F values - so if using T values, enter T.^2
% p = 2D/3D matrix of P values
% channeighbstructmat = output of limo_ft_neighbourselection
% minnbchan = minimum number of channels, default = 2, see
% alpha level, default 0.05
%
% OUTPUTS: maxclustersum = max cluster sum across all clusters of significant F values
%
% See also LIMO_CLUSTER_TEST LIMO_FT_FINDCLUSTER
% ------------------------------
% Copyright (C) LIMO Team 2019
% v1: GAR, University of Glasgow, June 2010
if nargin<5;alphav=.05;end
if nargin<4;minnbchan=2;end
[posclusterslabelmat,nposclusters] = limo_findcluster(p<=alphav,channeighbstructmat,minnbchan);
% figure;imagesc(posclusterslabelmat)
if nposclusters~=0
tmp=zeros(1,nposclusters);
for C = 1:nposclusters % compute sum for each cluster
tmp(C) = sum( f(posclusterslabelmat==C) );
end
maxclustersum = max(tmp(:)); % save max across clusters
else
maxclustersum = 0;
end