-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathGetZZ.m
More file actions
36 lines (33 loc) · 919 Bytes
/
GetZZ.m
File metadata and controls
36 lines (33 loc) · 919 Bytes
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
function varargout = GetZZ(dat)
% Return suffient statistics from latent variables
% FORMAT [N,Z,ZZ,S] = GetZZ(dat)
%
% dat - Structure containing various information about each image.
% Fields for each image n are:
% dat(n).f - Image data.
% dat(n).z - Expectations of latent variables.
% dat(n).S - Covariances of latent variables.
%
% N - Number of images.
% Z - Sum over expectations of latent variables (dat(n).z).
% ZZ - Sum over dat(n).z*dat(n).z'
% S - Sum over covariances (dat(n).S)
%
%__________________________________________________________________________
% Copyright (C) 2017 Wellcome Trust Centre for Neuroimaging
% John Ashburner
% $Id$
Z = single(0);
ZZ = single(0);
S = single(0);
N = numel(dat);
for n=1:N
z = dat(n).z;
Z = Z + z;
ZZ = ZZ + z*z';
S = S + dat(n).S;
end
varargout{1} = N;
varargout{2} = Z;
varargout{3} = ZZ;
varargout{4} = S;