Skip to content

Commit

Permalink
Merge pull request #326 from HJZollner/develop
Browse files Browse the repository at this point in the history
Fix plot related issues
  • Loading branch information
HJZollner authored Aug 25, 2021
2 parents 4944974 + b55d2c8 commit f3d2829
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 42 deletions.
12 changes: 0 additions & 12 deletions GUI/osp_FitTabChangeFcn.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@ function osp_FitTabChangeFcn(src,~,gui)
%%% 1. GET HANDLES %%%
% User selected tab refreshs plot
gui.fit.Selected = src.Selection;
% Parameter shown in the info panel on top
% gui.Info.fit = gui.layout.(gui.layout.fitTabhandles{gui.fit.Selected}).Children(2);
gui.Results.fit = gui.layout.(gui.layout.fitTabhandles{gui.fit.Selected}).Children(1).Children(1);
gui.Plot.fit = gui.layout.(gui.layout.fitTabhandles{gui.fit.Selected});
gui.InfoText.fit = gui.layout.(gui.layout.fitTabhandles{gui.fit.Selected}).Children(2).Children;
set(gui.layout.(gui.layout.fitTabhandles{gui.fit.Selected}).Children(2).Children(3).Children(1).Children.Children(4),'String',gui.controls.act_z)
set(gui.layout.(gui.layout.fitTabhandles{gui.fit.Selected}).Children(2).Children(3).Children(1).Children.Children(5),'String',gui.controls.act_y)
set(gui.layout.(gui.layout.fitTabhandles{gui.fit.Selected}).Children(2).Children(3).Children(1).Children.Children(6),'String',gui.controls.act_x)
gui.Results.fit = gui.layout.(gui.layout.fitTabhandles{gui.fit.Selected}).Children(1).Children(1).Children;
delete(gui.Plot.fit.Children(1).Children(2).Children)
% Grid for Plot
gui.Plot.fit = gui.layout.(gui.layout.fitTabhandles{gui.fit.Selected});

%%% 2. UPDATE GUI %%%
osp_updateFitWindow(gui);
Expand Down
22 changes: 16 additions & 6 deletions GUI/osp_iniFitWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,22 @@ function osp_iniFitWindow(gui)
resultsFontSize = 8;
case 'Osprey'
% Number of metabolites and lipid/MM basis functions
nMets = MRSCont.fit.resBasisSet.(gui.fit.Style){1,MRSCont.info.A.unique_ndatapoint_indsort(gui.controls.Selected)}.nMets;
nMMLip = MRSCont.fit.resBasisSet.(gui.fit.Style){1,MRSCont.info.A.unique_ndatapoint_indsort(gui.controls.Selected)}.nMM;
nMets = MRSCont.fit.basisSet.nMets;
nMMLip = MRSCont.fit.basisSet.nMM;
% Additional info panel string for the water fit range
waterFitRangeString = ['Fitting range: ' num2str(MRSCont.opts.fit.rangeWater(1)) ' to ' num2str(MRSCont.opts.fit.rangeWater(2)) ' ppm'];
% Where are the metabolite names stored?
basisSetNames = MRSCont.fit.resBasisSet.(gui.fit.Style){1,MRSCont.info.A.unique_ndatapoint_indsort(gui.controls.Selected)}.name;
if strcmp(gui.fit.Style, 'ref') || strcmp(gui.fit.Style, 'w')
basisSetNames = MRSCont.fit.resBasisSet.(gui.fit.Style).water.(['np_sw_' num2str(MRSCont.processed.A{1}.sz(1)) '_' num2str(MRSCont.processed.A{1}.spectralwidth)]).name;
else if strcmp(gui.fit.Style, 'conc')
basisSetNames = MRSCont.fit.resBasisSet.(gui.fit.Style).(['np_sw_' num2str(MRSCont.processed.A{1}.sz(1)) '_' num2str(MRSCont.processed.A{1}.spectralwidth)]).name;
else if strcmp(gui.fit.Style, 'off')
basisSetNames = MRSCont.fit.resBasisSet.(gui.fit.Style).(['np_sw_' num2str(MRSCont.processed.A{1}.sz(1)) '_' num2str(MRSCont.processed.A{1}.spectralwidth)]).name;
else
basisSetNames = MRSCont.fit.resBasisSet.(gui.fit.Style).(['np_sw_' num2str(MRSCont.processed.A{1}.sz(1)) '_' num2str(MRSCont.processed.A{1}.spectralwidth)]).name;
end
end
end
% Larger fonts for the results
resultsFontSize = 11;
end
Expand Down Expand Up @@ -276,9 +286,9 @@ function osp_iniFitWindow(gui)
switch MRSCont.opts.fit.method
case 'Osprey'
if MRSCont.flags.hasRef %Calculate Raw Water Scaled amplitudes
RawAmpl = RawAmpl ./ (MRSCont.fit.results.ref.fitParams{1,gui.controls.Selected}.ampl .* MRSCont.fit.scale{kk});
RawAmpl = RawAmpl ./ (MRSCont.fit.results.ref.fitParams{1,gui.controls.Selected}.ampl .* MRSCont.fit.scale{gui.controls.Selected});
else
RawAmpl = RawAmpl ./ (MRSCont.fit.results.water.fitParams{1,gui.controls.Selected}.ampl .* MRSCont.fit.scale{kk});
RawAmpl = RawAmpl ./ (MRSCont.fit.results.water.fitParams{1,gui.controls.Selected}.ampl .* MRSCont.fit.scale{gui.controls.Selected});
end
case 'LCModel'
end
Expand Down Expand Up @@ -310,7 +320,7 @@ function osp_iniFitWindow(gui)
else %Water/reference fit
NameText = ['Water: ' ];
RawAmplText = [num2str(RawAmpl,'%1.2e')];
set(gui.Results.fit, 'Title', ['Raw Amplitudes']);
set(gui.Results.fit{t}, 'Title', ['Raw Amplitudes']);
gui.Results.FitText = uix.HBox('Parent', gui.Results.fit{t}, 'Padding', 5,'BackgroundColor',gui.colormap.Background);
gui.Results.FitTextNames = uicontrol('Parent',gui.Results.FitText,'style','text',...
'FontSize', 11, 'FontName', gui.font,'HorizontalAlignment', 'left', 'String', sprintf(NameText),...
Expand Down
18 changes: 14 additions & 4 deletions GUI/osp_onPrint.m
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,22 @@ function osp_onPrint( ~, ~ ,gui)
resultsFontSize = 6;
case 'Osprey'
% Number of metabolites and lipid/MM basis functions
nMets = MRSCont.fit.resBasisSet.(gui.fit.Style){1,MRSCont.info.A.unique_ndatapoint_indsort(gui.controls.Selected)}.nMets;
nMMLip = MRSCont.fit.resBasisSet.(gui.fit.Style){1,MRSCont.info.A.unique_ndatapoint_indsort(gui.controls.Selected)}.nMM;
nMets = MRSCont.fit.basisSet.nMets;
nMMLip = MRSCont.fit.basisSet.nMM;
% Additional info panel string for the water fit range
waterFitRangeString = ['Fitting range: ' num2str(MRSCont.opts.fit.rangeWater(1)) ' to ' num2str(MRSCont.opts.fit.rangeWater(2)) ' ppm'];
% Where are the metabolite names stored?
basisSetNames = MRSCont.fit.resBasisSet.(gui.fit.Style){1,MRSCont.info.A.unique_ndatapoint_indsort(gui.controls.Selected)}.name;
if strcmp(gui.fit.Style, 'ref') || strcmp(gui.fit.Style, 'w')
basisSetNames = MRSCont.fit.resBasisSet.(gui.fit.Style).water.(['np_sw_' num2str(MRSCont.processed.A{gui.controls.Selected}.sz(1)) '_' num2str(MRSCont.processed.A{1}.spectralwidth)]).name;
else if strcmp(gui.fit.Style, 'conc')
basisSetNames = MRSCont.fit.resBasisSet.(gui.fit.Style).(['np_sw_' num2str(MRSCont.processed.A{gui.controls.Selected}.sz(1)) '_' num2str(MRSCont.processed.A{1}.spectralwidth)]).name;
else if strcmp(gui.fit.Style, 'off')
basisSetNames = MRSCont.fit.resBasisSet.(gui.fit.Style).(['np_sw_' num2str(MRSCont.processed.A{gui.controls.Selected}.sz(1)) '_' num2str(MRSCont.processed.A{1}.spectralwidth)]).name;
else
basisSetNames = MRSCont.fit.resBasisSet.(gui.fit.Style).(['np_sw_' num2str(MRSCont.processed.A{gui.controls.Selected}.sz(1)) '_' num2str(MRSCont.processed.A{1}.spectralwidth)]).name;
end
end
end
% Larger fonts for the results
resultsFontSize = 11;
end
Expand All @@ -299,7 +309,7 @@ function osp_onPrint( ~, ~ ,gui)
CRLB = MRSCont.fit.results.(gui.fit.Style).fitParams{1,gui.controls.Selected}.CRLB;
end
case 'Osprey'
RawAmpl = MRSCont.fit.results.(gui.fit.Style).fitParams{1,kk}.ampl .* MRSCont.fit.scale{kk};
RawAmpl = MRSCont.fit.results.(gui.fit.Style).fitParams{1,gui.controls.Selected}.ampl .* MRSCont.fit.scale{gui.controls.Selected};
end
else %Is concatenated and not water/reference
gui.fit.Style = 'conc';
Expand Down
26 changes: 18 additions & 8 deletions GUI/osp_updateFitWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,22 @@ function osp_updateFitWindow(gui)
resultsFontSize = 9;
case 'Osprey'
% Number of metabolites and lipid/MM basis functions
nMets = MRSCont.fit.resBasisSet.(gui.fit.Style){1,MRSCont.info.A.unique_ndatapoint_indsort(1,gui.controls.Selected)}.nMets;
nMMLip = MRSCont.fit.resBasisSet.(gui.fit.Style){1,MRSCont.info.A.unique_ndatapoint_indsort(1,gui.controls.Selected)}.nMM;
nMets = MRSCont.fit.basisSet.nMets;
nMMLip = MRSCont.fit.basisSet.nMM;
% Additional info panel string for the water fit range
waterFitRangeString = ['Fitting range: ' num2str(MRSCont.opts.fit.rangeWater(1)) ' to ' num2str(MRSCont.opts.fit.rangeWater(2)) ' ppm'];
% Where are the metabolite names stored?
basisSetNames = MRSCont.fit.resBasisSet.(gui.fit.Style){1,MRSCont.info.A.unique_ndatapoint_indsort(1,gui.controls.Selected)}.name;
if strcmp(gui.fit.Style, 'ref') || strcmp(gui.fit.Style, 'w')
basisSetNames = MRSCont.fit.resBasisSet.(gui.fit.Style).water.(['np_sw_' num2str(MRSCont.processed.A{gui.controls.Selected}.sz(1)) '_' num2str(MRSCont.processed.A{1}.spectralwidth)]).name;
else if strcmp(gui.fit.Style, 'conc')
basisSetNames = MRSCont.fit.resBasisSet.(gui.fit.Style).(['np_sw_' num2str(MRSCont.processed.A{gui.controls.Selected}.sz(1)) '_' num2str(MRSCont.processed.A{1}.spectralwidth)]).name;
else if strcmp(gui.fit.Style, 'off')
basisSetNames = MRSCont.fit.resBasisSet.(gui.fit.Style).(['np_sw_' num2str(MRSCont.processed.A{gui.controls.Selected}.sz(1)) '_' num2str(MRSCont.processed.A{1}.spectralwidth)]).name;
else
basisSetNames = MRSCont.fit.resBasisSet.(gui.fit.Style).(['np_sw_' num2str(MRSCont.processed.A{gui.controls.Selected}.sz(1)) '_' num2str(MRSCont.processed.A{1}.spectralwidth)]).name;
end
end
end
% Larger fonts for the results
resultsFontSize = 11;
end
Expand Down Expand Up @@ -168,11 +178,11 @@ function osp_updateFitWindow(gui)
'\nFitting range: ' num2str(MRSCont.opts.fit.range(1)) ' to ' num2str(MRSCont.opts.fit.range(2)) ' ppm; Baseline knot spacing: ' num2str(MRSCont.opts.fit.bLineKnotSpace) ' ppm; ph0: ' num2str(ph0,'%1.2f') 'deg; ph1: ' num2str(ph1,'%1.2f') 'deg; refShift: ' num2str(refShift,'%1.2f') ' Hz; refFWHM: ' num2str(refFWHM,'%1.2f')...
' ppm\nNumber of metabolites: ' num2str(nMets) '; Number of MM/lipids: ' num2str(nMMLip) ...
' scale: ' num2str(MRSCont.fit.scale{gui.controls.Selected}) '; initial ph0: ' num2str(iniph0,'%1.2f') 'deg; initial ph1: ' num2str(iniph1,'%1.2f') 'deg'];
else if strcmp (which, 'ref') %Reference data?
StatText = ['Reference Data -> Sequence: ' gui.load.Names.Seq '; Fitting algorithm: ' MRSCont.opts.fit.method '; Fitting Style: ' MRSCont.opts.fit.style '; Selected subspecs: ' which,...
else if strcmp (Selection, 'ref') %Reference data?
StatText = ['Reference Data -> Sequence: ' gui.load.Names.Seq '; Fitting algorithm: ' MRSCont.opts.fit.method '; Fitting Style: ' MRSCont.opts.fit.style '; Selected subspecs: ' Selection,...
'\n' waterFitRangeString];
else %Is water data
StatText = ['Water Data -> Sequence: ' gui.load.Names.Seq '; Fitting algorithm: ' MRSCont.opts.fit.method '; Fitting Style: ' MRSCont.opts.fit.style '; Selected subspecs: ' which,...
StatText = ['Water Data -> Sequence: ' gui.load.Names.Seq '; Fitting algorithm: ' MRSCont.opts.fit.method '; Fitting Style: ' MRSCont.opts.fit.style '; Selected subspecs: ' Selection,...
'\n' waterFitRangeString];
end
end
Expand Down Expand Up @@ -207,9 +217,9 @@ function osp_updateFitWindow(gui)
switch MRSCont.opts.fit.method
case 'Osprey'
if MRSCont.flags.hasRef %Calculate Raw Water Scaled amplitudes
RawAmpl = RawAmpl ./ (MRSCont.fit.results.ref.fitParams{1,gui.controls.Selected}.ampl .* MRSCont.fit.scale{kk});
RawAmpl = RawAmpl ./ (MRSCont.fit.results.ref.fitParams{1,gui.controls.Selected}.ampl .* MRSCont.fit.scale{gui.controls.Selected});
else
RawAmpl = RawAmpl ./ (MRSCont.fit.results.water.fitParams{1,gui.controls.Selected}.ampl .* MRSCont.fit.scale{kk});
RawAmpl = RawAmpl ./ (MRSCont.fit.results.water.fitParams{1,gui.controls.Selected}.ampl .* MRSCont.fit.scale{gui.controls.Selected});
end
case 'LCModel'
end
Expand Down
24 changes: 12 additions & 12 deletions plot/osp_plotFit.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,32 +135,32 @@
if (MRSCont.flags.isPRIAM == 1)
if strcmp(which_spec, 'ref') || strcmp(which_spec, 'w')
fitRangePPM = MRSCont.opts.fit.rangeWater;
basisSet = MRSCont.fit.resBasisSet{VoxelIndex}.(which_spec).water{MRSCont.info.(which_spec).unique_ndatapoint_indsort(kk)};
basisSet = MRSCont.fit.resBasisSet{VoxelIndex}.(which_spec).water.(['np_sw_' num2str(dataToPlot.sz(1)) '_' num2str(dataToPlot.spectralwidth)]);
else if strcmp(which_spec, 'conc')
fitRangePPM = MRSCont.opts.fit.range;
basisSet = MRSCont.fit.resBasisSet{VoxelIndex}.(which_spec){MRSCont.info.diff1.unique_ndatapoint_indsort(kk)};
basisSet = MRSCont.fit.resBasisSet{VoxelIndex}.(which_spec).(['np_sw_' num2str(dataToPlot.sz(1)) '_' num2str(dataToPlot.spectralwidth)]);
else if strcmp(which_spec, 'off')
fitRangePPM = MRSCont.opts.fit.range;
basisSet = MRSCont.fit.resBasisSet{VoxelIndex}.(which_spec){kk};
basisSet = MRSCont.fit.resBasisSet{VoxelIndex}.(which_spec).(['np_sw_' num2str(dataToPlot.sz(1)) '_' num2str(dataToPlot.spectralwidth)]);
else
fitRangePPM = MRSCont.opts.fit.range;
basisSet = MRSCont.fit.resBasisSet{VoxelIndex}.(which_spec){kk};
basisSet = MRSCont.fit.resBasisSet{VoxelIndex}.(which_spec).(['np_sw_' num2str(dataToPlot.sz(1)) '_' num2str(dataToPlot.spectralwidth)]);
end
end
end
else
if strcmp(which_spec, 'ref') || strcmp(which_spec, 'w')
fitRangePPM = MRSCont.opts.fit.rangeWater;
basisSet = MRSCont.fit.resBasisSet.(which_spec).water{MRSCont.info.(which_spec).unique_ndatapoint_indsort(kk)};
basisSet = MRSCont.fit.resBasisSet.(which_spec).water.(['np_sw_' num2str(dataToPlot.sz(1)) '_' num2str(dataToPlot.spectralwidth)]);
else if strcmp(which_spec, 'conc')
fitRangePPM = MRSCont.opts.fit.range;
basisSet = MRSCont.fit.resBasisSet.(which_spec){MRSCont.info.diff1.unique_ndatapoint_indsort(kk)};
basisSet = MRSCont.fit.resBasisSet.(which_spec).(['np_sw_' num2str(dataToPlot.sz(1)) '_' num2str(dataToPlot.spectralwidth)]);
else if strcmp(which_spec, 'off')
fitRangePPM = MRSCont.opts.fit.range;
basisSet = MRSCont.fit.resBasisSet.(which_spec){kk};
basisSet = MRSCont.fit.resBasisSet.(which_spec).(['np_sw_' num2str(dataToPlot.sz(1)) '_' num2str(dataToPlot.spectralwidth)]);
else
fitRangePPM = MRSCont.opts.fit.range;
basisSet = MRSCont.fit.resBasisSet.(which_spec){kk};
basisSet = MRSCont.fit.resBasisSet.(which_spec).(['np_sw_' num2str(dataToPlot.sz(1)) '_' num2str(dataToPlot.spectralwidth)]);
end
end
end
Expand All @@ -179,16 +179,16 @@

if strcmp(which_spec, 'ref') || strcmp(which_spec, 'w')
fitRangePPM = MRSCont.opts.fit.rangeWater;
basisSet = MRSCont.fit.resBasisSet.(which_spec).water{MRSCont.info.(which_spec).unique_ndatapoint_indsort(kk)};
basisSet = MRSCont.fit.resBasisSet.(which_spec).water.(['np_sw_' num2str(dataToPlot.sz(1)) '_' num2str(dataToPlot.spectralwidth)]);
else if strcmp(which_spec, 'conc')
fitRangePPM = MRSCont.opts.fit.range;
basisSet = MRSCont.fit.resBasisSet.(which_spec){MRSCont.info.diff1.unique_ndatapoint_indsort(kk)};
basisSet = MRSCont.fit.resBasisSet.(which_spec).(['np_sw_' num2str(dataToPlot.sz(1)) '_' num2str(dataToPlot.spectralwidth)]);
else if strcmp(which_spec, 'off')
fitRangePPM = MRSCont.opts.fit.range;
basisSet = MRSCont.fit.resBasisSet.(which_spec){kk};
basisSet = MRSCont.fit.resBasisSet.(which_spec).(['np_sw_' num2str(dataToPlot.sz(1)) '_' num2str(dataToPlot.spectralwidth)]);
else
fitRangePPM = MRSCont.opts.fit.range;
basisSet = MRSCont.fit.resBasisSet.(which_spec){kk};
basisSet = MRSCont.fit.resBasisSet.(which_spec).(['np_sw_' num2str(dataToPlot.sz(1)) '_' num2str(dataToPlot.spectralwidth)]);
end
end
end
Expand Down

0 comments on commit f3d2829

Please sign in to comment.