Skip to content

Commit

Permalink
Update to v3.3.0
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
markmikkelsen committed Oct 22, 2022
1 parent 1ba4049 commit b2a13e4
Show file tree
Hide file tree
Showing 26 changed files with 1,675 additions and 1,607 deletions.
4 changes: 2 additions & 2 deletions AlignSubSpectra.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
else
subSpecInd = [3 2 1 4];
end
case 'nifti'
case 'NIfTI'
subSpecInd = [3 2 1 4];
case {'Philips','Philips_data','Philips_raw'}
subSpecInd = [1 2 3 4];
Expand All @@ -89,7 +89,7 @@
end
else
switch MRS_struct.p.vendor
case {'GE','nifti'}
case {'GE','NIfTI'}
subSpecInd = [3 2 1 4];
case {'Philips','Philips_data','Philips_raw'}
subSpecInd = [1 4 3 2];
Expand Down
30 changes: 15 additions & 15 deletions CoRegStandAlone/CoReg.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@

%Ultimately this switch will not be necessary...
switch MRS_struct.p.vendor

case 'GE'
[~,~,ext] = fileparts(struc{ii});
if strcmp(ext,'.nii')
MRS_struct = GannetMask_GE_nii(MRS_struct.metabfile{ii}, struc{ii}, MRS_struct, ii, vox, kk);
else
MRS_struct = GannetMask_GE(MRS_struct.metabfile{ii}, struc{ii}, MRS_struct, ii, vox, kk);
end

case 'NIfTI'
MRS_struct = GannetMask_NIfTI(MRS_struct.metabfile{ii}, struc{ii}, MRS_struct, ii, vox, kk);

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

case {'Siemens_twix', 'Siemens_dicom', 'dicom'}
case {'Siemens_twix', 'Siemens_dicom', 'DICOM'}
MRS_struct = GannetMask_SiemensTWIX(MRS_struct.metabfile{ii}, struc{ii}, MRS_struct, ii, vox, kk);

case 'GE'
[~,~,ext] = fileparts(struc{ii});
if strcmp(ext,'.nii')
MRS_struct = GannetMask_GE_nii(MRS_struct.metabfile{ii}, struc{ii}, MRS_struct, ii, vox, kk);
else
MRS_struct = GannetMask_GE(MRS_struct.metabfile{ii}, struc{ii}, MRS_struct, ii, vox, kk);
end

case 'nifti'
error('NIfTI not yet supported.');

end

% Build output figure
Expand Down Expand Up @@ -164,16 +164,16 @@
imagesc(squeeze(MRS_struct.mask.(vox{kk}).img{ii}));
colormap('gray');
img = MRS_struct.mask.(vox{kk}).img{ii}(:);
caxis([0 mean(img(img > 0.01)) + 3*std(img(img > 0.01))]);
caxis([0 mean(img(img > 0.01)) + 3*std(img(img > 0.01))]); %#ok<*CAXIS>
axis equal tight off;
text(10, size(MRS_struct.mask.(vox{kk}).img{ii},1)/2, 'L', 'Color', [1 1 1], 'FontSize', 20);
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);
set(ha,'pos',[0 0.15 1 1]);
title(t, 'FontName', 'Arial', 'FontSize', 15, 'Interpreter', 'none');

% Gannet logo
Gannet_logo = fullfile(fileparts(which('GannetLoad')), 'Gannet3_logo.png');
I = imread(Gannet_logo,'png','BackgroundColor',[1 1 1]);
Gannet_logo = fullfile(fileparts(which('GannetLoad')), 'Gannet3_logo.jpg');
I = imread(Gannet_logo);
axes('Position', [0.825, 0.05, 0.125, 0.125]);
imshow(I);
text(0.9, 0, MRS_struct.version.Gannet, 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 14, 'FontWeight', 'bold', 'HorizontalAlignment', 'left');
Expand Down
4 changes: 2 additions & 2 deletions CoRegStandAlone/CoRegStandAlone.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@

switch MRS_struct.p.vendor

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

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

case 'nifti'
case 'NIfTI'
MRS_struct = NIfTIMRSRead(MRS_struct, metabfile{ii});

case 'Philips'
Expand Down
4 changes: 2 additions & 2 deletions CoRegStandAlone/Seg.m
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@
title(t, 'FontName', 'Arial', 'FontSize', 15, 'Interpreter', 'none');

% Gannet logo
Gannet_logo = fullfile(fileparts(which('GannetLoad')), 'Gannet3_logo.png');
I = imread(Gannet_logo,'png','BackgroundColor',[1 1 1]);
Gannet_logo = fullfile(fileparts(which('GannetLoad')), 'Gannet3_logo.jpg');
I = imread(Gannet_logo);
axes('Position', [0.825, 0.05, 0.125, 0.125]);
imshow(I);
text(0.9, 0, MRS_struct.version.Gannet, 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 14, 'FontWeight', 'bold', 'HorizontalAlignment', 'left');
Expand Down
30 changes: 15 additions & 15 deletions DiscernDataType.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@
switch lower(ext)
case '.7'
MRS_struct.p.vendor = 'GE';
case '.dat'
MRS_struct.p.vendor = 'Siemens_twix';
case '.data'
MRS_struct.p.vendor = 'Philips_data';
case '.dcm'
MRS_struct.p.vendor = 'DICOM';
case {'.gz','.nii'}
MRS_struct.p.vendor = 'NIfTI';
case '.ima'
MRS_struct.p.vendor = 'Siemens_dicom';
case '.raw'
MRS_struct.p.vendor = 'Philips_raw';
case '.rda'
MRS_struct.p.vendor = 'Siemens_rda';
case '.sdat'
MRS_struct.p.vendor = 'Philips';
if all(isstrprop(ext(end-3:end), 'upper'))
MRS_struct.p.spar_string = 'SPAR';
else
MRS_struct.p.spar_string = 'spar';
end
case '.data'
MRS_struct.p.vendor = 'Philips_data';
case '.raw'
MRS_struct.p.vendor = 'Philips_raw';
case '.rda'
MRS_struct.p.vendor = 'Siemens_rda';
case '.dat'
MRS_struct.p.vendor = 'Siemens_twix';
case '.ima'
MRS_struct.p.vendor = 'Siemens_dicom';
case '.dcm'
MRS_struct.p.vendor = 'dicom';
case {'.gz','.nii'}
MRS_struct.p.vendor = 'nifti';
otherwise
error('Unrecognized file type! Extension should be .7, .sdat, .data, .raw, .rda, .dat, .ima, .dcm, .gz, or .nii.');
error('Unrecognized file type! Extension should be .7, .dat, .data, .dcm, .gz, .ima, .nii, .raw, .rda, or, .sdat.');
end

end
Expand Down
2 changes: 1 addition & 1 deletion ExportToCSV.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function ExportToCSV(MRS_struct, vox, module)
end
out.MATLAB_ver = cellstr(repmat(version('-release'), n_rep));
out.Gannet_ver = cellstr(repmat(MRS_struct.version.Gannet, n_rep));
out.date_of_analysis = cellstr(repmat(datestr(date, 'yyyy-mm-dd'), n_rep));
out.date_of_analysis = cellstr(repmat(datestr(date, 'yyyy-mm-dd'), n_rep)); %#ok<*DATE,*DATST>


%%% 1. Extract data from GannetFit %%%
Expand Down
39 changes: 18 additions & 21 deletions GERead.m
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@

MRS_struct.p.LarmorFreq(ii) = i_hdr_value(rdb_hdr_ps_mps_freq)/1e7;
MRS_struct.p.sw(ii) = f_hdr_value(rdb_hdr_user0);

nechoes = hdr_value(rdb_hdr_nechoes);
MRS_struct.p.GE.nechoes(ii) = nechoes;
nex = hdr_value(rdb_hdr_navs);
Expand Down Expand Up @@ -286,12 +285,12 @@
if nechoes == 1

if (dataframes + refframes) ~= nframes
mult = 1;
mult = 1;
MRS_struct.p.GE.noadd(ii) = 1;
dataframes = dataframes * nex;
refframes = nframes - dataframes;
dataframes = dataframes * nex;
refframes = nframes - dataframes;
else
mult = 1/nex;
mult = 1/nex;
MRS_struct.p.GE.noadd(ii) = 0;
end

Expand All @@ -301,29 +300,23 @@

totalframes = totalframes - (refframes + 1);

MRS_struct.p.nrows(ii) = totalframes;
MRS_struct.p.Navg(ii) = dataframes * nex;
MRS_struct.p.nrows(ii) = totalframes;
MRS_struct.p.Navg(ii) = dataframes * nex;
MRS_struct.p.Nwateravg(ii) = refframes * nex;

else

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

if (dataframes + refframes) ~= nframes
mult = nex/2; % RTN 2016
multw = nex; % RTN 2016
%mult = 1; % RTN 2017
%multw = 1; % RTN 2017
mult = nex/2; % RTN 2016 1; % RTN 2017
multw = nex; % RTN 2016 1; % RTN 2017
MRS_struct.p.GE.noadd(ii) = 1;
dataframes = dataframes * nex;
refframes = nframes - dataframes;
dataframes = dataframes * nex;
refframes = nframes - dataframes;
else
%mult = nex/2; % RTN 2016
%multw = 1; % RTN 2016
%mult = 1; % RTN 2017
%multw = 1/nex; % RTN 2017
mult = 1/nex; % MM 2020
multw = 1; % MM 2020
mult = 1/nex; % MM 2020 1; % RTN 2017 nex/2; % RTN 2016
multw = 1; % MM 2020 1/nex; % RTN 2017 1; % RTN 2016
MRS_struct.p.GE.noadd(ii) = 0;
end

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

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

end
Expand All @@ -361,7 +354,11 @@
WaterData = squeeze(complex(WaterData(1,:,:,:), WaterData(2,:,:,:)));
WaterData = permute(WaterData, [3 1 2]);

% Generalized least squares method (An et al., JMRI, 2013, doi:10.1002/jmri.23941)
% Combine coils using generalized least squares method (An et al., JMRI,
% 2013, doi:10.1002/jmri.23941); the noise covariance matrix is more
% optionally estimated by using all averages as suggested by Rodgers &
% Robson (MRM, 2010, doi:10.1002/mrm.22230)

[nCh, nPts, nReps] = size(WaterData);
noise_pts = false(1,nPts);
noise_pts(ceil(0.75*nPts):end) = true;
Expand Down
Binary file added Gannet3_logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Gannet3_logo.png
Binary file not shown.
43 changes: 21 additions & 22 deletions GannetCoRegister.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
error('MATLAB:minrhs','Not enough input arguments.');
end

MRS_struct.version.coreg = '220923';
MRS_struct.version.coreg = '221021';

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

Expand Down Expand Up @@ -36,7 +36,7 @@
run_count = 0;

for ii = 1:MRS_struct.p.numScans

[~,b,c] = fileparts(MRS_struct.metabfile{1,ii});
[~,e,f] = fileparts(struc{ii});
if strcmpi(f, '.gz')
Expand All @@ -52,25 +52,24 @@

% Loop over voxels if PRIAM
for kk = 1:length(vox)

switch MRS_struct.p.vendor

case 'GE'
case 'GE'
[~,~,ext] = fileparts(struc{ii});
if strcmp(ext,'.nii')
MRS_struct = GannetMask_GE_nii(fname, struc{ii}, MRS_struct, ii, vox, kk);
else
MRS_struct = GannetMask_GE(fname, struc{ii}, MRS_struct, ii, vox, kk);
end

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

case 'Philips'
sparname = [MRS_struct.metabfile{1,ii}(1:(end-4)) MRS_struct.p.spar_string];
MRS_struct = GannetMask_Philips(sparname, struc{ii}, MRS_struct, ii, vox, kk);

case 'Philips_data'
if exist(MRS_struct.metabfile_sdat,'file')
MRS_struct.p.vendor = 'Philips';
Expand Down Expand Up @@ -100,7 +99,7 @@
fname = MRS_struct.metabfile{1,ii*2-1};
MRS_struct = GannetMask_SiemensRDA(fname, struc{ii}, MRS_struct, ii, vox, kk);

case {'Siemens_dicom', 'Siemens_twix', 'dicom'}
case {'Siemens_dicom', 'Siemens_twix', 'DICOM'}
MRS_struct = GannetMask_SiemensTWIX(fname, struc{ii}, MRS_struct, ii, vox, kk);

end
Expand All @@ -122,46 +121,46 @@
set(h,'Color',[1 1 1]);
figTitle = 'GannetCoRegister Output';
set(h,'Name',figTitle,'Tag',figTitle,'NumberTitle','off');

subplot(2,3,4:6);
axis off;

[~,tmp,tmp2] = fileparts(MRS_struct.mask.(vox{kk}).outfile{ii});
fname = [tmp tmp2];
if length(fname) > 30
fname = [fname(1:12) '...' fname(end-11:end)];
end
text(0.5, 0.75, 'Mask output: ', 'HorizontalAlignment' , 'right', 'FontName', 'Arial', 'FontSize', 13);
text(0.5, 0.75, [' ' fname], 'FontName', 'Arial', 'FontSize', 13, 'Interpreter', 'none');

text(0.5, 0.63, 'Spatial parameters: ', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
text(0.5, 0.63, ' [LR, AP, FH]', 'FontName', 'Arial', 'FontSize', 13);

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}'];
text(0.5, 0.51, 'Dimensions: ', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
text(0.5, 0.51, tmp, 'FontName', 'Arial', 'FontSize', 13, 'Interpreter', 'tex');

tmp = [' ' num2str(prod(MRS_struct.p.voxdim(ii,:))/1e3) ' mL'];
text(0.5, 0.39, 'Volume: ', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
text(0.5, 0.39, tmp, 'FontName', 'Arial', 'FontSize', 13);

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'];
text(0.5, 0.27, 'Position: ', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
text(0.5, 0.27, tmp, 'FontName', 'Arial', 'FontSize', 13);

if any(strcmp(MRS_struct.p.vendor,{'Philips','Philips_data'}))
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'];
else
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'];
end
text(0.5, 0.15, 'Angulation: ', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
text(0.5, 0.15, tmp, 'FontName', 'Arial', 'FontSize', 13);

text(0.5, 0.03, 'CoRegVer: ', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
text(0.5, 0.03, [' ' MRS_struct.version.coreg], 'FontName', 'Arial', 'FontSize', 13);

ha = subplot(2,3,1:3);

if strcmp(MRS_struct.p.vendor,'Siemens_rda')
[~,tmp,tmp2] = fileparts(MRS_struct.metabfile{1,ii*2-1});
else
Expand All @@ -177,19 +176,19 @@
T1image = [T1image(1:12) '...' T1image(end-11:end)];
end
t = ['Voxel from ' fname ' on ' T1image];

imagesc(MRS_struct.mask.(vox{kk}).img{ii});
axis equal tight off;
text(10, size(MRS_struct.mask.(vox{kk}).img{ii},1)/2, 'L', 'Color', [1 1 1], 'FontSize', 20);
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);
set(ha,'pos',[0 0.15 1 1]);
title(t, 'FontName', 'Arial', 'FontSize', 15, 'Interpreter', 'none');

% Save output as PDF
run_count = SavePDF(h, MRS_struct, ii, 1, kk, vox, mfilename, run_count);

end

end

% Save MRS_struct as mat file
Expand Down
Loading

0 comments on commit b2a13e4

Please sign in to comment.