-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_sim.m
57 lines (50 loc) · 1.33 KB
/
run_sim.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
%% Run Temporal Mapper on simulated data
% Load code and data
addpath(genpath('code/'));
load('data/sim.mat');
tidx = (1:length(data.t))'; % indexing variable
% Set parameters
k = 14; % nearest neighbor parameter
d = 2;
% Compute temporal mapper
g = tknndigraph (data.x,k,tidx,'reciprocal',true);
[g_simp, members, ~] = filtergraph(g,d,'reciprocal',true); % Perform simplification
[a1, a2] = plotgraphtcm(g_simp,data.x_label,data.t,members,'nodesizerange',[1,25]);
%% Comparison to other methods
figure('position',[10,10,1000,400]);
% Plot regular recurrence plot
subplot(1,2,1)
recur_reg = pdist2(data.x,data.x);
imagesc(t,t,recur_reg)
colormap hot
cb=colorbar;
axis square
xlabel('time (s)')
ylabel('time (s)')
xlabel(cb,'distance between S_E')
title('Recurrence of S_E')
% Compute dynamic (windowed) functional connectivity
winsize = 30; %default 30
lag = 1;
[~,dfc_fz] = dynFC(data.x,winsize,lag);
% -- plot recurrence plot of dFC
recur_dfc = pdist2(dfc_fz,dfc_fz);
subplot(1,2,2)
imagesc(t,t,recur_dfc)
colormap hot
cb=colorbar;
axis square
xlabel('time (s)')
ylabel('time (s)')
xlabel(cb,'distance between dFC')
title('Recurrence of dFC')
% Recurrence of control parameter G
figure
imagesc(pdist2(data.G,data.G))
colormap hot
cb=colorbar;
axis square
xlabel('time (s)')
ylabel('time (s)')
xlabel(cb,'distance between G')
title('Recurrence of G')