Skip to content

Commit

Permalink
[BUG FIX] - Osprey GUI - Crash for MEGA data - Gaelle Doucet
Browse files Browse the repository at this point in the history
GUI generated job crashes for MEGA data. This was related to the edit target and include metabolite cells.

Additionally, fixed process plots for dcm plots.

Release preparation.
  • Loading branch information
HJZollner committed Jun 24, 2022
1 parent 6062789 commit a9d1296
Show file tree
Hide file tree
Showing 20 changed files with 69 additions and 54 deletions.
2 changes: 1 addition & 1 deletion GUI/Osprey.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
logoFcn = @()imread('osprey.png', 'BackgroundColor', gui.colormap.Background);
logoBanner = uiw.utility.loadIcon(logoFcn);
% Here the intro banner is created
gui.d = uiw.dialog.About('Name', 'Osprey','Version','2.2.0','Date', 'April 12, 2022',...
gui.d = uiw.dialog.About('Name', 'Osprey','Version','2.3.0','Date', 'June 24, 2022',...
'Timeout', 3,'CustomText', 'Osprey is provided by Johns Hopkins University.',...
'ContactInfo', '[email protected]','LogoCData', logoBanner);

Expand Down
2 changes: 1 addition & 1 deletion GUI/osp_Toolbox_Check.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
% 2020-05-15: First version of the code.
%% % 1. SAVE OSPREY VERSION%%%
%%% 1. SAVE OSPREY VERSION%%%
OspreyVersion = 'Osprey 2.2.0';
OspreyVersion = 'Osprey 2.3.0';
fprintf(['Timestamp %s ' OspreyVersion ' ' Module '\n'], datestr(now,'mmmm dd, yyyy HH:MM:SS'));
hasSPM = 1; % For the compiled GUI
%% % 2. GET SPMPATH AND TOOLBOXES%%%
Expand Down
2 changes: 1 addition & 1 deletion GUI/osp_onLoad.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
osp_iniLoadWindow(gui);
gui.layout.b_load.Enable = 'off';
gui.layout.b_proc.Enable = 'on';
if MRSCont.flags.hasSPM == 1
if MRSCont.flags.hasSPM == 1 && ~isempty(MRSCont.files_nii)
gui.layout.b_coreg.Enable = 'on';
end
gui.layout.ListBox.Enable = 'on';
Expand Down
4 changes: 2 additions & 2 deletions fit/OspreyFit.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
if MRSCont.flags.hasRef
refFitTime = tic;
% Loop over all the datasets here
for kk = 1:MRSCont.nDatasets
for kk = 1:MRSCont.nDatasets(1)
[~] = printLog('OspreyFitRef',kk,1,MRSCont.nDatasets,progressText,MRSCont.flags.isGUI ,MRSCont.flags.isMRSI);
if ~(MRSCont.flags.didFit == 1 && MRSCont.flags.speedUp && isfield(MRSCont, 'fit') && (kk > length(MRSCont.fit.results.ref.fitParams))) || ~strcmp(MRSCont.ver.Osp,MRSCont.ver.CheckOsp)
[MRSCont] = osp_fitWater(MRSCont, kk, 'ref');
Expand All @@ -101,7 +101,7 @@
if MRSCont.flags.hasWater
waterFitTime = tic;
% Loop over all the datasets here
for kk = 1:MRSCont.nDatasets
for kk = 1:MRSCont.nDatasets(1)
[~] = printLog('OspreyFitWater',kk,1,MRSCont.nDatasets,progressText,MRSCont.flags.isGUI ,MRSCont.flags.isMRSI);
if ~(MRSCont.flags.didFit == 1 && MRSCont.flags.speedUp && isfield(MRSCont, 'fit') && (kk > length(MRSCont.fit.results.w.fitParams))) || ~strcmp(MRSCont.ver.Osp,MRSCont.ver.CheckOsp)
[MRSCont] = osp_fitWater(MRSCont, kk, 'w');
Expand Down
2 changes: 1 addition & 1 deletion fit/osp_fitHERCULES.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
else
progressText = '';
end
for kk = 1:MRSCont.nDatasets
for kk = 1:MRSCont.nDatasets(1)
[~] = printLog('OspreyFit',kk,1,MRSCont.nDatasets,progressText,MRSCont.flags.isGUI ,MRSCont.flags.isMRSI);
%%% 1. DETERMINE THE FITTING STYLE %%%
% Extract fit options
Expand Down
2 changes: 1 addition & 1 deletion fit/osp_fitHERMES.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
else
progressText = '';
end
for kk = 1:MRSCont.nDatasets
for kk = 1:MRSCont.nDatasets(1)
[~] = printLog('OspreyFit',kk,1,MRSCont.nDatasets,progressText,MRSCont.flags.isGUI ,MRSCont.flags.isMRSI);
%%% 1. DETERMINE THE FITTING STYLE %%%
% Extract fit options
Expand Down
2 changes: 1 addition & 1 deletion fit/osp_fitInitialise.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
end

% Determine the scaling factor between data and basis set for each dataset
for kk = 1:MRSCont.nDatasets
for kk = 1:MRSCont.nDatasets(1)
if ~MRSCont.flags.isMRSI && ~MRSCont.flags.isPRIAM
if ~MRSCont.flags.isUnEdited
dataToScale = op_takesubspec(MRSCont.processed.metab{kk},1);
Expand Down
2 changes: 1 addition & 1 deletion fit/osp_fitUnEdited.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
basisSet_mm = fit_selectMetabs(basisSet_mm, metabList_mm, 1);
end

for kk = 1:MRSCont.nDatasets
for kk = 1:MRSCont.nDatasets(1)


% ----- Osprey fit pipeline -----
Expand Down
Binary file modified job/CreateOspreyJob.mlapp
Binary file not shown.
3 changes: 1 addition & 2 deletions job/CreateOspreyJob_app.m
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ function H2OReferenceButtonPushed(app, event)
% Button pushed function: H2OShortTEButton
function H2OShortTEButtonPushed(app, event)
info = 'Please select the water short-TE file to read';
[fname,pathname]=uigetfile('*.*',info);

ndata = app.NumberofdatasetsEditField.Value;

Expand Down Expand Up @@ -492,7 +491,7 @@ function StatcsvFileButtonPushed(app, event)

csvfiles = spm_select(ndata,'any',info,{},pwd,'.csv','1');

app.StatcsvEditField.Value = svfiles(1,:);
app.StatcsvEditField.Value = csvfiles(1,:);
end

% Button pushed function: basissetfileButton
Expand Down
16 changes: 12 additions & 4 deletions job/OspreyJob.m
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
error('Invalid job file! A job file needs to specify an output folder.');
end
if isfield(jobStruct, 'file_stat')
outputFolder = jobStruct.file_stat{1};
file_stat = jobStruct.file_stat{1};
else
'';
end
Expand Down Expand Up @@ -307,10 +307,13 @@
MRSCont.opts.ECC.mm = str2num(jobStruct.ECCmm);
end
if isfield(jobStruct,'MM3coModel')
MRSCont.opts.fit.coMM3 = jobStruct.MM3coModel;
opts.fit.coMM3 = jobStruct.MM3coModel;
end
if isfield(jobStruct,'FWHMMM3co')
MRSCont.opts.fit.FWHMcoMM3= num2str(jobStruct.FWHMMM3co);
opts.fit.FWHMcoMM3= str2num(jobStruct.FWHMMM3co);
if isempty(opts.fit.FWHMcoMM3) || strcmp(opts.fit.FWHMcoMM3,' ')
opts.fit.FWHMcoMM3 = 14;
end
end
if isfield(jobStruct,'saveLCM')
MRSCont.opts.saveLCM = str2num(jobStruct.saveLCM);
Expand Down Expand Up @@ -445,6 +448,11 @@
MRSCont.opts.fit.coMM3 = 'none';
MRSCont.opts.fit.FWHMcoMM3 = 14;
end
if isfield(MRSCont.opts.fit, 'FWHMcoMM3')
if isempty(MRSCont.opts.fit.FWHMcoMM3)
MRSCont.opts.fit.FWHMcoMM3 = 14;
end
end
if ~isfield(MRSCont.opts.fit, 'GAP')
MRSCont.opts.fit.GAP.A = [];
MRSCont.opts.fit.GAP.diff1 = [];
Expand Down Expand Up @@ -703,7 +711,7 @@
%%% 7. SET FLAGS AND VERSION %%%
MRSCont.flags.didJob = 1;
MRSCont.loadedJob = jobFile;
MRSCont.ver.Osp = 'Osprey 2.2.0';
MRSCont.ver.Osp = 'Osprey 2.3.0';


%%% 8. CHECK IF OUTPUT STRUCTURE ALREADY EXISTS IN OUTPUT FOLDER %%%
Expand Down
6 changes: 3 additions & 3 deletions job/osp_create_job_file.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
fprintf(fid,'\n\t%s',['"seqType": "' app.SequenceTypeDropDown.Value '",']);

if strcmp(app.SequenceTypeDropDown.Value,'MEGA')
fprintf(fid,'\n\t%s',['"editTarget": "' app.EditingTargetsDropDown.Value '",']);
fprintf(fid,'\n\t%s',['"editTarget": ["' app.EditingTargetsDropDown.Value '"],']);
end
if strcmp(app.SequenceTypeDropDown.Value,'HERMES') || strcmp(app.SequenceTypeDropDown.Value,'HERCULES')
if strcmp(app.EditingTargetsDropDown.Value, 'GABA, GSH')
fprintf(fid,'\n\t%s',['"editTarget": "''GABA'',''GSH''",']);
fprintf(fid,'\n\t%s',['"editTarget": ["GABA","GSH"],']);
end
end

Expand Down Expand Up @@ -107,7 +107,7 @@
fprintf(fid,'%s','],');

otherwise
fprintf(fid,'\n\t%s',['"includeMetabs": "' app.IncludedMetabolitesDropDown.Value '",']);
fprintf(fid,'\n\t%s',['"includeMetabs": ["' app.IncludedMetabolitesDropDown.Value '"],']);
end

fprintf(fid,'\n\t%s',['"style": "' app.FittingStyleDropDown.Value '",']);
Expand Down
2 changes: 1 addition & 1 deletion libraries/FID-A/fitTools/fitModels/Osprey/fit_Osprey.m
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
[fitParamsStep2] = fit_OspreyPrelimStep2(dataToFitRef, resBasisSet, minKnotSpacingPPM, fitRangePPM, fitParamsStep1, refFWHM,fitOpts.GAP);
end
else
if fitOpts.GaussLBMM
if fitOpts.GaussLBMM && resBasisSet.nMM == 1 % We only want to use a separate gaussian parameter for the single MM functions
[fitParamsStep2] = fit_OspreyPrelimStep2MMExp(dataToFitRef, resBasisSet, minKnotSpacingPPM, fitRangePPM, fitParamsStep1, refFWHM,fitOpts.GAP);
else
[fitParamsStep2] = fit_OspreyPrelimStep2(dataToFitRef, resBasisSet, minKnotSpacingPPM, fitRangePPM, fitParamsStep1, refFWHM,fitOpts.GAP);
Expand Down
53 changes: 27 additions & 26 deletions libraries/FID-A/processingTools/op_rmempty.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,30 @@

function [out]=op_rmempty(in)

if in.flags.averaged
error('ERROR: Spectra have already been averaged! Aborting!');
end

% If the standard deviation of an FID is ~0, this FID row is empty.
% Find the indices of the averages with non-zero standard deviations -
% these are the ones that will be
idx_nonzeroFID = find(std(in.fids,0,1)>1e-40);
nonzero_fids = in.fids(:,idx_nonzeroFID);

%re-calculate Specs using fft
nonzero_specs=fftshift(fft(nonzero_fids,[],in.dims.t),in.dims.t);

%recalculate the sz vector
sz=size(nonzero_fids);

%
%FILLING IN DATA STRUCTURES
out=in;
out.fids=nonzero_fids;
out.specs=nonzero_specs;
out.sz=sz;
out.averages=sz(2);

%FILLING IN THE FLAGS
out.flags=in.flags;
if ~in.flags.averaged

% If the standard deviation of an FID is ~0, this FID row is empty.
% Find the indices of the averages with non-zero standard deviations -
% these are the ones that will be
idx_nonzeroFID = find(std(in.fids,0,1)>1e-40);
nonzero_fids = in.fids(:,idx_nonzeroFID);

%re-calculate Specs using fft
nonzero_specs=fftshift(fft(nonzero_fids,[],in.dims.t),in.dims.t);

%recalculate the sz vector
sz=size(nonzero_fids);

%
%FILLING IN DATA STRUCTURES
out=in;
out.fids=nonzero_fids;
out.specs=nonzero_specs;
out.sz=sz;
out.averages=sz(2);

%FILLING IN THE FLAGS
out.flags=in.flags;
else
out = in;
end
3 changes: 3 additions & 0 deletions plot/osp_plotLoad.m
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@
else if MRSCont.flags.isMEGA && (strcmp(which, 'w') || strcmp(which, 'ref')|| strcmp(which, 'mm_ref'))
axesHandles.A = gca();
nAvgs = dataToPlot.averages;
if nAvgs > dataToPlot.sz(dataToPlot.dims.averages)
nAvgs =dataToPlot.sz(dataToPlot.dims.averages);
end
% Loop over all averages
for rr = 1:nAvgs
plot(axesHandles.A, dataToPlot.ppm, real(dataToPlot.specs(:,rr)) + rr*stag, 'k', 'LineWidth', 0.5, 'Color',MRSCont.colormap.Foreground);
Expand Down
4 changes: 2 additions & 2 deletions plot/osp_plotRaincloud.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@
if ~strcmp(quant,'Quality')
ind = find(strcmp(MRSCont.overview.FitSpecNamesStruct.metab,model));
quant_ind = [basis ind(1)];
names_list = MRSCont.quantify.names.metab{quant_ind};
names_list = MRSCont.quantify.names.metab{quant_ind(2)};
idx_1 = find(strcmp(names_list,metab));
metabolite_conc = MRSCont.quantify.tables.metab.(quant).(['Voxel_' num2str(VoxelIndex)]){quant_ind};
metabolite_conc = MRSCont.quantify.tables.metab.(quant).(['Voxel_' num2str(VoxelIndex)]){quant_ind(2)};
ConcData = metabolite_conc{:,idx_1};
else
quality = {'SNR','FWHM','freqShift'};
Expand Down
6 changes: 3 additions & 3 deletions plot/osp_plotScatter.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@
ind = find(strcmp(MRSCont.overview.FitSpecNamesStruct.metab,model));
quant_ind = [basis ind(1)];

names_list = MRSCont.quantify.names.metab{quant_ind};
names_list = MRSCont.quantify.names.metab{quant_ind(2)};
idx_1 = find(strcmp(names_list,metab));
metabolite_conc = MRSCont.quantify.tables.metab.(quant).(['Voxel_' num2str(VoxelIndex)]){quant_ind};
metabolite_conc = MRSCont.quantify.tables.metab.(quant).(['Voxel_' num2str(VoxelIndex)]){quant_ind(2)};
ConcData = metabolite_conc{:,idx_1};


Expand All @@ -89,7 +89,7 @@
if ischar(corrData)
metabFlag = 1;
idx_1 = find(strcmp(names_list,corrData));
metabolite_conc = MRSCont.quantify.tables.metab.(quant).(['Voxel_' num2str(VoxelIndex)]){quant_ind};
metabolite_conc = MRSCont.quantify.tables.metab.(quant).(['Voxel_' num2str(VoxelIndex)]){quant_ind(2)};
corrData = metabolite_conc{:,idx_1};
end

Expand Down
4 changes: 4 additions & 0 deletions process/OspreyProcess.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@
raw_w.flags.averaged = 1;
raw_w.dims.averages = 0;
end

if raw_w.subspecs > 1
raw_w = combine_water_subspecs(raw_w);
end
if ~MRSCont.flags.isMRSI
[raw_w,~] = op_eccKlose(raw_w, raw_w); % Klose eddy current correction
else
Expand Down
6 changes: 3 additions & 3 deletions utilities/CompileOspreyStandalone.m
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function CompileOspreyStandalone(OutputDir,SPM12Dir,WidgetsDir,GUILayoutDir)
'OutputDir',OutputDirHBCD,...
'ExecutableIcon',fullfile(OspreyDir, 'graphics','osprey.gif'),...
'ExecutableSplashScreen',fullfile(OspreyDir, 'graphics','osprey.gif'),...
'ExecutableVersion','2.2.0',...
'ExecutableVersion','2.3.0',...
'ExecutableName','OspreyHBCD',...
'AdditionalFiles',{ fullfile(SPM12Dir),...
fullfile(OspreyDir,'coreg'),...
Expand Down Expand Up @@ -225,7 +225,7 @@ function CompileOspreyStandalone(OutputDir,SPM12Dir,WidgetsDir,GUILayoutDir)
'OutputDir',OutputDirCmd,...
'ExecutableIcon',fullfile(OspreyDir, 'graphics','osprey.gif'),...
'ExecutableSplashScreen',fullfile(OspreyDir, 'graphics','osprey.gif'),...
'ExecutableVersion','2.2.0',...
'ExecutableVersion','2.3.0',...
'ExecutableName','OspreyCMD',...
'AdditionalFiles',{ fullfile(SPM12Dir),...
fullfile(OspreyDir,'coreg'),...
Expand Down Expand Up @@ -264,7 +264,7 @@ function CompileOspreyStandalone(OutputDir,SPM12Dir,WidgetsDir,GUILayoutDir)
'OutputDir',OutputDirGUI,...
'ExecutableIcon',fullfile(OspreyDir, 'graphics','osprey.gif'),...
'ExecutableSplashScreen',fullfile(OspreyDir, 'graphics','osprey.gif'),...
'ExecutableVersion','2.2.0',...
'ExecutableVersion','2.3.0',...
'ExecutableName','Osprey',...
'AdditionalFiles',{fullfile(WidgetsDir),...
fullfile(GUILayoutDir),...
Expand Down
2 changes: 1 addition & 1 deletion utilities/osp_CheckRunPreviousModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
end

%Do the toolbox check here
OspreyVersion = 'Osprey 2.2.0';
OspreyVersion = 'Osprey 2.3.0';
hasSPM = 1;
[hasSPM,OspreyVersion ] = osp_Toolbox_Check (module,MRSCont.flags.isGUI);

Expand Down

0 comments on commit a9d1296

Please sign in to comment.