-
Notifications
You must be signed in to change notification settings - Fork 0
/
slvoxppmodelTest.m
46 lines (38 loc) · 1.14 KB
/
slvoxppmodelTest.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
%slvoxppmodelTest
%
%
%author : steeve laquitaine
% date : 161101
%purpose: decode likelihood of stimulus feature (e.g., motion directions)
% from Ni instances by Nv voxels responses with model parameters
% W_tr, rho_tr,tau_tr,sigma_tr
%
% usage :
%
% LLHs = slvoxppmodelTest(b_test)
function LLHs = slvoxppmodelTest(b_test,W_tr,rho_tr,tau_tr,sigma_tr,pp)
%number of data feature (voxels)
Nv = size(W_tr,1);
%calculate likelihoods
%W_tr, rho_tr, tau_tr, sigma_tr,
%we first calculate them from each trial BOLD pattern
%Nv x Nv mu MV gaussian mean
mu = W_tr*pp.f_k_s;
%Nv x Nv Omega global noise matrix
Om = rho_tr*(tau_tr*tau_tr') + (1-rho_tr)*times(eye(Nv,Nv),tau_tr*tau_tr')+(sigma_tr^2)*(W_tr*W_tr');
[~,e] = cholcov(Om);
if e~=0
fprintf('%s \n','(slsimvoxppdec) Covariance matrix Omega is not symmetric, positive definite')
dbstack
keyboard
end
if det(Om)==0
fprintf('%s \n','(slsimvoxppdec) Covariance matrix Omega singular')
dbstack
keyboard
end
%likelihood probability distribution
for si = 1 : 360
pb_si(:,si) = mvnpdf(b_test,mu(:,si)',Om);
end
LLHs = bsxfun(@rdivide,pb_si,sum(pb_si,2));