Skip to content

Commit b2a13e4

Browse files
committed
Update to v3.3.0
- New function GannetMask_NIfTI.m for voxel co-registration of NIfTI-MRS data - The Gannet logo has been reverted to the original image of a gannet - Added support for Siemens XA30 sequence as provided by JHU - Updated NIfTIMRSRead.m to load Philips data correctly - Turned off warnings of iteration limits in `GannetFit.m` - Updated mapVBVD functions to latest version (https://github.com/pehses/mapVBVD) - More cosmetic changes
1 parent 1ba4049 commit b2a13e4

26 files changed

+1675
-1607
lines changed

AlignSubSpectra.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
else
7171
subSpecInd = [3 2 1 4];
7272
end
73-
case 'nifti'
73+
case 'NIfTI'
7474
subSpecInd = [3 2 1 4];
7575
case {'Philips','Philips_data','Philips_raw'}
7676
subSpecInd = [1 2 3 4];
@@ -89,7 +89,7 @@
8989
end
9090
else
9191
switch MRS_struct.p.vendor
92-
case {'GE','nifti'}
92+
case {'GE','NIfTI'}
9393
subSpecInd = [3 2 1 4];
9494
case {'Philips','Philips_data','Philips_raw'}
9595
subSpecInd = [1 4 3 2];

CoRegStandAlone/CoReg.m

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@
4040

4141
%Ultimately this switch will not be necessary...
4242
switch MRS_struct.p.vendor
43+
44+
case 'GE'
45+
[~,~,ext] = fileparts(struc{ii});
46+
if strcmp(ext,'.nii')
47+
MRS_struct = GannetMask_GE_nii(MRS_struct.metabfile{ii}, struc{ii}, MRS_struct, ii, vox, kk);
48+
else
49+
MRS_struct = GannetMask_GE(MRS_struct.metabfile{ii}, struc{ii}, MRS_struct, ii, vox, kk);
50+
end
51+
52+
case 'NIfTI'
53+
MRS_struct = GannetMask_NIfTI(MRS_struct.metabfile{ii}, struc{ii}, MRS_struct, ii, vox, kk);
4354

4455
case 'Philips'
4556
sparname = [MRS_struct.metabfile{ii}(1:(end-4)) MRS_struct.p.spar_string];
@@ -73,20 +84,9 @@
7384
case 'Siemens_rda'
7485
MRS_struct = GannetMask_SiemensRDA(MRS_struct.metabfile{ii}, struc{ii}, MRS_struct, ii, vox, kk);
7586

76-
case {'Siemens_twix', 'Siemens_dicom', 'dicom'}
87+
case {'Siemens_twix', 'Siemens_dicom', 'DICOM'}
7788
MRS_struct = GannetMask_SiemensTWIX(MRS_struct.metabfile{ii}, struc{ii}, MRS_struct, ii, vox, kk);
7889

79-
case 'GE'
80-
[~,~,ext] = fileparts(struc{ii});
81-
if strcmp(ext,'.nii')
82-
MRS_struct = GannetMask_GE_nii(MRS_struct.metabfile{ii}, struc{ii}, MRS_struct, ii, vox, kk);
83-
else
84-
MRS_struct = GannetMask_GE(MRS_struct.metabfile{ii}, struc{ii}, MRS_struct, ii, vox, kk);
85-
end
86-
87-
case 'nifti'
88-
error('NIfTI not yet supported.');
89-
9090
end
9191

9292
% Build output figure
@@ -164,16 +164,16 @@
164164
imagesc(squeeze(MRS_struct.mask.(vox{kk}).img{ii}));
165165
colormap('gray');
166166
img = MRS_struct.mask.(vox{kk}).img{ii}(:);
167-
caxis([0 mean(img(img > 0.01)) + 3*std(img(img > 0.01))]);
167+
caxis([0 mean(img(img > 0.01)) + 3*std(img(img > 0.01))]); %#ok<*CAXIS>
168168
axis equal tight off;
169169
text(10, size(MRS_struct.mask.(vox{kk}).img{ii},1)/2, 'L', 'Color', [1 1 1], 'FontSize', 20);
170170
text(size(MRS_struct.mask.(vox{kk}).img{ii},2) - 20, size(MRS_struct.mask.(vox{kk}).img{ii},1)/2, 'R', 'Color', [1 1 1], 'FontSize', 20);
171171
set(ha,'pos',[0 0.15 1 1]);
172172
title(t, 'FontName', 'Arial', 'FontSize', 15, 'Interpreter', 'none');
173173

174174
% Gannet logo
175-
Gannet_logo = fullfile(fileparts(which('GannetLoad')), 'Gannet3_logo.png');
176-
I = imread(Gannet_logo,'png','BackgroundColor',[1 1 1]);
175+
Gannet_logo = fullfile(fileparts(which('GannetLoad')), 'Gannet3_logo.jpg');
176+
I = imread(Gannet_logo);
177177
axes('Position', [0.825, 0.05, 0.125, 0.125]);
178178
imshow(I);
179179
text(0.9, 0, MRS_struct.version.Gannet, 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 14, 'FontWeight', 'bold', 'HorizontalAlignment', 'left');

CoRegStandAlone/CoRegStandAlone.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@
9191

9292
switch MRS_struct.p.vendor
9393

94-
case 'dicom'
94+
case 'DICOM'
9595
MRS_struct = DICOMRead(MRS_struct, metabfile{ii});
9696

9797
case 'GE'
9898
MRS_struct = GERead(MRS_struct, metabfile{ii});
9999

100-
case 'nifti'
100+
case 'NIfTI'
101101
MRS_struct = NIfTIMRSRead(MRS_struct, metabfile{ii});
102102

103103
case 'Philips'

CoRegStandAlone/Seg.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@
248248
title(t, 'FontName', 'Arial', 'FontSize', 15, 'Interpreter', 'none');
249249

250250
% Gannet logo
251-
Gannet_logo = fullfile(fileparts(which('GannetLoad')), 'Gannet3_logo.png');
252-
I = imread(Gannet_logo,'png','BackgroundColor',[1 1 1]);
251+
Gannet_logo = fullfile(fileparts(which('GannetLoad')), 'Gannet3_logo.jpg');
252+
I = imread(Gannet_logo);
253253
axes('Position', [0.825, 0.05, 0.125, 0.125]);
254254
imshow(I);
255255
text(0.9, 0, MRS_struct.version.Gannet, 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 14, 'FontWeight', 'bold', 'HorizontalAlignment', 'left');

DiscernDataType.m

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@
55
switch lower(ext)
66
case '.7'
77
MRS_struct.p.vendor = 'GE';
8+
case '.dat'
9+
MRS_struct.p.vendor = 'Siemens_twix';
10+
case '.data'
11+
MRS_struct.p.vendor = 'Philips_data';
12+
case '.dcm'
13+
MRS_struct.p.vendor = 'DICOM';
14+
case {'.gz','.nii'}
15+
MRS_struct.p.vendor = 'NIfTI';
16+
case '.ima'
17+
MRS_struct.p.vendor = 'Siemens_dicom';
18+
case '.raw'
19+
MRS_struct.p.vendor = 'Philips_raw';
20+
case '.rda'
21+
MRS_struct.p.vendor = 'Siemens_rda';
822
case '.sdat'
923
MRS_struct.p.vendor = 'Philips';
1024
if all(isstrprop(ext(end-3:end), 'upper'))
1125
MRS_struct.p.spar_string = 'SPAR';
1226
else
1327
MRS_struct.p.spar_string = 'spar';
1428
end
15-
case '.data'
16-
MRS_struct.p.vendor = 'Philips_data';
17-
case '.raw'
18-
MRS_struct.p.vendor = 'Philips_raw';
19-
case '.rda'
20-
MRS_struct.p.vendor = 'Siemens_rda';
21-
case '.dat'
22-
MRS_struct.p.vendor = 'Siemens_twix';
23-
case '.ima'
24-
MRS_struct.p.vendor = 'Siemens_dicom';
25-
case '.dcm'
26-
MRS_struct.p.vendor = 'dicom';
27-
case {'.gz','.nii'}
28-
MRS_struct.p.vendor = 'nifti';
2929
otherwise
30-
error('Unrecognized file type! Extension should be .7, .sdat, .data, .raw, .rda, .dat, .ima, .dcm, .gz, or .nii.');
30+
error('Unrecognized file type! Extension should be .7, .dat, .data, .dcm, .gz, .ima, .nii, .raw, .rda, or, .sdat.');
3131
end
3232

3333
end

ExportToCSV.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function ExportToCSV(MRS_struct, vox, module)
99
end
1010
out.MATLAB_ver = cellstr(repmat(version('-release'), n_rep));
1111
out.Gannet_ver = cellstr(repmat(MRS_struct.version.Gannet, n_rep));
12-
out.date_of_analysis = cellstr(repmat(datestr(date, 'yyyy-mm-dd'), n_rep));
12+
out.date_of_analysis = cellstr(repmat(datestr(date, 'yyyy-mm-dd'), n_rep)); %#ok<*DATE,*DATST>
1313

1414

1515
%%% 1. Extract data from GannetFit %%%

GERead.m

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@
215215

216216
MRS_struct.p.LarmorFreq(ii) = i_hdr_value(rdb_hdr_ps_mps_freq)/1e7;
217217
MRS_struct.p.sw(ii) = f_hdr_value(rdb_hdr_user0);
218-
219218
nechoes = hdr_value(rdb_hdr_nechoes);
220219
MRS_struct.p.GE.nechoes(ii) = nechoes;
221220
nex = hdr_value(rdb_hdr_navs);
@@ -286,12 +285,12 @@
286285
if nechoes == 1
287286

288287
if (dataframes + refframes) ~= nframes
289-
mult = 1;
288+
mult = 1;
290289
MRS_struct.p.GE.noadd(ii) = 1;
291-
dataframes = dataframes * nex;
292-
refframes = nframes - dataframes;
290+
dataframes = dataframes * nex;
291+
refframes = nframes - dataframes;
293292
else
294-
mult = 1/nex;
293+
mult = 1/nex;
295294
MRS_struct.p.GE.noadd(ii) = 0;
296295
end
297296

@@ -301,29 +300,23 @@
301300

302301
totalframes = totalframes - (refframes + 1);
303302

304-
MRS_struct.p.nrows(ii) = totalframes;
305-
MRS_struct.p.Navg(ii) = dataframes * nex;
303+
MRS_struct.p.nrows(ii) = totalframes;
304+
MRS_struct.p.Navg(ii) = dataframes * nex;
306305
MRS_struct.p.Nwateravg(ii) = refframes * nex;
307306

308307
else
309308

310309
MRS_struct.p.Navg(ii) = dataframes * nex * nechoes; % RTN 2017
311310

312311
if (dataframes + refframes) ~= nframes
313-
mult = nex/2; % RTN 2016
314-
multw = nex; % RTN 2016
315-
%mult = 1; % RTN 2017
316-
%multw = 1; % RTN 2017
312+
mult = nex/2; % RTN 2016 1; % RTN 2017
313+
multw = nex; % RTN 2016 1; % RTN 2017
317314
MRS_struct.p.GE.noadd(ii) = 1;
318-
dataframes = dataframes * nex;
319-
refframes = nframes - dataframes;
315+
dataframes = dataframes * nex;
316+
refframes = nframes - dataframes;
320317
else
321-
%mult = nex/2; % RTN 2016
322-
%multw = 1; % RTN 2016
323-
%mult = 1; % RTN 2017
324-
%multw = 1/nex; % RTN 2017
325-
mult = 1/nex; % MM 2020
326-
multw = 1; % MM 2020
318+
mult = 1/nex; % MM 2020 1; % RTN 2017 nex/2; % RTN 2016
319+
multw = 1; % MM 2020 1/nex; % RTN 2017 1; % RTN 2016
327320
MRS_struct.p.GE.noadd(ii) = 0;
328321
end
329322

@@ -351,7 +344,7 @@
351344
Y2 = 1 + refframes + (totalframes/nechoes) * (X2-1) + X1;
352345
MetabData = Y1 .* ShapeData(:,:,Y2,:) * mult;
353346

354-
totalframes = totalframes - (refframes + 1) * nechoes; % RTN 2017
347+
totalframes = totalframes - (refframes + 1) * nechoes; % RTN 2017
355348
MRS_struct.p.nrows(ii) = totalframes;
356349

357350
end
@@ -361,7 +354,11 @@
361354
WaterData = squeeze(complex(WaterData(1,:,:,:), WaterData(2,:,:,:)));
362355
WaterData = permute(WaterData, [3 1 2]);
363356

364-
% Generalized least squares method (An et al., JMRI, 2013, doi:10.1002/jmri.23941)
357+
% Combine coils using generalized least squares method (An et al., JMRI,
358+
% 2013, doi:10.1002/jmri.23941); the noise covariance matrix is more
359+
% optionally estimated by using all averages as suggested by Rodgers &
360+
% Robson (MRM, 2010, doi:10.1002/mrm.22230)
361+
365362
[nCh, nPts, nReps] = size(WaterData);
366363
noise_pts = false(1,nPts);
367364
noise_pts(ceil(0.75*nPts):end) = true;

Gannet3_logo.jpg

41.9 KB
Loading

Gannet3_logo.png

-31.3 KB
Binary file not shown.

GannetCoRegister.m

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
error('MATLAB:minrhs','Not enough input arguments.');
77
end
88

9-
MRS_struct.version.coreg = '220923';
9+
MRS_struct.version.coreg = '221021';
1010

1111
warning('off'); % temporarily suppress warning messages
1212

@@ -36,7 +36,7 @@
3636
run_count = 0;
3737

3838
for ii = 1:MRS_struct.p.numScans
39-
39+
4040
[~,b,c] = fileparts(MRS_struct.metabfile{1,ii});
4141
[~,e,f] = fileparts(struc{ii});
4242
if strcmpi(f, '.gz')
@@ -52,25 +52,24 @@
5252

5353
% Loop over voxels if PRIAM
5454
for kk = 1:length(vox)
55-
55+
5656
switch MRS_struct.p.vendor
5757

58-
case 'GE'
58+
case 'GE'
5959
[~,~,ext] = fileparts(struc{ii});
6060
if strcmp(ext,'.nii')
6161
MRS_struct = GannetMask_GE_nii(fname, struc{ii}, MRS_struct, ii, vox, kk);
6262
else
6363
MRS_struct = GannetMask_GE(fname, struc{ii}, MRS_struct, ii, vox, kk);
6464
end
6565

66-
case 'nifti'
67-
error('NIfTI not yet supported.');
68-
% MRS_struct = GannetMask_NIfTI(fname, struc{ii}, MRS_struct, ii, vox, kk);
66+
case 'NIfTI'
67+
MRS_struct = GannetMask_NIfTI(fname, struc{ii}, MRS_struct, ii, vox, kk);
6968

7069
case 'Philips'
7170
sparname = [MRS_struct.metabfile{1,ii}(1:(end-4)) MRS_struct.p.spar_string];
7271
MRS_struct = GannetMask_Philips(sparname, struc{ii}, MRS_struct, ii, vox, kk);
73-
72+
7473
case 'Philips_data'
7574
if exist(MRS_struct.metabfile_sdat,'file')
7675
MRS_struct.p.vendor = 'Philips';
@@ -100,7 +99,7 @@
10099
fname = MRS_struct.metabfile{1,ii*2-1};
101100
MRS_struct = GannetMask_SiemensRDA(fname, struc{ii}, MRS_struct, ii, vox, kk);
102101

103-
case {'Siemens_dicom', 'Siemens_twix', 'dicom'}
102+
case {'Siemens_dicom', 'Siemens_twix', 'DICOM'}
104103
MRS_struct = GannetMask_SiemensTWIX(fname, struc{ii}, MRS_struct, ii, vox, kk);
105104

106105
end
@@ -122,46 +121,46 @@
122121
set(h,'Color',[1 1 1]);
123122
figTitle = 'GannetCoRegister Output';
124123
set(h,'Name',figTitle,'Tag',figTitle,'NumberTitle','off');
125-
124+
126125
subplot(2,3,4:6);
127126
axis off;
128-
127+
129128
[~,tmp,tmp2] = fileparts(MRS_struct.mask.(vox{kk}).outfile{ii});
130129
fname = [tmp tmp2];
131130
if length(fname) > 30
132131
fname = [fname(1:12) '...' fname(end-11:end)];
133132
end
134133
text(0.5, 0.75, 'Mask output: ', 'HorizontalAlignment' , 'right', 'FontName', 'Arial', 'FontSize', 13);
135134
text(0.5, 0.75, [' ' fname], 'FontName', 'Arial', 'FontSize', 13, 'Interpreter', 'none');
136-
135+
137136
text(0.5, 0.63, 'Spatial parameters: ', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
138137
text(0.5, 0.63, ' [LR, AP, FH]', 'FontName', 'Arial', 'FontSize', 13);
139-
138+
140139
tmp = [' ' num2str(MRS_struct.p.voxdim(ii,1)) ' \times ' num2str(MRS_struct.p.voxdim(ii,2)) ' \times ' num2str(MRS_struct.p.voxdim(ii,3)) ' mm^{3}'];
141140
text(0.5, 0.51, 'Dimensions: ', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
142141
text(0.5, 0.51, tmp, 'FontName', 'Arial', 'FontSize', 13, 'Interpreter', 'tex');
143-
142+
144143
tmp = [' ' num2str(prod(MRS_struct.p.voxdim(ii,:))/1e3) ' mL'];
145144
text(0.5, 0.39, 'Volume: ', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
146145
text(0.5, 0.39, tmp, 'FontName', 'Arial', 'FontSize', 13);
147-
146+
148147
tmp = [' [' num2str(MRS_struct.p.voxoff(ii,1), '%3.1f') ', ' num2str(MRS_struct.p.voxoff(ii,2), '%3.1f') ', ' num2str(MRS_struct.p.voxoff(ii,3), '%3.1f') '] mm'];
149148
text(0.5, 0.27, 'Position: ', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
150149
text(0.5, 0.27, tmp, 'FontName', 'Arial', 'FontSize', 13);
151-
150+
152151
if any(strcmp(MRS_struct.p.vendor,{'Philips','Philips_data'}))
153152
tmp = [' [' num2str(MRS_struct.p.voxang(ii,2), '%3.1f') ', ' num2str(MRS_struct.p.voxang(ii,1), '%3.1f') ', ' num2str(MRS_struct.p.voxang(ii,3), '%3.1f') '] deg'];
154153
else
155154
tmp = [' [' num2str(MRS_struct.p.voxang(ii,1), '%3.1f') ', ' num2str(MRS_struct.p.voxang(ii,2), '%3.1f') ', ' num2str(MRS_struct.p.voxang(ii,3), '%3.1f') '] deg'];
156155
end
157156
text(0.5, 0.15, 'Angulation: ', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
158157
text(0.5, 0.15, tmp, 'FontName', 'Arial', 'FontSize', 13);
159-
158+
160159
text(0.5, 0.03, 'CoRegVer: ', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
161160
text(0.5, 0.03, [' ' MRS_struct.version.coreg], 'FontName', 'Arial', 'FontSize', 13);
162-
161+
163162
ha = subplot(2,3,1:3);
164-
163+
165164
if strcmp(MRS_struct.p.vendor,'Siemens_rda')
166165
[~,tmp,tmp2] = fileparts(MRS_struct.metabfile{1,ii*2-1});
167166
else
@@ -177,19 +176,19 @@
177176
T1image = [T1image(1:12) '...' T1image(end-11:end)];
178177
end
179178
t = ['Voxel from ' fname ' on ' T1image];
180-
179+
181180
imagesc(MRS_struct.mask.(vox{kk}).img{ii});
182181
axis equal tight off;
183182
text(10, size(MRS_struct.mask.(vox{kk}).img{ii},1)/2, 'L', 'Color', [1 1 1], 'FontSize', 20);
184183
text(size(MRS_struct.mask.(vox{kk}).img{ii},2) - 20, size(MRS_struct.mask.(vox{kk}).img{ii},1)/2, 'R', 'Color', [1 1 1], 'FontSize', 20);
185184
set(ha,'pos',[0 0.15 1 1]);
186185
title(t, 'FontName', 'Arial', 'FontSize', 15, 'Interpreter', 'none');
187-
186+
188187
% Save output as PDF
189188
run_count = SavePDF(h, MRS_struct, ii, 1, kk, vox, mfilename, run_count);
190189

191190
end
192-
191+
193192
end
194193

195194
% Save MRS_struct as mat file

0 commit comments

Comments
 (0)