-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSNRandCNRfieldDependenceJMRI.m
515 lines (412 loc) · 16.9 KB
/
SNRandCNRfieldDependenceJMRI.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
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
%% Read Me
% cd to the directory where the function SNRandCNRfieldDependenceJMRI.m is located
% you can either run the whole code or simply use the html file to navigate
% through the results
%% initializing path and variables
close all
clear all
CurrDirectory = pwd ;
addpath(genpath(CurrDirectory)) ;
gamma = 42.577e6 ; % gyromagnetic constant in Hz
SNR_PowerLaw = 1.5 ; % at high fields this has been measured at 1.68, at lower fields it is expected to tend towards 1 because noise in the sample
% range of fields of simulations
B0 = [0.1:0.1:7] ;
% assumption of dead time within a GRE
%(time needed to crush magnetization, apply slice selective and phase encoding gradients)
DeadTime = 3e-3 ;
PDT1approach = 'ShortEnoughTE' ; % options are 'ShortEnoughTE' or 'minTR'
minTR = 7e-3 ; % minimum repetition time achievable (used in PD and T1w in case of minTR)
TEfractionOfT2 = 1 / 8 ; % fraction of shorter T2 at which we assume that no T2* contrast exists (used for PD and T1w)
PDflip_Ernstfract = 0.25 ; % Fraction of the Ernst flip angle used for PD
TE_SpinEcho = 70e-3; % used on the 2D example
PlotIntermediate = 0 ;
%% initializing relaxation times field dependence
% Longitudinal and transverse relaxation rates using the models presented
% in:
% - Rooney et al MRM 2007;
% - Pohmann et al MRM 2016;
% R1 as a function of magnetic field according to
% Rooney et al, MRM, 2007
% and using a model suggested by Bottemley et al, Med Phys, 1984
T1_WM = 0.00071 * (gamma*B0).^0.382;
T1_GM = 0.00116 * (gamma*B0).^0.376;
T1_BL = 0.00335 * (gamma*B0).^0.340;
T1_CSF =1/0.231 * ones(size(B0));
% using Pohmann et al, MRM, 2016
T2s_GM = 0.090 * exp(-0.142 *B0);
T2s_WM = 0.064 * exp(-0.132 *B0);
T2s_CSF = 0.1*ones(size(B0)); % made up.. but not too relevant
SNR_B0 = B0.^SNR_PowerLaw ;
%% relaxation parameters - plotting relaxation parameters as a function of field
figure('name','Relaxation Rates ','numbertitle','off')
set(gcf,'Position',[ 11 627 917 369],'Color',[1 1 1])
subplot(121)
hold off
plot(B0,1./T1_GM,'-','Color',[1 1 1]*0.0,'Linewidth',2)
hold on
plot(B0,1./T1_WM,'-','Color',[1 1 1]*0.35,'Linewidth',2)
plot(B0,1./T1_CSF,'-.','Color',[1 1 1]*0.8,'Linewidth',2)
legend('GM ','WM ', 'CSF');
title (['R_1 as a function of B_0'])
ylabel(['R_1 (s^{-1})'])
xlabel(['B_0 (T)'])
axis tight
subplot(122)
hold off
plot(B0,1./T2s_GM,'-','Color',[1 1 1]*0.0,'Linewidth',2)
hold on
plot(B0,1./T2s_WM,'-','Color',[1 1 1]*0.35,'Linewidth',2)
legend('GM ','WM ')
title (['R_2^* as a function of B_0'])
ylabel(['R_2^* (s^{-1})'])
xlabel(['B_0 (T)'])
axis tight
fontScale(1.1)
figure('name','Relaxation times ','numbertitle','off')
set(gcf,'Position',[ 11 627 917 369],'Color',[1 1 1])
subplot(121)
hold off
plot(B0,T1_GM,'-','Color',[1 1 1]*0.0,'Linewidth',2)
hold on
plot(B0,T1_WM,'-','Color',[1 1 1]*0.4,'Linewidth',2)
plot(B0,T1_CSF,'-.','Color',[1 1 1]*0.8,'Linewidth',2)
legend('GM ','WM ', 'CSF','Location','East');
axis tight
axis([0 max(B0) 0 max(T1_CSF)*1.1])
title (['T_1 as a function of B0'])
ylabel(['T_1 (s)'])
xlabel(['B_0 (T)'])
subplot(122)
hold off
plot(B0,T2s_GM,'-','Color',[1 1 1]*0.0,'Linewidth',2)
hold on
plot(B0,T2s_WM,'-','Color',[1 1 1]*0.4,'Linewidth',2)
axis tight
axis([0 max(B0) 0 max(T2s_GM)*1.1])
legend('GM ','WM ')
title (['T_2^* as a function of B0'])
ylabel(['T_2^* (s)'])
xlabel(['B_0 (T)'])
fontScale(1.1)
% savefig('RelaxationTimes')
%% Functions
% Ernst Angle and GRE signal calculation
% Ernst Angle Calculation in degrees
Ernstangle_d = @(TRep,T1) acosd( exp(-TRep./T1) );
% GRESignal calculation
GRESignal = @(FlipAngle,TRep,TE,T1,T2) sind(FlipAngle).*exp(-TE/T2).*(1-exp(-TRep./T1))./(1-(exp(-TRep./T1)).*cosd(FlipAngle));
%% T1-w imaging
% Sequence optimized (flip angle and TR, while TE= T2s_WM * TEfractionOfT2)
% at each B0 to yield maximum contrast between grey and white matter
if strcmp(PDT1approach,'minTR')
% At Fixed TR
TR = minTR * ones(size(B0));
TE = TR / 2;
elseif strcmp(PDT1approach,'ShortEnoughTE')
% Using a "short" TE in respect to T2 of WM
TE = T2s_WM * TEfractionOfT2;
TR = 2 * TE;
else
error('Unknow PD and T1 approach, it has to be either ''ShortEnoughTE'' or ''minTR'' ')
end;
% calculation of signal
BW = 1 ./ (2 * TE - DeadTime);
OptimumTheta=zeros([1,length(B0)]);
for k=1:length(B0)
[OptimumTheta(k)]=simContrastvFlip([T1_WM(k) T1_GM(k)],TR(k),0);
end;
GREs_GM = GRESignal(OptimumTheta,TR,TE,T1_GM,T2s_GM);
GREs_WM = GRESignal(OptimumTheta,TR,TE,T1_WM,T2s_WM);
GREs_CSF = GRESignal(OptimumTheta,TR,TE,T1_CSF,T2s_CSF);
figure('name','T1w imaging ','numbertitle','off')
set(gcf,'Position',[ 936 165 917 369],'Color',[1 1 1])
subplot(121)
hold off
plot(B0,GREs_GM,'-','Color',[1 1 1]*0.0,'Linewidth',2)
hold on
plot(B0,GREs_WM,'-','Color',[1 1 1]*0.35,'Linewidth',2)
plot(B0,GREs_CSF,'-.','Color',[1 1 1]*0.8,'Linewidth',2)
plot(B0,GREs_WM-GREs_GM,'-','Color',[1 1 1]*0.6,'Linewidth',2)
legend('GM ','WM ','CSF','GM vs WM contrast')
% legend('GM ','WM ','GM vs WM contrast')
title (['T_1w Signal as a function of B_0'])
ylabel(['Signal '])
xlabel(['B_0 (T)'])
axis tight
subplot(122)
hold off
plot(B0,SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*GREs_GM,'-','Color',[1 1 1]*0.0,'Linewidth',2)
hold on
plot(B0,SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*GREs_WM,'-','Color',[1 1 1]*0.35,'Linewidth',2)
plot(B0,SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*GREs_CSF,'-','Color',[1 1 1]*0.8,'Linewidth',2)
plot(B0,SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*(GREs_WM-GREs_GM),'-','Color',[1 1 1]*0.6,'Linewidth',2)
% legend('GM ','WM ','GM vs WM contrast')
title (['T_1w SNR accounting for TR and BW'])
ylabel(['SNR (au)'])
xlabel(['B_0 (T)'])
axis tight
y1 = SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*(GREs_WM );
y = SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*(GREs_WM -GREs_GM);
% fitting the model using a log transform re-weighted by the amplitude for
% a more balanced weigthting
beta = PowerLawFit(y,B0);
plot(B0,beta(1)*B0.^(beta(2)),'-.','Color',[1 1 1]*0.6,'Linewidth',2)
legend('GM ','WM ','CSF','GM vs WM contrast','GM vs WM contrast fit','Location','East')
text(min(B0)+(max(B0)-min(B0))*0.05 ,max(y1)*0.9,['Power Law of T_1w CNR = B_0 ^{',num2str(round(beta(2)*100)/100),'}'])
text(min(B0)+(max(B0)-min(B0))*0.05 ,max(y1)*0.8,['Power Law of SNR = B_0 ^{',num2str(round(SNR_PowerLaw*10)/10),'}'])
fontScale(1.1)
% savefig('T1wCNR_VariableTR')
figure('name','T1w Ernst Angle ','numbertitle','off')
set(gcf,'Position',[ 1367 599 426 344],'Color',[1 1 1])
hold off
plot(B0,TR*1000,'-','Color',[1 1 1]*0.0,'Linewidth',2)
hold on
plot(B0,OptimumTheta,'-','Color',[1 1 1]*0.5,'Linewidth',2)
legend('TR (ms)','Flip Angle (degrees)')
legend('TR (ms)','Flip Angle (degrees)','Location','Best')
xlabel(['B_0 (T)'])
ylabel(['Flip Angle (degrees) ; TR (ms)'])
title(['sequence Paraemters as a function of B_0'])
fontScale(1.1)
% savefig('T1w_VariableTR_parameters')
%% PD-w imaging
% Sequence optimized (flip angle = PDflip_Ernstfract * ErnstAngle , while TE= T2s_WM * TEfractionOfT2)
% at each B0 to yield a proton density type of contrast
if strcmp(PDT1approach,'minTR')
%At Fixed TR
TR = minTR * ones(size(B0));
TE = TR / 2;
elseif strcmp(PDT1approach,'ShortEnoughTE')
TE = T2s_WM * TEfractionOfT2;
TR = 2 * TE;
else
error('Unknow PD and T1 approach, it has to be either ''ShortEnoughTE'' or ''minTR'' ')
end;
%calculation of signal
BW = 1 ./ (2 * TE - DeadTime);
theta = PDflip_Ernstfract * Ernstangle_d(TR,T1_GM);
GREs_GM = GRESignal(theta,TR,TE,T1_GM,T2s_GM);
GREs_WM = GRESignal(theta,TR,TE,T1_WM,T2s_WM);
GREs_CSF = GRESignal(theta,TR,TE,T1_CSF,T2s_CSF);
figure('name','PD imaging ','numbertitle','off')
set(gcf,'Position',[ 938 627 917 369],'Color',[1 1 1])
subplot(121)
hold off
plot(B0,GREs_GM,'-','Color',[1 1 1]*0.0,'Linewidth',2)
hold on
plot(B0,GREs_WM,'-','Color',[1 1 1]*0.35,'Linewidth',2)
plot(B0,GREs_CSF,'-','Color',[1 1 1]*0.8,'Linewidth',2)
legend('GM ','WM ','CSF')
legend('GM ','WM ')
title (['PD Signal as a function of B0'])
ylabel(['Signal '])
xlabel(['B_0 (T)'])
axis tight
subplot(122)
hold off
plot(B0,SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*GREs_GM,'-','Color',[1 1 1]*0.0,'Linewidth',2)
hold on
plot(B0,SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*GREs_WM,'-','Color',[1 1 1]*0.35,'Linewidth',2)
plot(B0,SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*GREs_CSF,'-','Color',[1 1 1]*0.8,'Linewidth',2)
title (['PD SNR accounting for TR and BW'])
ylabel(['SNR (au)'])
xlabel(['B_0 (T)'])
axis tight
y = SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*GREs_WM;
% fitting the model using a log transform re-weighted
beta = PowerLawFit(y,B0);
plot(B0,beta(1)*B0.^(beta(2)),'-.','Color',[1 1 1]*0.6,'Linewidth',2)
text(min(B0)+(max(B0)-min(B0))*0.05 ,max(y)*0.9,['Power Law of PD SNR = B_0 ^{',num2str(round(beta(2)*100)/100),'}'])
text(min(B0)+(max(B0)-min(B0))*0.05 ,max(y)*0.8,['Power Law of SNR = B_0 ^{',num2str(round(SNR_PowerLaw*10)/10),'}'])
legend('GM ','WM ','CSF ','GM fit','Location','East')
fontScale(1.1)
% savefig('PDCNR_VariableTR')
%% T2*-w imaging contrast
% sequence optimized to have the TE that gives the optimum GM WM contrast at given field
% Remainging parameters were optimizer for SNR
for k=1:length(B0)
[TE(k)]=simContrastvTE([T2s_WM(k) T2s_GM(k)]*1000,0)/1000;
end;
TR = 2 * TE;
OptimumTheta = Ernstangle_d(TR,T1_GM);
%calculation of signal
BW = 1 ./ (2 * TE - DeadTime);
GREs_GM = GRESignal(OptimumTheta,TR,TE,T1_GM,T2s_GM);
GREs_WM = GRESignal(OptimumTheta,TR,TE,T1_WM,T2s_WM);
figure('name','T2*w ','numbertitle','off')
set(gcf,'Position',[8 167 917 369],'Color',[1 1 1])
subplot(121)
hold off
plot(B0,GREs_GM,'-','Color',[1 1 1]*0.0,'Linewidth',2)
hold on
plot(B0,GREs_WM,'-','Color',[1 1 1]*0.35,'Linewidth',2)
plot(B0,GREs_WM-GREs_GM,'-','Color',[1 1 1]*0.6,'Linewidth',2)
legend('GM ','WM ','GM vs WM contrast')
title (['T_2*w Signal as a function of B_0'])
ylabel(['Signal '])
xlabel(['B_0 (T)'])
axis tight
subplot(122)
hold off
plot(B0,SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*GREs_GM,'-','Color',[1 1 1]*0.0,'Linewidth',2)
hold on
plot(B0,SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*GREs_WM,'-','Color',[1 1 1]*0.35,'Linewidth',2)
plot(B0,SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*(GREs_GM-GREs_WM),'-','Color',[1 1 1]*0.6,'Linewidth',2)
%
title (['T2*w SNR accounting for TR and BW'])
ylabel(['SNR (au)'])
xlabel(['B_0 (T)'])
axis tight
y1 = SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*(GREs_GM );
y = SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*(GREs_GM -GREs_WM);
x0=[0.1 1];
% fitting the model using a log transform re-weighted
beta = PowerLawFit(y,B0);
plot(B0,beta(1)*B0.^(beta(2)),'-.','Color',[1 1 1]*0.6,'Linewidth',2)
legend('GM ','WM ','GM vs WM contrast','GM vs WM contrast fit','Location','East')
text(min(B0)+(max(B0)-min(B0))*0.05 ,max(y1)*0.9,['Power Law of T2*w CNR = B_0 ^{',num2str(round(beta(2)*100)/100),'}'])
text(min(B0)+(max(B0)-min(B0))*0.05 ,max(y1)*0.8,['Power Law of SNR = B_0 ^{',num2str(round(SNR_PowerLaw*10)/10),'}'])
fontScale(1.1)
% savefig('T2swCNR_VariableTR ')
%%
%% 2D GRE signal considering various numbers of interleaved slices
% T1 and T2*-w were obtained using the same consideration as in the previous sections;
% T2w in diffusion like experiments was also simulated:
% TE assumed to be constant across fields
Nslices =1:64;
if PlotIntermediate
fnumbT2 = figure('name','2D T2* Ernst Angle ','numbertitle','off','Color',[1 1 1])
fnumbT1 = figure('name','2D T1w ','numbertitle','off','Color',[1 1 1])
fnumbSE = figure('name','2D Spin Echo ','numbertitle','off','Color',[1 1 1])
end;
for Ns=Nslices;
% T2* contrast
for k=1:length(B0)
[TE(k)]=simContrastvTE([T2s_WM(k) T2s_GM(k)]*1000,0)/1000;
end;
%calculation of signal
BW = 1 ./ (2 * TE - DeadTime);
TR = 2 * TE * Ns;
OptimumTheta = Ernstangle_d(TR,T1_GM);
GREs_GM = GRESignal(OptimumTheta,TR,TE,T1_GM,T2s_GM);
GREs_WM = GRESignal(OptimumTheta,TR,TE,T1_WM,T2s_WM);
y1 = SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*(GREs_GM );
y = SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*(GREs_GM -GREs_WM);
% fitting the model using a log transform re-weighted
beta = PowerLawFit(y,B0);
% plot(B0,beta(1)*B0.^(beta(2)),'-.','Color',[1 1 1]*0.6,'Linewidth',2)
powerlawT2star(Ns)=beta(2);
propT2star(Ns)=beta(1);
if PlotIntermediate
figure(fnumbT2)
if Ns==1, hold off, end;
subplot(121)
plot(B0,y,'Color',[1 1 1]*(Ns-min(Nslices))/max(Nslices))
ylabel([' SNR (au)'])
xlabel(['B_0 (T)'])
hold on
subplot(122)
plot(B0,beta(1)*B0.^(beta(2)),'-.','Color',[1 1 1]*(Ns-min(Nslices))/max(Nslices),'Linewidth',2)
hold on
ylabel(['fitted SNR (au)'])
xlabel(['B_0 (T)'])
end;
% T1 contrast
TE = T2s_WM * TEfractionOfT2;
TR = 2 * TE * Ns;
%calculation of signal
BW = 1 ./ (2 * TE - DeadTime);
for k=1:length(B0)
[OptimumTheta(k)]=simContrastvFlip([T1_WM(k) T1_GM(k)],TR(k),0);
end;
GREs_GM = GRESignal(OptimumTheta,TR,TE,T1_GM,T2s_GM);
GREs_WM = GRESignal(OptimumTheta,TR,TE,T1_WM,T2s_WM);
GREs_CSF = GRESignal(OptimumTheta,TR,TE,T1_CSF,T2s_CSF);
y = SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*(GREs_WM -GREs_GM);
% fitting the model using a log transform re-weighted
beta = PowerLawFit(y,B0);
powerlawT1(Ns)=beta(2);
propT1(Ns)=beta(1);
if PlotIntermediate
figure(fnumbT1)
subplot(121)
if Ns==1, hold off, end;
plot(B0,y,'Color',[1 1 1]*(Ns-min(Nslices))/max(Nslices))
ylabel(['SNR (au)'])
xlabel(['B_0 (T)'])
hold on
subplot(122)
plot(B0,beta(1)*B0.^(beta(2)),'-.','Color',[1 1 1]*(Ns-min(Nslices))/max(Nslices),'Linewidth',2)
ylabel(['fitted SNR (au)'])
xlabel(['B_0 (T)'])
end;
y = SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*abs(GREs_CSF -GREs_GM);
% fitting the model using a log transform re-weighted
beta = PowerLawFit(y,B0);
powerlawT1_GMCSF(Ns)=beta(2);
propT1_GMCSF(Ns)=beta(1);
% SNR in diffusion like experimetns
% TE assumed to be constant across fields in the assumption of equally
% performing Gradients
TE = ones(size(B0))*TE_SpinEcho;
TR = 1.5 * TE * Ns;
%calculation of signal
BW = 1 ./ (TE - DeadTime);
[OptimumTheta]=ones(size(B0))*90;
GREs_WM = GRESignal(OptimumTheta,TR,TE,T1_WM,T2s_WM);
y = SNR_B0 .* 1./sqrt(TR) .*1./sqrt(BW) .*(GREs_WM );
% fitting the model using a log transform re-weighted
beta = PowerLawFit(y,B0);
powerlawDiff(Ns)=beta(2);
propDiff(Ns)=beta(1);
if PlotIntermediate
figure(fnumbSE)
subplot(121)
if Ns==1, hold off, end;
plot(B0,y,'Color',[1 1 1]*(Ns-min(Nslices))/max(Nslices))
ylabel(['SNR (au)'])
xlabel(['B_0 (T)'])
hold on
subplot(122)
plot(B0,beta(1)*B0.^(beta(2)),'-.','Color',[1 1 1]*(Ns-min(Nslices))/max(Nslices),'Linewidth',2)
ylabel(['fitted SNR (au)'])
xlabel(['B_0 (T)'])
end;
end;
if PlotIntermediate
figure(fnumbT2)
title (['T2*w SNR accounting for TR and BW'])
figure(fnumbT1)
title (['T1 SNR accounting for TR and BW'])
figure(fnumbSE)
title (['SE SNR accounting for TR and BW'])
end;
fnumb2D = figure('name','2D Spin Echo ','numbertitle','off','Color',[1 1 1]);
set(fnumb2D,'Position',[ 461 474 917 369],'Color',[1 1 1])
subplot(121)
hold off
plot(Nslices,powerlawT2star,'-','Color',[1 1 1]*0.45,'Linewidth',2);
hold on
plot(Nslices,powerlawT1,'-','Color',[1 1 1]*0.85,'Linewidth',2);
plot(Nslices,powerlawT1_GMCSF,'-.','Color',[1 1 1]*0.85,'Linewidth',2);
plot(Nslices,powerlawDiff,'-','Color',[1 1 1]*0.05,'Linewidth',2);
text(min(Nslices)+(max(Nslices)-min(Nslices))*0.05 ,max(powerlawDiff)*0.5,['Power Law of SNR = B_0 ^{',num2str(round(SNR_PowerLaw*10)/10),'}'])
legend('T_2* weighted GM WM contrast', 'T1 weighted GM WM contrast', 'T1 weighted GM CSF contrast', 'SNR of T2w');
ylabel(['Power Law'])
xlabel(['Number of Slices'])
axis tight
subplot(122)
hold off
plot(Nslices,propT2star,'-','Color',[1 1 1]*0.45,'Linewidth',2);
hold on
plot(Nslices,propT1,'-','Color',[1 1 1]*0.85,'Linewidth',2);
plot(Nslices,propDiff,'-','Color',[1 1 1]*0.05,'Linewidth',2);
text(min(Nslices)+(max(Nslices)-min(Nslices))*0.05 ,max(propT2star)*0.8,['Power Law of SNR = B_0 ^{',num2str(round(SNR_PowerLaw*10)/10),'}'])
legend('T_2* weighted GM WM contrast', 'T1 weighted GM WM contrast', 'SNR of T2w');
ylabel(['Proportionality Constant'])
xlabel(['Number of Slices'])
axis tight
fontScale(1.1)
figure(fnumb2D)
% savefig('PowerLawsOfContrast');
%% End of simulations