Skip to content

Commit

Permalink
Update to v3.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
markmikkelsen committed Jun 7, 2022
1 parent 511c85c commit 287076a
Show file tree
Hide file tree
Showing 14 changed files with 1,031 additions and 288 deletions.
2 changes: 0 additions & 2 deletions AlignSubSpectra.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@
case 'GE'
if strcmpi(MRS_struct.p.seqorig,'Lythgoe')
subSpecInd = [3 2 4 1];
elseif strcmpi(MRS_struct.p.seqorig,'Noeske')
subSpecInd = [2 1 3 4];
else
subSpecInd = [3 2 1 4];
end
Expand Down
60 changes: 45 additions & 15 deletions CoRegStandAlone/CoRegStandAlone.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
% 1. Pre-initialise
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MRS_struct.version.Gannet = '3.2.1-rc';
MRS_struct.version.load = '220526';
MRS_struct.version.Gannet = '3.2.1';
MRS_struct.version.load = '220607';
MRS_struct.ii = 0;
if size(metabfile,2) == 1
metabfile = metabfile';
Expand All @@ -53,7 +53,8 @@
MRS_struct.p.HERMES = 0;

% Flags
MRS_struct.p.mat = 1; % Save results in *.mat output structure? (0 = NO, 1 = YES (default)).
MRS_struct.p.mat = 1; % Save results in *.mat file? (0 = NO, 1 = YES (default)).
MRS_struct.p.csv = 1; % Save results in *.csv file? (0 = NO, 1 = YES (default)).
MRS_struct.p.vox = {'vox1'}; % Name of the voxel
MRS_struct.p.target = {'GABAGlx'}; % Name of the target metabolite

Expand All @@ -69,37 +70,37 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for ii = 1:length(metabfile) % Loop over all files in the batch (from metabfile)

MRS_struct.ii = ii;

switch MRS_struct.p.vendor

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

case 'Siemens_twix'
MRS_struct = SiemensTwixRead(MRS_struct, metabfile{ii});

case 'Siemens_dicom'
MRS_struct = SiemensDICOMRead(MRS_struct, metabfile{ii});

case 'dicom'
MRS_struct = DICOMRead(MRS_struct, metabfile{ii});

case 'Siemens_rda'
MRS_struct = SiemensRead(MRS_struct, metabfile{ii}, metabfile{ii});

case 'Philips'
MRS_struct = PhilipsRead(MRS_struct, metabfile{ii});

case 'Philips_data'
MRS_struct = PhilipsRead_data(MRS_struct, metabfile{ii});

case 'Philips_raw'
MRS_struct = PhilipsRawLoad(MRS_struct, metabfile{ii}, 3, 0);

end

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand All @@ -124,6 +125,35 @@
save(fullfile(pwd, 'MRS_struct_CoRegStandAlone.mat'), 'MRS_struct', '-v7.3');
end

% Export MRS_struct fields into csv file
if MRS_struct.p.csv
csv_name = fullfile(pwd, 'MRS_struct.csv');
if exist(csv_name, 'file')
fprintf('\nUpdating results in %s\n\n', 'MRS_struct.csv...');
else
fprintf('\nExporting results to %s\n\n', 'MRS_struct.csv...');
end

if strcmp(MRS_struct.p.vendor, 'Siemens_rda')
filename = MRS_struct.metabfile(:,1:2:end)';
else
filename = MRS_struct.metabfile';
end
for ii = 1:length(filename)
[~,b,c] = fileparts(filename{ii});
out.filename(ii,1) = cellstr([b c]);
end

out.fGM = MRS_struct.out.vox1.tissue.fGM(:);
out.fWM = MRS_struct.out.vox1.tissue.fWM(:);
out.fCSF = MRS_struct.out.vox1.tissue.fCSF(:);

round2 = @(x) round(x*1e3)/1e3;
T = table(out.filename, round2(out.fGM), round2(out.fWM), round2(out.fCSF), ...
'VariableNames', {'Filename', 'fGM', 'fWM', 'fCSF'});
writetable(T, csv_name);
end

end


Expand Down
12 changes: 6 additions & 6 deletions CoRegStandAlone/Seg.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
% This is useful if only the tissue segmentation information is supposed to
% be obtained.

MRS_struct.version.segment = '210331';
MRS_struct.version.segment = '220607';
vox = MRS_struct.p.vox(1);

warning('off'); % temporarily suppress warning messages
Expand Down Expand Up @@ -94,18 +94,18 @@
airvol_thresh = airvol_tmp .* T1_tmp;
airvol_thresh = airvol_thresh(:);

MRS_struct.out.tissue.CV_WM(ii) = std(WMvol_thresh, 'omitnan') / mean(WMvol_thresh, 'omitnan');
MRS_struct.out.tissue.CV_GM(ii) = std(GMvol_thresh, 'omitnan') / mean(GMvol_thresh, 'omitnan');
MRS_struct.out.tissue.CJV(ii) = (std(WMvol_thresh, 'omitnan') + std(GMvol_thresh, 'omitnan')) ...
MRS_struct.out.QA.CV_WM(ii) = std(WMvol_thresh, 'omitnan') / mean(WMvol_thresh, 'omitnan');
MRS_struct.out.QA.CV_GM(ii) = std(GMvol_thresh, 'omitnan') / mean(GMvol_thresh, 'omitnan');
MRS_struct.out.QA.CJV(ii) = (std(WMvol_thresh, 'omitnan') + std(GMvol_thresh, 'omitnan')) ...
/ abs(mean(WMvol_thresh, 'omitnan') - mean(GMvol_thresh, 'omitnan'));
MRS_struct.out.tissue.CNR(ii) = abs(mean(WMvol_thresh, 'omitnan') - mean(GMvol_thresh, 'omitnan')) / ...
MRS_struct.out.QA.CNR(ii) = abs(mean(WMvol_thresh, 'omitnan') - mean(GMvol_thresh, 'omitnan')) / ...
sqrt(var(airvol_thresh, 'omitnan') + var(WMvol_thresh, 'omitnan') + var(GMvol_thresh, 'omitnan'));

T1_tmp = T1_tmp(:);
n_vox = numel(T1_tmp);
efc_max = n_vox * (1/sqrt(n_vox)) * log(1/sqrt(n_vox));
b_max = sqrt(sum(T1_tmp.^2));
MRS_struct.out.tissue.EFC(ii) = (1/efc_max) .* sum((T1_tmp ./ b_max) .* log((T1_tmp + eps) ./ b_max));
MRS_struct.out.QA.EFC(ii) = (1/efc_max) .* sum((T1_tmp ./ b_max) .* log((T1_tmp + eps) ./ b_max));

% Loop over voxels if PRIAM
for kk = 1:length(vox)
Expand Down
4 changes: 2 additions & 2 deletions GannetLoad.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
% 6. Build GannetLoad output
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MRS_struct.version.Gannet = '3.2.1-rc';
MRS_struct.version.load = '220526';
MRS_struct.version.Gannet = '3.2.1';
MRS_struct.version.load = '220607';
VersionCheck(0, MRS_struct.version.Gannet);
ToolboxCheck;

Expand Down
6 changes: 3 additions & 3 deletions GannetPreInitialise.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
% and MEGA-PRESS: {'GABA'}, {'Glx'}, {'GSH'}, {'Lac'}, or {'EtOH'}
% and HERMES: {'GABA','GSH'}, {'Glx','GSH'}, {'Lac','GSH'}, or {'EtOH','GABA','GSH'}
MRS_struct.p.seqorig = 'JHU'; % Origin of Philips MEGA-PRESS or GE HERMES sequences;
% options are 'JHU' or 'Philips' if Philips, or 'Lythgoe' or 'Noeske' if GE (HERMES only)
% options are 'JHU' or 'Philips' if Philips, or 'Lythgoe' if GE (HERMES only)

% Analysis parameters
MRS_struct.p.LB = 3; % Exponential line-broadening (in Hz)
Expand All @@ -38,9 +38,9 @@
MRS_struct.p.mat = 0; % Save MRS_struct as a .mat file
MRS_struct.p.csv = 0; % Extract useful data from MRS_struct and export them to a .csv file (applies to GannetFit,
% GannetSegment and GannetQuantify)
MRS_struct.p.append = 1; % Append PDF outputs into one PDF (separately for each module) (requires export_fig in the Gannet
MRS_struct.p.append = 0; % Append PDF outputs into one PDF (separately for each module) (requires export_fig in the Gannet
% folder to be added to the search path and GhostScript to be installed)
MRS_struct.p.hide = 0; % Do not dynamically display output figures
MRS_struct.p.hide = 0; % Do not display output figures

end

Expand Down
12 changes: 6 additions & 6 deletions GannetSegment.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
% for the GM, WM and CSF segmentations. If these files are present, they
% are loaded and used for the voxel segmentation

MRS_struct.version.segment = '210331';
MRS_struct.version.segment = '220607';

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

Expand Down Expand Up @@ -110,18 +110,18 @@
airvol_thresh = airvol_tmp .* T1_tmp;
airvol_thresh = airvol_thresh(:);

MRS_struct.out.tissue.CV_WM(ii) = std(WMvol_thresh, 'omitnan') / mean(WMvol_thresh, 'omitnan');
MRS_struct.out.tissue.CV_GM(ii) = std(GMvol_thresh, 'omitnan') / mean(GMvol_thresh, 'omitnan');
MRS_struct.out.tissue.CJV(ii) = (std(WMvol_thresh, 'omitnan') + std(GMvol_thresh, 'omitnan')) ...
MRS_struct.out.QA.CV_WM(ii) = std(WMvol_thresh, 'omitnan') / mean(WMvol_thresh, 'omitnan');
MRS_struct.out.QA.CV_GM(ii) = std(GMvol_thresh, 'omitnan') / mean(GMvol_thresh, 'omitnan');
MRS_struct.out.QA.CJV(ii) = (std(WMvol_thresh, 'omitnan') + std(GMvol_thresh, 'omitnan')) ...
/ abs(mean(WMvol_thresh, 'omitnan') - mean(GMvol_thresh, 'omitnan'));
MRS_struct.out.tissue.CNR(ii) = abs(mean(WMvol_thresh, 'omitnan') - mean(GMvol_thresh, 'omitnan')) / ...
MRS_struct.out.QA.CNR(ii) = abs(mean(WMvol_thresh, 'omitnan') - mean(GMvol_thresh, 'omitnan')) / ...
sqrt(var(airvol_thresh, 'omitnan') + var(WMvol_thresh, 'omitnan') + var(GMvol_thresh, 'omitnan'));

T1_tmp = T1_tmp(:);
n_vox = numel(T1_tmp);
efc_max = n_vox * (1/sqrt(n_vox)) * log(1/sqrt(n_vox));
b_max = sqrt(sum(T1_tmp.^2));
MRS_struct.out.tissue.EFC(ii) = (1/efc_max) .* sum((T1_tmp ./ b_max) .* log((T1_tmp + eps) ./ b_max));
MRS_struct.out.QA.EFC(ii) = (1/efc_max) .* sum((T1_tmp ./ b_max) .* log((T1_tmp + eps) ./ b_max));

% Voxel mask
voxmaskvol = spm_vol(MRS_struct.mask.(vox{kk}).outfile{ii});
Expand Down
Loading

0 comments on commit 287076a

Please sign in to comment.