diff --git a/GUI/osp_FitTabChangeFcn.m b/GUI/osp_FitTabChangeFcn.m index 24306455..d0753a66 100644 --- a/GUI/osp_FitTabChangeFcn.m +++ b/GUI/osp_FitTabChangeFcn.m @@ -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); diff --git a/GUI/osp_iniFitWindow.m b/GUI/osp_iniFitWindow.m index 53ea7e2d..7673516a 100644 --- a/GUI/osp_iniFitWindow.m +++ b/GUI/osp_iniFitWindow.m @@ -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 @@ -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 @@ -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),... diff --git a/GUI/osp_onPrint.m b/GUI/osp_onPrint.m index bdcffff8..7be203bc 100644 --- a/GUI/osp_onPrint.m +++ b/GUI/osp_onPrint.m @@ -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 @@ -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'; diff --git a/GUI/osp_updateFitWindow.m b/GUI/osp_updateFitWindow.m index b14bac85..5ccd7525 100644 --- a/GUI/osp_updateFitWindow.m +++ b/GUI/osp_updateFitWindow.m @@ -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 @@ -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 @@ -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 diff --git a/plot/osp_plotFit.m b/plot/osp_plotFit.m index 4eae7f94..498a86d8 100755 --- a/plot/osp_plotFit.m +++ b/plot/osp_plotFit.m @@ -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 @@ -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