9
9
% out = generateSimDataset(dirname, nSubj, nSess, nRuns, options)
10
10
%
11
11
% Description:
12
- % options - { {'probe'|'digpts}, 'springs', 'data' }
12
+ % options - { {'probe'|'digpts}, 'springs', 'data' }
13
13
%
14
14
% Examples:
15
+ %
16
+ % %%%%% Change current folder to <root groups test folder>
17
+ % emptyGroupTestDir = 'c:/users/public/groups/emptyGroupTestDir';
18
+ % if ~exist(emptyGroupTestDir,'dir'), mkdir(emptyGroupTestDir); end
19
+ % cd(emptyGroupTestDir);
20
+ %
21
+ % %%%%% Now generate probe and/or digitized points and/or raw/unprocessed dataTree data.
22
+ % %%%%% These 9 examples covers all the major AtlasViewer + Homer3 workflows
23
+ %
24
+ % % Example 1: probe file in SD format with spring registration and
25
+ % % raw/unprocessed dataTree data with 3 subjects, 3 sessions each, and 3 runs each.
26
+ % out = generateSimDataset(pwd, 3, 3, 3, 'probe:springs:data');
27
+ %
28
+ % % Example 2: probe file in SD format with spring registration and
29
+ % % raw/unprocessed dataTree data with 3 subjects, 3 sessions each with 3 runs each.
15
30
% out = generateSimDataset();
31
+ %
32
+ % % Example 3: probe file in SD format with spring registration and
33
+ % % acquisition data with 3 subjects, 1 session each, and 3 runs each.
16
34
% out = generateSimDataset(pwd);
35
+ %
36
+ % % Example 4: probe file in SD format with spring registration and acquisition data
37
+ % % with 2 subjects with 1 session each, and each session with 5 runs each.
38
+ % out = generateSimDataset(pwd, 2, 1, 5);
39
+ %
40
+ % % Example 5: probe file in SD format with NO registration and NO acquisition data
17
41
% out = generateSimDataset(pwd, [],[],[],'probe');
18
- % out = generateSimDataset(pwd, 3,3,3,'probe:data');
42
+ %
43
+ % % Example 6: probe file in SD format with spring registration and NO data
19
44
% out = generateSimDataset(pwd, [],[],[],'probe:springs');
45
+ %
46
+ % % Example 7: Unprocessed dataTree data with 3 subjects, 3 sessions, and 3 runs each
47
+ % % and with acquisition files containing probe with landmark registration.
48
+ % % with 3 subjects with 1 session each, and each session with 3 runs each.
20
49
% out = generateSimDataset(pwd, [],[],[],'probe:landmarks:data');
21
- % out = generateSimDataset(pwd, [],[],[],'probe:landmarks:data');
50
+ %
51
+ % % Example 8: Digpts file with associated probe file in SD format containing measurement list
52
+ % % and NO acquisition data
22
53
% out = generateSimDataset(pwd, [],[],[],'digpts');
23
- % out = generateSimDataset(pwd, [],[],[],'digpts:data');
54
+ %
55
+ % % Example 9: Digpts file with associated probe file in SD format containing measurement list
56
+ % % and data with 1 subject with 2 sessions each, and each session with 4 runs each.
57
+ % out = generateSimDataset(pwd, 1, 2, 4, 'digpts:data');
58
+ %
24
59
%
25
60
global atlasViewer
61
+ global probeFilename
62
+
26
63
atlasViewer = [];
64
+ probeFilename = ' newfile1.SD' ;
65
+
27
66
out = [];
28
67
29
68
t0 = tic ;
35
74
nSubj = 3 ;
36
75
end
37
76
if ~exist(' nSess' ,' var' ) || isempty(nSess )
38
- nSess = 3 ;
77
+ nSess = 1 ;
39
78
end
40
79
if ~exist(' nRuns' ,' var' ) || isempty(nRuns )
41
80
nRuns = 3 ;
73
112
subjDirs = dir(' sub-*' );
74
113
for ii = 1 : length(subjDirs )
75
114
digptsNew = movePts(digpts , randNearZero(1 ,3 ,t0 ), randNearOne(1 ,3 ,t0 ), randNearZero(1 ,3 ,t0 ));
76
- digptsNew.pathname = [filesepStandard(pwd ), subjDirs(ii ).name];
115
+ digptsNew.pathname = [filesepStandard(dirname ), subjDirs(ii ).name];
77
116
saveDigpts(digptsNew );
117
+ if ispathvalid([dirname , probeFilename ])
118
+ if optionExists(options , ' springs' )
119
+ copyfile([dirname , probeFilename ], [filesepStandard(dirname ), subjDirs(ii ).name, ' /' , probeFilename ]);
120
+ end
121
+ end
78
122
end
79
123
delete(' ./digpts*.txt' );
80
124
end
81
125
82
126
83
127
84
-
85
128
% ----------------------------------------------
86
129
function genSimData(probe , dirname , nSubj , nSess , nRuns , t0 )
87
130
SD = convertProbe2SD(probe );
@@ -108,29 +151,43 @@ function genSimData(probe, dirname, nSubj, nSess, nRuns, t0)
108
151
else
109
152
iSubjName = sprintf(' %d ' , iSubj );
110
153
end
111
- sname = sprintf(' sub-%s ' , iSubjName );
112
- if ispathvalid([dirname , sname ])
113
- rmdir([dirname , sname ], ' s' )
154
+ subjName = sprintf(' sub-%s ' , iSubjName );
155
+ subjNameFull = filesepStandard([dirname , subjName ], ' dir:nameonly' );
156
+ if ispathvalid(subjNameFull )
157
+ rmdir(subjNameFull , ' s' )
114
158
end
115
- mkdir([ dirname , sname ] );
159
+ mkdir(subjNameFull );
116
160
117
- for iRun = 1 : nRuns
118
- for iM = 1 : size(nirs .SD .MeasList ,1 )
119
- [nirs .t , nirs .d(: ,iM )] = simulateDataTimeSeries(ntpts , 1 , .4 , t0 );
120
- end
121
- snirf = SnirfClass(nirs .d , nirs .t , nirs .SD , [], nirs .s , nirs .CondNames );
122
- if iRun < 10
123
- rname = sprintf(' %s%s /%s _run0%d .snirf' , dirname , sname , sname , iRun );
161
+ for iSess = 1 : nSess
162
+ if iSess < 10
163
+ iSessName = sprintf(' 0%d ' , iSess );
124
164
else
125
- rname = sprintf(' %s%s /%s _run%d .snirf' , dirname , sname , sname , iRun );
165
+ iSessName = sprintf(' %d ' , iSess );
166
+ end
167
+ sessName = sprintf(' ses-%s ' , iSessName );
168
+ sessNameFull = filesepStandard([subjNameFull , sessName ], ' dir:nameonly' );
169
+ if ispathvalid(sessNameFull )
170
+ rmdir(sessNameFull , ' s' )
171
+ end
172
+ mkdir(sessNameFull );
173
+
174
+ for iRun = 1 : nRuns
175
+ for iM = 1 : size(nirs .SD .MeasList ,1 )
176
+ [nirs .t , nirs .d(: ,iM )] = simulateDataTimeSeries(ntpts , 1 , .4 , t0 );
177
+ end
178
+ snirf = SnirfClass(nirs .d , nirs .t , nirs .SD , [], nirs .s , nirs .CondNames );
179
+ if iRun < 10
180
+ runNameFull = sprintf(' %s%s _%s _run0%d .snirf' , sessNameFull , subjName , sessName , iRun );
181
+ else
182
+ runNameFull = sprintf(' %s%s _%s _run%d .snirf' , sessNameFull , subjName , sessName , iRun );
183
+ end
184
+ snirf .Save(runNameFull );
185
+ fprintf(' Created run %s\n ' , runNameFull );
126
186
end
127
- snirf .Save(rname );
128
- fprintf(' Created run %s\n ' , rname );
129
187
end
130
188
end
131
189
132
190
133
-
134
191
% -----------------------------------------------------------------
135
192
function resetDataset(dirname )
136
193
if ~exist(' dirname' ,' var' )
@@ -188,7 +245,7 @@ function resetDataset(dirname)
188
245
B = [ ...
189
246
cos(beta ) 0 sin(beta ) 0 ;
190
247
0 1 0 0 ;
191
- - sin(beta ) 0 cos(beta ) 0 ;
248
+ - sin(beta ) 0 cos(beta ) 0 ;
192
249
0 0 0 1 ;
193
250
];
194
251
@@ -207,7 +264,7 @@ function resetDataset(dirname)
207
264
];
208
265
209
266
S = [ ...
210
- s(1 ) 0 0 0 ;
267
+ s(1 ) 0 0 0 ;
211
268
0 s(2 ) 0 0 ;
212
269
0 0 s(3 ) 0 ;
213
270
0 0 0 1 ;
@@ -246,7 +303,7 @@ function generateRandNumSeed(time0)
246
303
s = 0 ;
247
304
while s == 0
248
305
s = uint64(1e4 * toc(time0 ));
249
- end
306
+ end
250
307
rng(s );
251
308
end
252
309
0 commit comments