-
Notifications
You must be signed in to change notification settings - Fork 5
/
FaBiAN_demo_CHUV_DA.m
450 lines (441 loc) · 21.2 KB
/
FaBiAN_demo_CHUV_DA.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This script simulates T2-weighted MR images of the fetal brain. %
% Subjects from the CHUV testing set of the FeTA challenge 2022 serve %
% as anatomical models after white matter segmentation using FAST-FSL. %
% Common acquisition parameters were retrieved from 15 cases scanned at %
% Kispi using an SS-FSE sequence on two GE MR scanners. The sequence %
% parameters are chosen randomly among the list of possible parameters. %
% %
% NB: All data will be upsampled to 0.8mm isotropic in the in-plane %
% orientation before SR reconstruction. %
% %
% %
% Hélène Lajous, 2023-03-24 %
% helene.lajous@unil.ch %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all
addpath('/home/he1597/code/DA_OHBM_replicate/Utilities')
addpath('/home/he1597/code/spm12')
% Fetal brain model
FetalModel = 'FeTA';
FetalBrainModelPath = '/data/bach/SimuHASTE/Data/FeTA2021_Release1and2Corrected_v4/';
switch FetalModel
case 'STA'
% Gestational age (in weeks)
SubID_list = 21:38;
case 'FeTA_CHUV'
ParticipantsMetadata = strcat(FetalBrainModelPath, 'FeTA-CHUV_participants.xlsx');
Participants = readtable(ParticipantsMetadata);
SubID_list = string(Participants{:,5});
case 'FeTA'
ParticipantsMetadata = strcat(FetalBrainModelPath, '202303-FeTA2021_Release1and2Corrected_v4-Replicate_OHBM_training_set.xlsx');
Participants = readtable(ParticipantsMetadata, 'Sheet', 'data2sim_1', 'Range', 'A1:F11');
SubID_list = string(Participants{:,1});
end
% % Set of common sequence parameters used:
% % 1. column: main magnetic field strength, B0 (in T);
% % 2. column: effective echo time, TEeff (in ms);
% % 3. column: field-of-view in the readout (frequency) direction, FOVread (in mm)
% % These acquisition parameters were extracted from all the LR series
% % provided by Kelly for 15 subjects scanned at Kispi.
% AcqParam = [3 123.264 240.0256; ...
% 3 123.12 299.9808; ...
% 3 123.12 280.0128; ...
% 3 123.12 259.9936; ...
% 3 122.816 299.9808; ...
% 3 122.816 280.0128; ...
% 3 122.816 259.9936; ...
% 3 122.512 280.0128; ...
% 3 122.512 259.9936; ...
% 3 122.208 280.0128; ...
% 3 121.904 280.0128; ...
% 3 121.296 299.9808; ...
% 3 120.992 320 ; ...
% 3 120.688 320 ; ...
% 3 120.384 280.0128; ...
% 3 120.096 299.9808; ...
% 3 119.808 299.9808; ...
% 3 119.52 299.9808; ...
% 3 118.656 280.0128; ...
% 3 118.368 259.9936; ...
% 3 118.368 240.0256; ...
% 3 118.08 280.0128; ...
% 3 118.08 259.9936; ...
% 3 118.08 240.0256; ...
% 3 117.792 240.0256; ...
% 3 117.504 280.0128; ...
% 3 117.504 259.9936; ...
% 3 117.504 240.0256; ...
% 3 117.216 259.9936; ...
% 3 116.928 259.9936; ...
% 1.5 124.08 299.9808; ...
% 1.5 124.08 280.0128; ...
% 1.5 124.08 259.9936; ...
% 1.5 123.84 299.9808; ...
% 1.5 123.6 299.9808; ...
% 1.5 123.6 250.0096; ...
% 1.5 123.36 299.9808; ...
% 1.5 122.304 240.0256; ...
% 1.5 120.288 259.9936; ...
% 1.5 120.064 299.9808; ...
% 1.5 120.064 289.9968; ...
% 1.5 118.944 269.9776; ...
% 1.5 118.72 259.9936; ...
% 1.5 118.496 259.9936; ...
% 1.5 118.048 259.9936; ...
% 1.5 117.824 259.9936; ...
% 1.5 117.824 240.0256; ...
% 1.5 117.376 259.9936; ...
% 1.5 116.928 240.0256; ...
% 1.5 116.704 240.0256; ...
% 1.5 116.48 299.9808; ...
% 1.5 116.48 240.0256; ...
% 1.5 116.256 259.9936; ...
% 1.5 116.032 299.9808; ...
% 1.5 116.032 259.9936];
% Clinical magnetic field strength
B0_list = [1.5, 3];
% List of possible effective echo times (TEeff, in ms) at 1.5T
TEeff_list = [ 124.08 ; ...
123.84 ; ...
123.6 ; ...
123.36 ; ...
122.304 ; ...
120.288 ; ...
120.064 ; ...
118.944 ; ...
118.72 ; ...
118.496 ; ...
118.048 ; ...
117.824 ; ...
117.376 ; ...
116.928 ; ...
116.704 ; ...
116.48 ; ...
116.256 ; ...
116.032 ];
% List of possible effective echo times at 3T
TEeff_3T_list = [ 123.264 ; ...
123.12 ; ...
122.816 ; ...
122.512 ; ...
122.208 ; ...
121.904 ; ...
121.296 ; ...
120.992 ; ...
120.688 ; ...
120.384 ; ...
120.096 ; ...
119.808 ; ...
119.52 ; ...
118.656 ; ...
118.368 ; ...
118.08 ; ...
117.792 ; ...
117.504 ; ...
117.216 ; ...
116.928 ];
% Combinations of (T1,T2) values in the fetal brain tissues at 1.5T
% 1. column: T1 relaxation time of white matter
% 2. column: T2 relaxation time of white matter
% 3. column: T1 relaxation time of grey matter
% 4. column: T2 relaxation time of grey matter
% 5. column: T1 relaxation time of cerebrospinal fluid
% 6. column: T2 relaxation time of cerebrospinal fluid
BrainProperties = [ 2761 291 2068 174 4000 2000; ...
2509 275 2086 181 4000 2000; ...
3054 300 2363 189 4000 2000; ...
3003 288 2345 191 4000 2000; ...
2766 285 2339 189 4000 2000; ...
2416 274 2019 178 4000 2000; ...
2816 294 2014 174 4000 2000; ...
2545 281 1971 173 4000 2000; ...
2803 285 2052 180 4000 2000; ...
2768 285 2407 188 4000 2000; ...
2581 282 2367 188 4000 2000; ...
2381 273 2069 177 4000 2000; ...
2549 276 2054 179 4000 2000; ...
2433 276 2017 174 4000 2000; ...
2649 281 2343 182 4000 2000; ...
2504 284 2266 182 4000 2000; ...
2576 281 2376 188 4000 2000; ...
2391 280 2079 181 4000 2000; ...
2845 288 2365 184 4000 2000; ...
2363 280 2164 181 4000 2000; ...
2955 296 2087 180 4000 2000; ...
2963 286 2097 178 4000 2000; ...
2933 286 2129 177 4000 2000; ...
3028 295 2404 191 4000 2000; ...
2368 277 2091 177 4000 2000; ...
2392 275 2130 181 4000 2000; ...
2587 274 2098 178 4000 2000; ...
2958 299 2041 179 4000 2000; ...
2569 278 1955 172 4000 2000; ...
2912 299 2016 174 4000 2000; ...
2498 283 2352 190 4000 2000; ...
2967 292 2288 183 4000 2000; ...
2604 280 2015 177 4000 2000; ...
2746 289 2383 187 4000 2000; ...
2873 286 2353 191 4000 2000; ...
3020 300 2255 186 4000 2000; ...
2587 275 2032 179 4000 2000; ...
3098 298 2321 182 4000 2000; ...
2431 274 2049 181 4000 2000; ...
2994 288 2032 178 4000 2000; ...
2416 272 2041 173 4000 2000; ...
2440 284 2324 183 4000 2000; ...
2931 298 2114 177 4000 2000; ...
3070 300 2070 173 4000 2000; ...
2327 270 2039 174 4000 2000; ...
2426 283 2279 182 4000 2000; ...
2324 272 2434 191 4000 2000; ...
2375 272 1966 174 4000 2000; ...
3048 295 2370 190 4000 2000; ...
2761 291 1959 173 4000 2000; ...
2336 273 2071 178 4000 2000; ...
2923 297 2328 185 4000 2000; ...
2608 276 2092 179 4000 2000; ...
3027 297 2060 180 4000 2000; ...
2476 283 1969 174 4000 2000; ...
2361 275 2381 188 4000 2000; ...
2828 298 2126 180 4000 2000; ...
2519 283 2254 186 4000 2000; ...
2726 287 2129 177 4000 2000; ...
2872 299 2351 188 4000 2000; ...
3056 297 2377 187 4000 2000; ...
2994 286 2307 184 4000 2000; ...
2468 276 2067 178 4000 2000; ...
2613 278 2428 191 4000 2000; ...
2642 283 2078 180 4000 2000; ...
3047 299 2293 184 4000 2000; ...
2925 293 2341 187 4000 2000; ...
3023 288 2364 191 4000 2000; ...
3079 294 2082 180 4000 2000; ...
2861 299 2171 181 4000 2000];
% Combinations of (T1,T2) values in the fetal brain tissues at 3T
BrainProperties_3T = [ 2670 274 2568 172 4400 2000; ...
3194 289 2561 178 4400 2000; ...
3199 285 2884 188 4400 2000; ...
3103 285 2466 172 4400 2000; ...
2762 273 2989 191 4400 2000; ...
3276 292 2902 189 4400 2000; ...
2575 271 2862 184 4400 2000; ...
3266 292 2981 191 4400 2000; ...
3135 294 2674 180 4400 2000; ...
2715 276 2553 172 4400 2000; ...
2789 270 2963 189 4400 2000; ...
3338 296 2579 174 4400 2000; ...
3213 295 2860 188 4400 2000; ...
2529 271 2658 178 4400 2000; ...
2607 279 2912 190 4400 2000; ...
2804 277 2599 180 4400 2000; ...
3008 288 2635 181 4400 2000; ...
3219 285 2998 191 4400 2000; ...
2809 273 2541 174 4400 2000; ...
2580 271 2656 181 4400 2000; ...
2748 270 2600 172 4400 2000; ...
3347 299 2564 176 4400 2000; ...
3282 292 2867 185 4400 2000; ...
3291 296 2809 184 4400 2000; ...
3327 291 2577 176 4400 2000; ...
2784 281 2936 188 4400 2000; ...
2784 278 2810 185 4400 2000; ...
2642 275 2645 180 4400 2000; ...
3179 291 2961 186 4400 2000; ...
2706 275 2803 184 4400 2000; ...
2680 275 2956 190 4400 2000; ...
3208 294 2552 174 4400 2000; ...
2694 273 2904 182 4400 2000; ...
2726 274 2832 184 4400 2000; ...
3096 296 2887 182 4400 2000; ...
2814 270 2855 183 4400 2000; ...
2623 272 2918 187 4400 2000; ...
2719 280 2881 189 4400 2000; ...
2609 278 2916 190 4400 2000; ...
3202 300 2888 188 4400 2000; ...
2739 281 2550 174 4400 2000; ...
3193 286 2912 191 4400 2000; ...
2676 277 2854 188 4400 2000; ...
3016 288 2621 174 4400 2000; ...
3073 288 2691 178 4400 2000; ...
3197 297 2581 174 4400 2000; ...
2817 284 2637 176 4400 2000; ...
3365 300 2848 184 4400 2000; ...
2592 275 2814 182 4400 2000; ...
3049 286 2778 183 4400 2000; ...
3266 292 2690 179 4400 2000; ...
2559 270 2670 181 4400 2000; ...
3414 300 2693 178 4400 2000; ...
3121 288 2703 180 4400 2000; ...
3153 292 2848 185 4400 2000; ...
2691 276 2574 176 4400 2000; ...
3138 295 2880 187 4400 2000; ...
2529 271 2932 191 4400 2000; ...
2866 284 2605 177 4400 2000; ...
3293 292 2913 183 4400 2000; ...
2784 282 2649 176 4400 2000; ...
3147 294 2855 183 4400 2000; ...
3254 295 2559 178 4400 2000; ...
2701 272 2798 182 4400 2000; ...
3169 295 2912 184 4400 2000; ...
3007 286 2565 173 4400 2000; ...
2642 278 2707 181 4400 2000; ...
2632 281 2853 185 4400 2000; ...
3191 286 2721 180 4400 2000; ...
3314 291 2980 188 4400 2000];
% Session ID
SesID = 1;
% Introduce a shift variable to slightly shift the slice series between two
% simulations in the same orientation
Shift_mm_list = [0 -1.6; 0 1.6; -1.6 0; 1.6 0; -1.6 1.6; 1.6 -1.6]; %mm
% Non-linear slowly-varying intensity non-uniformity (INU) fields (b1+) can
% be downloaded from BrainWeb database:
% https://brainweb.bic.mni.mcgill.ca/brainweb/about_sbd.html
INU = '/data/bach/SimuHASTE/rf20_B.rawb';
% Define a sampling factor to subdivide the volume in the slice thickness
% orientation
SamplingFactor = 8;
% Motion
MotionLevel = 0;
% Implement WM changes
WMheterogeneity = 1;
% Depending on the application, resampling of the simulated images might be
% needed
SimResampling = 'false';
% Depending on the application, the simulated images can be cropped to the
% size of the original anatomical model
SimCrop = 'true';
% Create folder for outputs
OutputFolder = '/data/bach/SimuHASTE/202304_DA_OHBM_replicate/';
if not(isfolder(OutputFolder))
mkdir(OutputFolder)
end
for sub=1:length(SubID_list)
SubID = SubID_list(sub);
B0 = B0_list(randperm(length(B0_list),1));
% AcqParam_index = randperm(size(AcqParam,1), 1);
% B0 = AcqParam(AcqParam_index, 1);
% TEeff = AcqParam(AcqParam_index, 2);
% FOVRead = AcqParam(AcqParam_index, 3);
FlipAngle = randi([150 180], 1, 1); %refocusing flip angle (in degrees)
FOVRead = 409.6;
FOVPhase = FOVRead;
if B0==1.5
% Define T1 and T2 properties of the fetal brain tissues at 1.5T
BrainProperties_index = randperm(size(BrainProperties,1), 1);
T1_WM = BrainProperties(BrainProperties_index, 1);
T2_WM = BrainProperties(BrainProperties_index, 2);
T1_GM = BrainProperties(BrainProperties_index, 3);
T2_GM = BrainProperties(BrainProperties_index, 4);
T1_CSF = BrainProperties(BrainProperties_index, 5);
T2_CSF = BrainProperties(BrainProperties_index, 6);
% Contrast
TEeff = TEeff_list(randperm(length(TEeff_list),1));
TR = 10; %ms
% Acquisition parameters
ESP = 10; %ms
ETL = 224;
% Geometry
PhaseOversampling = 0;
SliceThickness = 3; %mm
SliceGap = 0; %mm
% Resolution
BaseResolution = 256; %voxels
PhaseResolution = 1;
% Acceleration technique
ACF = 1;
RefLines = 0;
% Scanner zero-interpolation filling (ZIP)
% (0: no ZIP; 1: Fermi filtering in k-space and ZIP)
ZIP = 1;
ReconMatrix = 2 * BaseResolution;
% SNR
% std_noise = 0.05;
SDnoise_list = [3 4 5 6 7] * 0.01;
SDnoise = SDnoise_list(randperm(length(SDnoise_list), 1));
elseif B0==3
% Define T1 and T2 properties of the fetal brain tissues at 3T
BrainProperties_index = randperm(size(BrainProperties_3T,1), 1);
T1_WM = BrainProperties_3T(BrainProperties_index, 1);
T2_WM = BrainProperties_3T(BrainProperties_index, 2);
T1_GM = BrainProperties_3T(BrainProperties_index, 3);
T2_GM = BrainProperties_3T(BrainProperties_index, 4);
T1_CSF = BrainProperties_3T(BrainProperties_index, 5);
T2_CSF = BrainProperties_3T(BrainProperties_index, 6);
% Contrast
TEeff = TEeff_3T_list(randperm(length(TEeff_3T_list),1));
TR = 10; %ms
% Acquisition parameters
ESP = 10; %ms
ETL = 224;
% Geometry
PhaseOversampling = 0;
SliceThickness = 3; %mm
SliceGap = 0; %mm
% Resolution
BaseResolution = 256; %voxels
PhaseResolution = 1;
% Acceleration technique
ACF = 1;
RefLines = 0;
% Scanner zero-interpolation filling (ZIP)
% (0: no ZIP; 1: Fermi filtering in k-space and ZIP)
ZIP = 1;
ReconMatrix = 2 * BaseResolution;
% SNR
% std_noise = 0.004;
SDnoise_list = [2 3 4 5 6] * 0.001;
SDnoise = SDnoise_list(randperm(length(SDnoise_list), 1));
end
% Simulate LR series in the three orthogonal orientations
% (1: sagittal, 2: coronal, 3: axial)
for Orientation=1:3
Shift_index = randperm(length(Shift_mm_list), 1);
for k=1:2
Shift_mm = Shift_mm_list(Shift_index,k);
RunID = name_run(Orientation, Shift_mm);
sprintf('Current subject being simulated: %s, session: %02s, run: %s', SubID, num2str(SesID), num2str(RunID))
HASTEimages = FaBiAN_main_CHUV_DA(FetalBrainModelPath, ...
FetalModel, ...
SubID, ...
SesID, ...
RunID, ...
Shift_mm, ...
Orientation, ...
INU, ...
SamplingFactor, ...
B0, ...
ESP, ...
ETL, ...
PhaseOversampling, ...
SliceThickness, ...
SliceGap, ...
FOVRead, ...
FOVPhase, ...
BaseResolution, ...
PhaseResolution, ...
TR, ...
TEeff, ...
FlipAngle, ...
ACF, ...
RefLines, ...
MotionLevel, ...
ZIP, ...
ReconMatrix, ...
SDnoise, ...
SimResampling, ...
SimCrop, ...
OutputFolder, ...
WMheterogeneity, ...
T1_WM, ...
T2_WM, ...
T1_GM, ...
T2_GM, ...
T1_CSF, ...
T2_CSF);
end
end
end