Skip to content

Commit e6e103e

Browse files
Merge pull request #38 from markmikkelsen/dev
Update to v3.4.0
2 parents 4594a4c + 189e586 commit e6e103e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+903
-537
lines changed

AlignSubSpectra.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@
6262
if MRS_struct.p.HERMES
6363
if ~MRS_struct.p.HERCULES
6464
if length(MRS_struct.p.target) == 2 && (all(strcmp(MRS_struct.p.target, {'GABAGlx', 'GSH'})) ...
65-
|| all(strcmp(MRS_struct.p.target, {'GABA', 'GSH'})))
65+
|| all(strcmp(MRS_struct.p.target, {'GABA', 'GSH'})) ...
66+
|| all(strcmp(MRS_struct.p.target, {'Lac', 'GSH'})))
6667
switch MRS_struct.p.vendor
6768
case 'GE'
6869
if strcmp(MRS_struct.p.seqorig, 'Lythgoe')

AlignUsingPeak.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
cub = find(min(z) == z);
6868
freqrange = MRS_struct.spec.freq(clb:cub);
6969
CrMeanSpec = mean(AllFramesFTrealign(clb:cub,:),2);
70-
CrMeanSpecFit = FitCr(freqrange, CrMeanSpec, Init, MRS_struct.p.LarmorFreq);
70+
CrMeanSpecFit = FitCr(freqrange, CrMeanSpec, Init, MRS_struct.p.LarmorFreq(MRS_struct.ii));
7171
MRS_struct.out.CrFWHMHz(MRS_struct.ii) = CrMeanSpecFit(2);
7272

7373
% Reject any point where the fit params - area, fwhm, phase

CalcIU.m

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@
2727
T1_Metab = 1.31; % Puts et al. 2013 (JMRI)
2828
T2_Metab = 0.088; % Edden et al. 2012 (JMRI)
2929
N_H_Metab = 2;
30-
MM = 0.45; % MM correction: fraction of GABA in GABA+ peak. (In TrypDep, 30 subjects: 55% of GABA+ was MM)
31-
% This fraction is platform- and implementation-dependent, based on length and
32-
% shape of editing pulses and ifis Henry method
30+
MM = 0.45; % MM correction: fraction of GABA in GABA+ peak. (In TrypDep, 30 subjects: 55% of GABA+ was MM)
31+
% This fraction is platform- and implementation-dependent, based on length and
32+
% shape of editing pulses and ifis Henry method
3333

3434
case 'Glx'
3535
EditingEfficiency = 0.4; % determined by FID-A simulations (for TE = 68 ms)
3636
T1_Metab = 1.23; % Posse et al. 2007 (MRM)
3737
T2_Metab = 0.18; % Ganji et al. 2012 (NMR Biomed)
3838
N_H_Metab = 1;
39-
MM = 1;
39+
MM = 1;
4040

4141
case 'GSH'
4242
EditingEfficiency = 0.74; % At 3T based on Quantification of Glutathione in the Human Brain by MR Spectroscopy at 3 Tesla:
@@ -49,42 +49,49 @@
4949
% T2 relaxation times of 18 brain metabolites determined in 83 healthy volunteers in vivo
5050
% Milan Scheidegger et al. Proc. Intl. Soc. Mag. Reson. Med. 22 (2014)
5151
N_H_Metab = 2;
52-
MM = 1;
52+
MM = 1;
5353

5454
case 'Lac'
5555
EditingEfficiency = 0.94; % determined by FID-A simulations (for TE = 140 ms)
5656
T1_Metab = 1.50; % Wijnen et al. 2015 (NMR Biomed)
5757
T2_Metab = 0.24; % Madan et al. 2015 (MRM) (NB: this was estimated in brain tumors)
5858
N_H_Metab = 3;
59-
MM = 1;
59+
MM = 1;
6060

6161
case 'EtOH'
6262
EditingEfficiency = 0.5; % assuming same as GABA for now
6363
T1_Metab = 1.31; % assuming same as GABA
6464
T2_Metab = 0.088; % assuming same as GABA
6565
N_H_Metab = 3;
66-
MM = 1;
66+
MM = 1;
6767

6868
case 'Cr' % 3 ppm moiety
6969
EditingEfficiency = 1; % not edited, so 1
7070
T1_Metab = (1.46 + 1.24)/2; % Mlynárik et al. 2001 (NMR in Biomed)
7171
T2_Metab = (166 + 144 + 148)/3/1e3; % Wyss et al. 2018 (MRM)
7272
N_H_Metab = 3;
73-
MM = 1;
73+
MM = 1;
7474

7575
case 'Cho' % 3.2 ppm moiety
7676
EditingEfficiency = 1; % not edited, so 1
7777
T1_Metab = (1.30 + 1.08)/2; % Mlynárik et al. 2001 (NMR in Biomed)
7878
T2_Metab = (218 + 222 + 274)/3/1e3; % Wyss et al. 2018 (MRM)
7979
N_H_Metab = 9;
80-
MM = 1;
80+
MM = 1;
8181

8282
case 'NAA' % 2 ppm moiety
8383
EditingEfficiency = 1; % not edited, so 1
8484
T1_Metab = (1.47 + 1.35)/2; % Mlynárik et al. 2001 (NMR in Biomed)
8585
T2_Metab = (343 + 263 + 253)/3/1e3; % Wyss et al. 2018 (MRM)
8686
N_H_Metab = 3;
87-
MM = 1;
87+
MM = 1;
88+
89+
case 'Glu' % 2.34 ppm moiety
90+
EditingEfficiency = 0.4; % Saleh et al. 2024 (MRM)
91+
T1_Metab = 1.23; % Posse et al. 2007 (MRM)
92+
T2_Metab = 0.18; % Ganji et al. 2012 (NMR Biomed)
93+
N_H_Metab = 2;
94+
MM = 1;
8895
end
8996

9097
T1_Factor = (1 - exp(-TR_water./T1_Water)) ./ (1 - exp(-TR./T1_Metab));

CheckTargets.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ function CheckTargets(MRS_struct)
1212
error(msg);
1313
end
1414
if MRS_struct.p.HERMES
15-
msg = 'MRS_struct.p.HERMES is set to 1 in GannetPreInitialise.m. Add a second target metabolite or set flag to 0.';
16-
msg = hyperlink(['matlab: opentoline(''' filepath ''', 4, 0)'], 'Add a second target metabolite', msg);
17-
msg = hyperlink(['matlab: opentoline(''' filepath ''', 33, 0)'], 'set flag to 0', msg);
15+
msg = 'MRS_struct.p.HERMES is set to 1 in GannetPreInitialise.m. Add at least a second target metabolite or set the flag to 0.';
16+
msg = hyperlink(['matlab: opentoline(''' filepath ''', 4, 0)'], 'Add at least a second target metabolite', msg);
17+
msg = hyperlink(['matlab: opentoline(''' filepath ''', 39, 0)'], 'set the flag to 0', msg);
1818
fprintf('\n');
1919
error(msg);
2020
end
@@ -33,7 +33,7 @@ function CheckTargets(MRS_struct)
3333
end
3434
if ~MRS_struct.p.HERMES
3535
msg = 'Two target metabolites detected. MRS_struct.p.HERMES must be set to 1 in GannetPreInitialise.m.';
36-
msg = hyperlink(['matlab: opentoline(''' filepath ''', 33, 0)'], 'MRS_struct.p.HERMES must be set to 1', msg);
36+
msg = hyperlink(['matlab: opentoline(''' filepath ''', 39, 0)'], 'MRS_struct.p.HERMES must be set to 1', msg);
3737
fprintf('\n');
3838
error(msg);
3939
end
@@ -45,7 +45,7 @@ function CheckTargets(MRS_struct)
4545
if all(strcmp(MRS_struct.p.target, {'EtOH', 'GABA', 'GSH'}))
4646
if ~MRS_struct.p.HERMES
4747
msg = 'Three target metabolites detected. MRS_struct.p.HERMES must be set to 1 in GannetPreInitialise.m.';
48-
msg = hyperlink(['matlab: opentoline(''' filepath ''', 33, 0)'], 'MRS_struct.p.HERMES must be set to 1', msg);
48+
msg = hyperlink(['matlab: opentoline(''' filepath ''', 39, 0)'], 'MRS_struct.p.HERMES must be set to 1', msg);
4949
fprintf('\n');
5050
error(msg);
5151
end

CoRegStandAlone/CoReg.m

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
text(0.5, 0.75, [' ' fname], 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 13, 'Interpreter', 'none');
135135

136136
text(0.5, 0.63, 'Spatial parameters: ', 'Units', 'normalized', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
137-
text(0.5, 0.63, ' [LR, AP, FH]', 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 13);
137+
text(0.5, 0.63, ' [LR, PA, SI]', 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 13);
138138

139139
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}'];
140140
text(0.5, 0.51, 'Dimensions: ', 'Units', 'normalized', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
@@ -182,8 +182,12 @@
182182
img = MRS_struct.mask.(vox{kk}).img{ii}(:);
183183
caxis([0 mean(img(img > 0.01)) + 3*std(img(img > 0.01))]); %#ok<*CAXIS>
184184
axis equal tight off;
185-
text(10, size(MRS_struct.mask.(vox{kk}).img{ii},1)/2, 'L', 'Color', [1 1 1], 'FontSize', 20);
186-
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);
185+
text(0.01, 0.5, 'L', 'Color', [1 1 1], 'FontSize', 20, 'Units', 'normalized');
186+
text(0.16, 0.95, 'A', 'Color', [1 1 1], 'FontSize', 20, 'Units', 'normalized');
187+
text(0.32, 0.5, 'A', 'Color', [1 1 1], 'FontSize', 20, 'Units', 'normalized');
188+
text(0.5, 0.95, 'S', 'Color', [1 1 1], 'FontSize', 20, 'Units', 'normalized');
189+
text(0.825, 0.95, 'S', 'Color', [1 1 1], 'FontSize', 20, 'Units', 'normalized');
190+
text(0.975, 0.5, 'R', 'Color', [1 1 1], 'FontSize', 20, 'Units', 'normalized');
187191
set(hb, 'Position', [0 0.15 1 1]);
188192
title(t, 'FontName', 'Arial', 'FontSize', 15, 'Interpreter', 'none');
189193

@@ -224,8 +228,15 @@
224228
fullpath = regexprep(fullpath, '/', '_');
225229
end
226230

227-
[~,metabfile_nopath] = fileparts(MRS_struct.metabfile{ii});
228-
231+
if strcmp(MRS_struct.p.vendor, 'Siemens_rda')
232+
[~, metabfile_nopath] = fileparts(MRS_struct.metabfile{ii*2-1});
233+
else
234+
[~, metabfile_nopath, ext] = fileparts(MRS_struct.metabfile{ii});
235+
if strcmpi(ext, '.gz')
236+
metabfile_nopath(end-3:end) = [];
237+
end
238+
end
239+
229240
if any(strcmp(listfonts,'Arial'))
230241
set(findall(h,'-property','FontName'),'FontName','Arial');
231242
end

CoRegStandAlone/CoRegStandAlone.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
out = regexp(str, expression, 'names');
6666
MRS_struct.version.load = out.version;
6767

68-
MRS_struct.version.coregstandalone = '230729';
68+
MRS_struct.version.coregstandalone = '240504';
6969

7070
MRS_struct.ii = 0;
7171
if size(metabfile,2) == 1
@@ -74,6 +74,7 @@
7474
MRS_struct.metabfile = metabfile;
7575
MRS_struct.p.HERMES = 0;
7676
MRS_struct.p.numScans = length(metabfile);
77+
MRS_struct.p.seqorig = 'JHU';
7778

7879
% Flags
7980
MRS_struct.p.mat = 0; % Save results in *.mat file? (0 = NO, 1 = YES (default))

CoRegStandAlone/Seg.m

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@
5050

5151
% Check to see if segmentation has already been done (and all
5252
% probability tissue maps are present)
53-
tmp = {[T1dir '/c1' T1name T1ext]
54-
[T1dir '/c2' T1name T1ext]
55-
[T1dir '/c3' T1name T1ext]
56-
[T1dir '/c6' T1name T1ext]};
53+
tmp = {[T1dir filesep 'c1' T1name T1ext]
54+
[T1dir filesep 'c2' T1name T1ext]
55+
[T1dir filesep 'c3' T1name T1ext]
56+
[T1dir filesep 'c6' T1name T1ext]};
5757
filesExist = zeros(1,length(tmp));
5858
for jj = 1:length(tmp)
5959
filesExist(jj) = exist(tmp{jj}, 'file');
@@ -85,10 +85,10 @@
8585
T1dir = '.';
8686
end
8787

88-
GM = [T1dir '/c1' T1name T1ext];
89-
WM = [T1dir '/c2' T1name T1ext];
90-
CSF = [T1dir '/c3' T1name T1ext];
91-
air = [T1dir '/c6' T1name T1ext];
88+
GM = [T1dir filesep 'c1' T1name T1ext];
89+
WM = [T1dir filesep 'c2' T1name T1ext];
90+
CSF = [T1dir filesep 'c3' T1name T1ext];
91+
air = [T1dir filesep 'c6' T1name T1ext];
9292

9393
GMvol = spm_vol(GM);
9494
WMvol = spm_vol(WM);
@@ -300,10 +300,13 @@
300300
fullpath = regexprep(fullpath, '/', '_');
301301
end
302302

303-
if strcmp(MRS_struct.p.vendor,'Siemens_rda')
304-
[~,metabfile_nopath] = fileparts(MRS_struct.metabfile{ii*2-1});
303+
if strcmp(MRS_struct.p.vendor, 'Siemens_rda')
304+
[~, metabfile_nopath] = fileparts(MRS_struct.metabfile{ii*2-1});
305305
else
306-
[~,metabfile_nopath] = fileparts(MRS_struct.metabfile{ii});
306+
[~, metabfile_nopath, ext] = fileparts(MRS_struct.metabfile{ii});
307+
if strcmpi(ext, '.gz')
308+
metabfile_nopath(end-3:end) = [];
309+
end
307310
end
308311

309312
if any(strcmp(listfonts,'Arial'))

DICOMRead.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
MRS_struct.p.npoints(ii) = DicomHeader.vectorSize;
6464
MRS_struct.p.Navg(ii) = 2*DicomHeader.nAverages;
6565
MRS_struct.p.nrows(ii) = 2*DicomHeader.nAverages;
66-
MRS_struct.p.sw(ii) = 1/DicomHeader.dwellTime * 1E9 * 0.5; % check with oversampling? hence factor 0.5, need to figure out why <=> probably dataset with 512 points, oversampled is 1024
67-
MRS_struct.p.LarmorFreq(ii) = DicomHeader.tx_freq * 1E-6;
66+
MRS_struct.p.sw(ii) = 1/DicomHeader.dwellTime * 1e9 * 0.5; % check with oversampling? hence factor 0.5, need to figure out why <=> probably dataset with 512 points, oversampled is 1024
67+
MRS_struct.p.LarmorFreq(ii) = DicomHeader.tx_freq * 1e-6;
6868
MRS_struct.p.voxdim(ii,1) = DicomHeader.VoI_PeFOV;
6969
MRS_struct.p.voxdim(ii,2) = DicomHeader.VoI_RoFOV;
7070
MRS_struct.p.voxdim(ii,3) = DicomHeader.VoIThickness;

DeIdentifyDisclaimer.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function DeIdentifyDisclaimer
2+
% Display a disclaimer when a user runs any of the de-identification
3+
% functions
4+
5+
persistent lastDisclaimTime
6+
7+
if isempty(lastDisclaimTime) || (datetime('now') - lastDisclaimTime) > days(1)
8+
9+
fprintf(['\nDISCLAIMER: The Gannet developers provide NO GUARANTEE ' ...
10+
'that the de-identification\nfunctions will remove all ' ...
11+
'protected health information (PHI) and personally\nidentifiable ' ...
12+
'information (PII) from data files.\n\n']);
13+
14+
lastDisclaimTime = datetime('now');
15+
16+
end

ExportToCSV.m

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
function MRS_struct = ExportToCSV(MRS_struct, vox, module)
22

3-
round2 = @(x) round(x*1e3)/1e3;
4-
53
if strcmp(MRS_struct.p.vendor, 'Siemens_rda')
64
n_rep = [size(MRS_struct.metabfile,2)/2 1];
75
else
@@ -25,7 +23,7 @@
2523
end
2624
out.avg_delta_F0 = MRS_struct.out.AvgDeltaF0(:);
2725

28-
metabs = {'GABA','Glx','GSH','EtOH','Lac','water','Cr','Cho','NAA'};
26+
metabs = {'GABA','Glx','Glu','GSH','EtOH','Lac','water','Cr','Cho','NAA'};
2927

3028
for ii = 1:length(metabs)
3129
if ~isfield(MRS_struct.out.(vox), metabs{ii})
@@ -51,7 +49,7 @@
5149
end
5250
end
5351

54-
T = table(out.MATLAB_ver, out.Gannet_ver, out.date_of_analysis, out.filename, round2(out.avg_delta_F0), ...
52+
T = table(out.MATLAB_ver, out.Gannet_ver, out.date_of_analysis, out.filename, round(out.avg_delta_F0,4), ...
5553
'VariableNames', {'MATLAB_version', 'Gannet_version', 'date_of_analysis', 'filename', 'avg_delta_F0'});
5654

5755
field_names = fieldnames(out);
@@ -64,7 +62,7 @@
6462
U = table(out.(field_names{ii}).(sub_field_names{jj}), ...
6563
'VariableNames', {[field_names{ii} '_' sub_field_names{jj}]});
6664
else
67-
U = table(round2(out.(field_names{ii}).(sub_field_names{jj})), ...
65+
U = table(round(out.(field_names{ii}).(sub_field_names{jj}),3), ...
6866
'VariableNames', {[field_names{ii} '_' sub_field_names{jj}]});
6967
end
7068
T = [T U]; %#ok<*AGROW>
@@ -112,7 +110,7 @@
112110
out.tissue.fWM = MRS_struct.out.(vox).tissue.fWM(:);
113111
out.tissue.fCSF = MRS_struct.out.(vox).tissue.fCSF(:);
114112

115-
metabs = {'GABA','Glx','GSH','EtOH','Lac','Cr','Cho','NAA'};
113+
metabs = {'GABA','Glx','Glu','GSH','EtOH','Lac','Cr','Cho','NAA'};
116114

117115
if strcmp(MRS_struct.p.reference, 'H2O')
118116
for ii = 1:length(metabs)
@@ -130,13 +128,13 @@
130128
for ii = 1:length(field_names)
131129
if any(strcmp(field_names{ii}, metabs)) && strcmp(MRS_struct.p.reference, 'H2O')
132130
sub_field_names = fieldnames(out.(field_names{ii}));
133-
Y = table(round2(out.(field_names{ii}).(sub_field_names{end})), ...
131+
Y = table(round(out.(field_names{ii}).(sub_field_names{end}),3), ...
134132
'VariableNames', {[field_names{ii} '_' sub_field_names{end}]});
135133
X = [X Y];
136134
elseif strcmp(field_names{ii}, 'tissue')
137135
sub_field_names = fieldnames(out.(field_names{ii}));
138136
for jj = 1:3
139-
U = table(round2(out.(field_names{ii}).(sub_field_names{jj})), ...
137+
U = table(round(out.(field_names{ii}).(sub_field_names{jj}),3), ...
140138
'VariableNames', sub_field_names(jj));
141139
V = [V U];
142140
end
@@ -180,7 +178,7 @@
180178
if any(strcmp(field_names{ii}, metabs))
181179
sub_field_names = fieldnames(out.(field_names{ii}));
182180
for jj = length(sub_field_names)-3:length(sub_field_names)
183-
U = table(round2(out.(field_names{ii}).(sub_field_names{jj})), ...
181+
U = table(round(out.(field_names{ii}).(sub_field_names{jj}),3), ...
184182
'VariableNames', {[field_names{ii} '_' sub_field_names{jj}]});
185183
T = [T U];
186184
end

0 commit comments

Comments
 (0)