-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript_Macro_GRE_MEsequencePulseq.m
214 lines (174 loc) · 9.63 KB
/
script_Macro_GRE_MEsequencePulseq.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
%--------------------------------------------------------------------------
%% add path to relevant PulseqFiles
%--------------------------------------------------------------------------
CurrentDir = ['C:\Users\josmar\surfdrive\SharedBerkin']
cd(CurrentDir)
addpath([CurrentDir,'\pulseq-master\matlab'])
addpath([CurrentDir,'\func\utils_pulseq'])% some relvant functions to define k-space patterns
SaveDir =['compiled_seq_files/For2022Abstract/'];
mkdir(SaveDir)
%%
sys=mr.opts('maxGrad',24,'gradUnit','mT/m','riseTime',400e-6,...
'rfRingdownTime', 30e-6, 'rfDeadTime', 100e-6,'B0',3);
%--------------------------------------------------------------------------
%% Protocol 1 = 3 mm iso, R=1, I went to 4mm to avoid having odd number and none integer matrix sizes
%--------------------------------------------------------------------------
DeltaTE = 4e-3;
TEmin = 3e-3;
TEmax = 32e-3;
res = 3;
SeqParams.TR = 40e-3; % Repetition time in secs
SeqParams.TE = [TEmin:DeltaTE:TEmax]; % Echo time in secs
SeqParams.Tread = 3.e-3; % Readouttime in secs
SeqParams.FlipAngle = 15; % flip angle in degrees
SeqParams.FOV = [256e-3] * [1 6/8 7/8] ; % Field of View of output
SeqParams.Dims = round( 256/res *[1 6/8 7/8]) ; % Dimensions of output
SeqParams.useMCnavigator = 0 ; % in case a fully sampled centre of k-space
SeqParams.RyRzCaipi = [1 1 0] ; % [Ry Rz Caipi] should define the downsampling pattern
SeqParams.Ndummy = round(5 / SeqParams.TR) ; % 5 secs of Dummys
SeqParams.rfphasecycle = 50; % we are using the 50 degree used in the siemens implementatoin
SeqParams.readoutOversampling =2; % readout Oversampling siemens uses Factor
SeqParams.OutputFile = [SaveDir, 'gre_3d_',num2str(res),'mm_R',num2str(prod(SeqParams.RyRzCaipi(1:2))),'.seq'] % Output File
tic
[seq, SeqParamsUpdated] = writeGradientEcho3D_ME_FreeSpacing_CAIPI (SeqParams, [])
toc
Display_MainAtributes(seq,SeqParamsUpdated)
%--------------------------------------------------------------------------
%% Protcol 2 : 3mm acquisition where each echo was downsampled by a factor of 9
%--------------------------------------------------------------------------
DeltaTE = 4e-3;
TEmin = 3e-3;
TEmax = 32e-3;
res = 3;
SeqParams.TR = 40e-3; % Repetition time in secs
SeqParams.TE = [TEmin:DeltaTE:TEmax]; % Echo time in secs
SeqParams.Tread = 2.5e-3; % Readouttime in secs
SeqParams.FlipAngle = 15; % flip angle in degrees
SeqParams.FOV = [256e-3] * [1 6/8 7/8] ; % Field of View of output
SeqParams.Dims = round( 256/res *[1 6/8 7/8]); % Dimensions of output
SeqParams.useMCnavigator = 0 % in case a fully sampled centre of k-space
SeqParams.RyRzCaipi = [1 9 3] ; % [Ry Rz Caipi] should define the downsampling pattern
SeqParams.Ndummy = round(5 / SeqParams.TR) ; % 5 secs of Dummys
SeqParams.rfphasecycle = 50; % we are using the 50 degree used in the siemens implementatoin
SeqParams.readoutOversampling =2; % readout Oversampling siemens uses Factor
SeqParams.OutputFile = [SaveDir, 'gre_3d_',num2str(res),'mm_R',num2str(prod(SeqParams.RyRzCaipi(1:2))),'.seq'] % Output File
tic
[seq, SeqParamsUpdated] = writeGradientEcho3D_ME_FreeSpacing_CAIPI (SeqParams, [])
toc
Display_MainAtributes(seq,SeqParamsUpdated)
%%
%--------------------------------------------------------------------------
%% Protcol 2 : 3mm acquisition where each echo was downsampled by a factor of 9
%--------------------------------------------------------------------------
DeltaTE = 4e-3;
TEmin = 3e-3;
TEmax = 32e-3;
res = 3;
SeqParams.TR = 40e-3; % Repetition time in secs
SeqParams.TE = [TEmin:DeltaTE:TEmax]; % Echo time in secs
SeqParams.Tread = 2.5e-3; % Readouttime in secs
SeqParams.FlipAngle = 15; % flip angle in degrees
SeqParams.FOV = [256e-3] * [1 6/8 7/8] ; % Field of View of output
SeqParams.Dims = round( 256/res *[1 6/8 7/8]) ; % Dimensions of output
SeqParams.useMCnavigator = 1; % in case a fully sampled centre of k-space
SeqParams.RyRzCaipi = [1 9 3] ; % [Ry Rz Caipi] should define the downsampling pattern
SeqParams.Ndummy = round(5 / SeqParams.TR) ; % 5 secs of Dummys
SeqParams.rfphasecycle = 50 ; % we are using the 50 degree used in the siemens implementatoin
SeqParams.readoutOversampling =2; % readout Oversampling siemens uses Factor
SeqParams.OutputFile = [SaveDir, 'gre_3d_',num2str(res),'mm_R',num2str(prod(SeqParams.RyRzCaipi(1:2))),'_mcNav.seq'] % Output File
tic
[seq, SeqParamsUpdated] = writeGradientEcho3D_ME_FreeSpacing_CAIPI (SeqParams, sys)
toc
Display_MainAtributes(seq,SeqParamsUpdated)
%%
%--------------------------------------------------------------------------
%% Protcol 3 : 3mm acquisition where each echo was downsampled by a factor of 9 + echo shifting used to
%--------------------------------------------------------------------------
DeltaTE = 4e-3;
TEmin = 3e-3;
TEmax = 32e-3;
res = 3;
GoldenAngleFraction = 0.38; % I will use this as a way to unalias successive pairs of echos
SeqParams.TR = 40e-3; % Repetition time in secs
SeqParams.Tread = 2.5e-3; % Readouttime in secs
SeqParams.TE = [TEmin:DeltaTE:TEmax]; % Echo time in secs
for k= 3 : 2 :length(SeqParams.TE)
SeqParams.TE(k:end) = SeqParams.TE(k:end) + round(DeltaTE * GoldenAngleFraction*1e5)/1e5;
end
SeqParams.FlipAngle = 15; % flip angle in degrees
SeqParams.FOV = [256e-3] * [1 6/8 7/8] ; % Field of View of output
SeqParams.Dims = round( 256/res *[1 6/8 7/8]) ; % Dimensions of output
SeqParams.useMCnavigator = 0; % in case a fully sampled centre of k-space
SeqParams.RyRzCaipi = [1 9 3] ; % [Ry Rz Caipi] should define the downsampling pattern
SeqParams.Ndummy = round(5 / SeqParams.TR) ; % 5 secs of Dummys
SeqParams.rfphasecycle = 50 ; % we are using the 50 degree used in the siemens implementatoin
SeqParams.readoutOversampling =2; % readout Oversampling siemens uses Factor
SeqParams.OutputFile = [SaveDir, 'gre_3d_',num2str(res),'mm_R',num2str(prod(SeqParams.RyRzCaipi(1:2))),'_varES.seq'] % Output File
tic
[seq, SeqParamsUpdated] = writeGradientEcho3D_ME_FreeSpacing_CAIPI (SeqParams, sys)
toc
Display_MainAtributes(seq,SeqParamsUpdated)
%--------------------------------------------------------------------------
%% Protcol 4 : 1mm acquisition where each echo was downsampled by a factor of 9
%--------------------------------------------------------------------------
DeltaTE = 5e-3;
TEmin = 3e-3;
TEmax = 32e-3;
res = 1;
SeqParams.TR = 40e-3; % Repetition time in secs
SeqParams.Tread = 3e-3; % Readouttime in secs
SeqParams.TE = [TEmin:DeltaTE:TEmax]; % Echo time in secs
SeqParams.FlipAngle = 15; % flip angle in degrees
SeqParams.FOV = [256e-3] * [1 6/8 7/8] ; % Field of View of output
SeqParams.Dims = round( 256/res *[1 6/8 7/8]) ; % Dimensions of output
SeqParams.useMCnavigator = 1; % in case a fully sampled centre of k-space
SeqParams.RyRzCaipi = [1 9 3] ; % [Ry Rz Caipi] should define the downsampling pattern
SeqParams.Ndummy = round(5 / SeqParams.TR) ; % 5 secs of Dummys
SeqParams.rfphasecycle = 50 ; % we are using the 50 degree used in the siemens implementatoin
SeqParams.readoutOversampling = 2; % readout Oversampling siemens uses Factor
SeqParams.OutputFile = [SaveDir, 'gre_3d_',num2str(res),'mm_R',num2str(prod(SeqParams.RyRzCaipi(1:2))),'.seq'] % Output File
tic
[seq, SeqParamsUpdated] = writeGradientEcho3D_ME_FreeSpacing_CAIPI (SeqParams, sys)
toc
Display_MainAtributes(seq,SeqParamsUpdated)
%%
SeqParams.OutputFileMat = [SaveDir, 'gre_3d_',num2str(res),'mm_R',num2str(prod(SeqParams.RyRzCaipi(1:2))),'.mat']
load (SeqParams.OutputFileMat);
% mc_order = reshape(SeqParamsEff.navcount,[max(SeqParamsEff.navcount) , length(SeqParamsEff.navcount)/(max(SeqParamsEff.navcount))]);
mc_order = reshape(SeqParamsEff.navcount,[ length(SeqParamsEff.navcount)/(max(SeqParamsEff.navcount)), max(SeqParamsEff.navcount) ]);
mc = mc_order(round(end/2),:);
Ny = SeqParamsEff.DimsNav(2);
Nz = SeqParamsEff.DimsNav(3);
nTE = length(SeqParamsEff.TEff)
Nav_n =zeros([Ny,Nz,nTE]);
Acq = 0;
iShotData = 0;
iShotNav = 0;
iReadOutNav = 0;
for iShot = 1:length(SeqParamsEff.labelData0_Nav1)
if SeqParamsEff.labelData0_Nav1(iShot) == 0
iShotData = iShotData + 1;
else
iShotNav = iShotNav + 1;
[PE1, PE2, TE] = ind2sub([Ny,Nz,nTE],find(KspaceOrderNavKyKzt==iShotNav));
for t = 1:nTE
Acq = Acq + 1;
iReadOutNav = iReadOutNav + 1;
Nav_n(PE1(t), PE2(t),t) = SeqParamsEff.navcount (iReadOutNav);
end
end
end
Nav_mask =zeros([Ny,Nz,10]);
k= 0;
for nav = mc(1:10)
k =k+1
for t = 1:nTE
Nav_mask(:,:,k)=Nav_mask(:,:,k)+ t*double((Nav_n(:,:,t)==nav));
end;
end
for k = 1:9
subplot(3,3,k)
imab(crop(Nav_mask(:,:,k),[9 9]*2))
title(['k - space mask MC nav ',num2str(k) ])
end;
colormap(gray)