-
Notifications
You must be signed in to change notification settings - Fork 2
/
spm_DFP_plot.m
91 lines (82 loc) · 2.04 KB
/
spm_DFP_plot.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
84
85
86
87
88
89
90
91
function spm_DFP_plot(QU,pU)
% plots particles for spm_DFP
% FORMAT spm_DFP_plot(QU,Nt)
% FORMAT spm_DFP_plot(QU,pU)
%--------------------------------------------------------------------------
% QU{t}(p).x{d} - ensemble of hidden states
% QU{t}(p).v{d} - ensemble of causal states
%__________________________________________________________________________
% Copyright (C) 2005 Wellcome Department of Imaging Neuroscience
% Karl Friston
% $Id$
% defaults for plotting
%--------------------------------------------------------------------------
clf
try
pX = pU.x{1};
pV = pU.v{2};
Nt = length(pX);
catch
try Nt = pU; catch, Nt = length(QU); end
end
% time-series specification
%--------------------------------------------------------------------------
nx = size(QU{1}(1).x{1},1);
nv = size(QU{1}(1).v{1},1);
np = length(QU{1});
nt = length(QU);
% unpack states
%--------------------------------------------------------------------------
for t = 1:nt
for j = 1:np
for i = 1:nx
X{i}(t,j) = QU{t}(j).x{1}(i);
end
for i = 1:nv
V{i}(t,j) = QU{t}(j).v{1}(i);
end
end
end
% causes
%--------------------------------------------------------------------------
if nt < 2, return, end
subplot(2,1,1)
for i = 1:nv
plot(1:nt,V{i},':','Color',[1 1 1]/(2 + i - 1))
hold on
plot(1:nt,mean(V{i},2),'--b','LineWidth',2)
hold on
end
try
hold on
plot([1:nt] - 1,pV,'r')
end
hold off
title(sprintf('causal states - %i',nv));
xlabel('time {bins}')
ylabel('states (a.u.)')
grid on
axis square
set(gca,'XLim',[1 Nt])
% hidden states
%--------------------------------------------------------------------------
if ~nx, drawnow, return, end
subplot(2,1,2)
for i = 1:nx
plot(1:nt,X{i},':','Color',[1 1 1]/(2 + i - 1))
hold on
plot(1:nt,mean(X{i},2),'--b','LineWidth',2)
hold on
end
try
hold on
plot([1:nt] - 1,pX,'r')
end
hold off
title(sprintf('hidden states - %i',nx));
xlabel('time {bins}')
ylabel('states (a.u.)')
grid on
axis square
set(gca,'XLim',[1 Nt])
drawnow