-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbsp_pcm_simulate_data.m
65 lines (52 loc) · 2.62 KB
/
bsp_pcm_simulate_data.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
function varargout=bsp_pcm_simulate_data(what,varargin)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
baseDir ='/srv/diedrichsen/data/Cerebellum/Pontine7T';
regDir ='/RegionOfInterest';
simDir = '/simulations';
resDir = '/results';
subj_name = {'S98','S97','S96','S95','S01','S03','S04','S07'};
numDummys = 3;
numTRs = 328;
numRuns = 16;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
switch(what)
case 'simulate_data'
num_subj = [1:length(subj_name)];
numSim = 100; %number of subjects to simulate
numVox = 50; %number of voxels to simulate
signal = 1; %integer signal level (default = 0.1)
noise = 2.0; %integer noise level (default = 1)
suffix = 'regress2.0x2.0d'; %suffix for rawts_signal filename
vararginoptions(varargin,{'num_subj','numSim','signal','noise','suffix'});
%Usage: bsp_pcm_simulate_data('simulate_data','num_subj',1,'numSim',100,'numVox',50,'signal',1,'noise',0,'suffix','highSNR');
% load(fullfile(fullfile(baseDir,simDir,'test_GLM_physio_task_instruc_model_tikhonov.mat')));
load(fullfile(fullfile(baseDir,simDir,'test_GLM_physio_all_tikhonov_cerebellum.mat')));
% exp = 2.0; theta = 0.7
% exp = 1.75; theta = 0.56
% exp = 1.5; theta = 0.41
% exp = 1.25; theta = 0.22
% exp = 1.0; theta = 1e-6
% exp = 0.75; theta = -0.29
% exp = 0.5; theta = -0.7
% exp = 0.25; theta = -1.4
% thetaSubj = [1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 -1e-6 -1e-6 -1e-6 -1e-6 -1e-6 -1e-6 -1e-6 -1e-6 -1e-6 -1e-6];
thetaSubj = [1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7];
X = design(1:numRuns:end,:);
signalVector = signal*ones(numSim,1);
noiseVector = noise*ones(numSim,1);
for s = 1:length(num_subj);
featureTemp = reshape(X(s,:),((numTRs-numDummys)*numRuns),[]);
feature = num2cell(featureTemp,[1,2]);
[M,Z] = pcm_buildModelFromFeatures(feature,'name','pontine');
M.numGparams = 20; %manually add numGparams, as pcm_buildModelFromFeatures doesn't
M.Gc = M.Gc .* thetaSubj;
M.Gd = M.Gd .* thetaSubj;
Ysim = pcm_makeDataset(M,thetaSubj','design',Z,'numVox',numVox,'numSim',numSim,'signal',signalVector,'noise',noiseVector);
for k = 1:length(Ysim)
Y = Ysim{1,k};
resMS = ones(1,size(Y,2));
filename = fullfile(fullfile(baseDir,simDir,'data','S98',sprintf('rawts_simulate_%s_%04d.mat',suffix,k)));
save(filename,'Y','resMS','-v7.3');
end
end
end