|
1 | 1 | %% script to run the simulations in figure 3
|
2 | 2 | % runs MDP simulation with the first 15 trials as fixed inputs.
|
3 | 3 |
|
4 |
| -%% get canonical variables for each cardiac phase |
5 |
| -close all |
6 |
| -clear all |
7 |
| - |
8 |
| -% path to code repository - change this |
9 |
| -addpath('C:\Users\Micah Allen\Google Drive\FEP_Heartbeat\code\cbrewer') |
10 |
| - |
11 |
| -% path to SPM 12 - change this |
12 |
| -addpath('C:\Users\Micah Allen\Dropbox\toolboxes\MatlabToolboxes\SPM12_latest') |
13 |
| - |
14 |
| -% intialize and close spm - need MDP functions on path |
15 |
| -spm fmri -nogui |
16 |
| -spm quit |
17 | 4 |
|
18 | 5 | %% run model 1 - healthy control
|
19 | 6 | % healthy interoception
|
|
39 | 26 | input.T = 100; % specify number of total trials to simulate
|
40 | 27 |
|
41 | 28 | %% simulate 30 healthy subjects in a parfor loop
|
42 |
| -nsubjects = 30; |
43 |
| - |
44 |
| -parfor n = 1:nsubjects |
45 |
| - |
46 |
| - |
47 |
| - |
48 |
| -tic |
49 |
| -fprintf('\nSubject %d/%d Started\n', n, nsubjects) |
50 |
| -mdp1(n)= run_mdp_simulation(input); |
51 |
| -t=toc; |
52 |
| -fprintf('\nSubject %d/%d Simulated in %02f seconds \n'... |
53 |
| - , n,nsubjects, t) |
54 |
| - |
55 |
| - |
56 |
| - |
| 29 | +% if you do not have parallel computing toolbox, just change to a for loop |
| 30 | +% and it should run. It may take a while. |
| 31 | +if ~exist(fullfile(datpath, 'MDP_30n_100t_healthy.mat'), 'file') |
| 32 | + nsubjects = 30; |
| 33 | + |
| 34 | + parfor n = 1:nsubjects |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + tic |
| 39 | + fprintf('\nSubject %d/%d Started\n', n, nsubjects) |
| 40 | + mdp1(n)= run_mdp_simulation(input); |
| 41 | + t=toc; |
| 42 | + fprintf('\nSubject %d/%d Simulated in %02f seconds \n'... |
| 43 | + , n,nsubjects, t) |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + end |
| 48 | + |
| 49 | + save(fullfile(datpath, 'MDP_30n_100t_healthy.mat'), 'mdp1') |
| 50 | + |
| 51 | +else |
| 52 | + |
| 53 | + load(fullfile(datpath, 'MDP_30n_100t_healthy.mat'), 'mdp1') |
| 54 | + |
57 | 55 | end
|
58 | 56 |
|
59 |
| -save MDP_30n_100t_healthy mdp1 |
60 |
| - |
61 |
| -%% optional plotting |
62 |
| -spm_figure('GetWin','Figure 1'); |
63 |
| -spm_MDP_VB_trial(mdp1(end)) |
| 57 | +%% optional plotting of state trajectories |
| 58 | +% spm_figure('GetWin','Figure 1'); |
| 59 | +% spm_MDP_VB_trial(mdp1(end)) |
64 | 60 |
|
65 | 61 | %% simulation #2 - lesioned interoceptive precision
|
66 | 62 |
|
|
80 | 76 | input.s = [repmat([1 2 3], 1, length(input.s)./3); input.s];
|
81 | 77 | input.T = 100;
|
82 | 78 |
|
| 79 | +if ~exist(fullfile(datpath, 'MDP_30n_100t_lesion.mat'), 'file') |
83 | 80 |
|
84 | 81 | nsubjects = 30;
|
85 | 82 |
|
|
98 | 95 |
|
99 | 96 | end
|
100 | 97 |
|
| 98 | +save(fullfile(datpath, 'MDP_30n_100t_lesion.mat'), 'mdp2') |
| 99 | + |
| 100 | +else |
| 101 | + |
101 | 102 |
|
| 103 | +load(fullfile(datpath, 'MDP_30n_100t_lesion.mat'), 'mdp2') |
| 104 | + |
| 105 | + |
| 106 | +end |
102 | 107 |
|
103 |
| -save MDP_30n_100t_lesion mdp2 |
| 108 | + |
104 | 109 |
|
105 |
| -%% optional plotting |
106 |
| -spm_figure('GetWin','Figure 1'); |
107 |
| -spm_MDP_VB_trial(mdp2(end)) |
| 110 | +%% optional plotting of state trajectories |
| 111 | +% spm_figure('GetWin','Figure 1'); |
| 112 | +% spm_MDP_VB_trial(mdp2(end)) |
108 | 113 |
|
109 | 114 |
|
110 | 115 |
|
|
0 commit comments