-
Notifications
You must be signed in to change notification settings - Fork 1
/
spm_Pec_resels.m
84 lines (77 loc) · 2.46 KB
/
spm_Pec_resels.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
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
function R = spm_Pec_resels(L,W)
% Returns the resel count for a point-list of voxels
% FORMAT R = spm_Pec_resels(L,W)
% L - point list of voxels {in voxels}
% W - smoothness of the component fields {FWHM in voxels}
% R - vector of RESEL counts
%___________________________________________________________________________
%
% Reference : Worsley KJ et al 1996, Hum Brain Mapp. 4:58-73
%___________________________________________________________________________
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
% Karl Friston
% $Id: spm_Pec_resels.m 1143 2008-02-07 19:33:33Z spm $
% Resel Counts
%---------------------------------------------------------------------------
L = round(L);
Ex = 0;
Ey = 0;
Ez = 0;
Fxy = 0;
Fxz = 0;
Fyz = 0;
C = 0;
x = L(1,:);
y = L(2,:);
z = L(3,:);
P = length(x);
R = zeros(1,4);
% characterize voxel space
%---------------------------------------------------------------------------
for i = 1:P
d = any(~any([x - L(1,i) - 1;y - L(2,i) - 0;z - L(3,i) - 0]));
if d
Ex = Ex + 1;
d = any(~any([x - L(1,i) - 0;y - L(2,i) - 1;z - L(3,i) - 0]));
d = d & any(~any([x - L(1,i) - 1;y - L(2,i) - 1;z - L(3,i) - 0]));
if d
Fxy = Fxy + 1;
d = any(~any([x - L(1,i) - 0;y - L(2,i) - 0;z - L(3,i) - 1]));
d = d & any(~any([x - L(1,i) - 1;y - L(2,i) - 0;z - L(3,i) - 1]));
d = d & any(~any([x - L(1,i) - 1;y - L(2,i) - 1;z - L(3,i) - 1]));
d = d & any(~any([x - L(1,i) - 0;y - L(2,i) - 1;z - L(3,i) - 1]));
if d
C = C + 1;
end
end
d = any(~any([x - L(1,i) - 0;y - L(2,i) - 0;z - L(3,i) - 1]));
d = d & any(~any([x - L(1,i) - 1;y - L(2,i) - 0;z - L(3,i) - 1]));
if d
Fxz = Fxz + 1;
end
end
d = any(~any([x - L(1,i) - 0;y - L(2,i) - 1;z - L(3,i) - 0]));
if d
Ey = Ey + 1;
d = any(~any([x - L(1,i) - 0;y - L(2,i) - 0;z - L(3,i) - 1]));
d = d & any(~any([x - L(1,i) - 0;y - L(2,i) - 1;z - L(3,i) - 1]));
if d
Fyz = Fyz + 1;
end
end
d = any(~any([x - L(1,i) - 0;y - L(2,i) - 0;z - L(3,i) - 1]));
if d
Ez = Ez + 1;
end
x(1) = [];
y(1) = [];
z(1) = [];
end
% Resel counts
%---------------------------------------------------------------------------
r = 1./W(:);
R(1) = P - (Ex + Ey + Ez) + (Fyz + Fxz + Fxy) - C;
R(2) = (Ex - Fxy - Fxz + C)*r(1) + (Ey - Fxy - Fyz + C)*r(2) +...
(Ez - Fxz - Fyz + C)*r(3);
R(3) = (Fxy - C)*r(1)*r(2) + (Fxz - C)*r(1)*r(3) + (Fyz - C)*r(3)*r(2);
R(4) = C*prod(r);