-
Notifications
You must be signed in to change notification settings - Fork 194
New function for Slice plotting added. Bug fixing in iso lines plotter. #818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
975b9b2
New function Plot Slice and Bug fixed in Iso Dose lines plot function
SimonaFa 18c13bb
Merge branch 'dev' of https://github.com/SimonaFa/matRad into dev
SimonaFa a8cb604
Merge branch 'dev' into dev
wahln 15e2954
Merge branch 'dev' into dev
wahln a590172
Merge branch 'e0404:dev' into dev
SimonaFa a1163e1
plotSlice function changes
SimonaFa 4d6d96e
plotSlice function modification to include display ct option and make…
SimonaFa d87921c
plot Slice function small fix
SimonaFa 1c49003
code cleanup
wahln afce203
Merge branch 'e0404:dev' into dev
SimonaFa df6d79e
Merge branch 'dev' into dev
wahln 77e19ab
plotSlice fixing and testing
SimonaFa 2931519
First substitution of plotSlice to deprecated plotSliceWrapper into c…
SimonaFa 625ec6a
Examples 1,2,5,7 substitution of plotSliceWrapper with new plotSlice
SimonaFa 8254137
Substitution of plotSliceWrapper with plotSlice
SimonaFa 6589fa5
Warning fix in plotSlice
SimonaFa e26769c
Merge branch 'dev' into dev
wahln fe64f8d
streamlined (using test data only) and octave compatible tests
wahln 21fd49d
Merge branch 'dev' into dev
wahln 3e98d48
Merge branch 'dev' into dev
wahln ced961e
fix test for optional inputs of new plotSlice
wahln File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wahln marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,215 @@ | ||
| function [hCMap,hDose,hCt,hContour,hIsoDose] = matRad_plotSlice(ct, varargin) | ||
| % matRad tool function to directly plot a complete slice of a ct with dose | ||
| % optionally including contours and isolines | ||
| % | ||
| % call | ||
| % [] = matRad_plotSlice(ct, dose, varargin) | ||
| % | ||
| % input (required) | ||
| % ct matRad ct struct | ||
| % dose dose cube | ||
| % | ||
| % input (optional/empty) to be called as Name-value pair arguments: | ||
| % axesHandle handle to axes the slice should be displayed in | ||
| % cst matRad cst struct | ||
| % cubeIdx Index of the desired cube in the ct struct | ||
| % plane plane view (coronal=1,sagittal=2,axial=3) | ||
| % slice slice in the selected plane of the 3D cube | ||
| % thresh threshold for display of dose values | ||
| % alpha alpha value for the dose overlay | ||
| % contourColorMap colormap for the VOI contours | ||
| % doseColorMap colormap for the dose | ||
| % doseWindow dose value window | ||
| % doseIsoLevels levels defining the isodose contours | ||
| % voiSelection logicals defining the current selection of contours | ||
| % that should be plotted. Can be set to [] to plot | ||
| % all non-ignored contours. | ||
| % colorBarLabel string defining the yLabel of the colorBar | ||
| % boolPlotLegend boolean if legend should be plottet or not | ||
| % varargin Additional MATLAB Line or Text Properties (e.g. 'LineWidth', 'FontSize', etc.) | ||
| % | ||
| % | ||
| % References | ||
| % - | ||
| % | ||
| % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| % | ||
| % Copyright 2015 the matRad development team. | ||
| % | ||
| % This file is part of the matRad project. It is subject to the license | ||
| % terms in the LICENSE file found in the top-level directory of this | ||
| % distribution and at https://github.com/e0404/matRad/LICENSE.md. No part | ||
| % of the matRad project, including this file, may be copied, modified, | ||
| % propagated, or distributed except according to the terms contained in the | ||
| % LICENSE file. | ||
| % | ||
| % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
|
|
||
| defaultDose = []; | ||
wahln marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| defaultCst = []; | ||
| defaultSlice = floor(min(ct.cubeDim)./2); | ||
| defaultAxesHandle = gca; | ||
| defaultCubeIdx = 1; | ||
| defaultPlane = 1; | ||
| defaultDoseWindow = []; | ||
| defaultThresh = []; | ||
| defaultAlpha = []; | ||
| defaultDoseColorMap = jet; | ||
| defaultDoseIsoLevels = []; | ||
| defaultVOIselection = []; | ||
| defaultContourColorMap = []; | ||
| defaultBoolPlotLegend = false; | ||
| defaultColorBarLabel = []; | ||
| defaultShowCt = true; | ||
|
|
||
| isDose = @(x) isnumeric(x) && all(size(x) == ct.cubeDim); | ||
| isSlice = @(x) x>=1 && x<=max(ct.cubeDim) && floor(x)==x; | ||
| isAxes = @(x) strcmp(get(gca, 'type'), 'axes'); | ||
| isCubeIdx = @(x) isscalar(x); | ||
| isPlane = @(x) isscalar(x) && (sum(x==[1, 2, 3])==1); | ||
| isDoseWindow = @(x) (length(x) == 2 && isvector(x)); | ||
| isThresh = @(x) (isscalar(x) && (x>=0) && (x<=1)) || isempty(x); | ||
| isAlpha = @(x) isscalar(x) && (x>=0) && (x<=1) || isempty(x); | ||
| isDoseColorMap = @(x) isnumeric(x) && (size(x, 2)==3) && all(x(:) >= 0) && all(x(:) <= 1); | ||
| isDoseIsoLevels = @(x) isnumeric(x) && isvector(x)|| isempty(x); | ||
| isVOIselection = @(x) isnumeric(x) || isempty(x); %all(x(:)==1 | x(:)==0) || isempty(x); | ||
| isContourColorMap = @(x) isnumeric(x) && (size(x, 2)==3) && size(x, 1)>=2 && all(x(:) >= 0) && all(x(:) <= 1); | ||
| isBoolPlotLegend = @(x) x==0 || x ==1; | ||
| isColorBarLabel = @(x) isstring(x) || ischar(x) || isempty(x); | ||
| isShowCt = @(x) isscalar(x) && (x==0) || (x==1); | ||
|
|
||
| p = inputParser; | ||
| p.KeepUnmatched = true; | ||
| addRequired(p, 'ct') | ||
|
|
||
| addParameter(p, 'dose', defaultDose, isDose) | ||
| addParameter(p, 'cst', defaultCst) | ||
| addParameter(p, 'slice', defaultSlice, isSlice) | ||
| addParameter(p, 'axesHandle', defaultAxesHandle, isAxes) | ||
| addParameter(p, 'cubeIdx', defaultCubeIdx, isCubeIdx) | ||
| addParameter(p, 'plane', defaultPlane, isPlane) | ||
| addParameter(p, 'doseWindow', defaultDoseWindow, isDoseWindow) | ||
| addParameter(p, 'thresh', defaultThresh, isThresh) | ||
| addParameter(p, 'alpha', defaultAlpha, isAlpha) | ||
| addParameter(p, 'doseColorMap', defaultDoseColorMap, isDoseColorMap) | ||
| addParameter(p, 'doseIsoLevels', defaultDoseIsoLevels, isDoseIsoLevels) | ||
| addParameter(p, 'voiSelection', defaultVOIselection, isVOIselection) | ||
| addParameter(p, 'contourColorMap', defaultContourColorMap, isContourColorMap) | ||
| addParameter(p, 'boolPlotLegend', defaultBoolPlotLegend, isBoolPlotLegend) | ||
| addParameter(p, 'colorBarLabel', defaultColorBarLabel, isColorBarLabel) | ||
| addParameter(p, 'showCt', defaultShowCt, isShowCt) | ||
|
|
||
| parse(p, ct, varargin{:}); | ||
|
|
||
| %% Unmatched properties | ||
| % General properties | ||
| lineFieldNames = fieldnames(set(line)); | ||
| textFieldNames = fieldnames(set(text)); | ||
| % Filter line properties from Unmatched | ||
| unmParamNames = fieldnames(p.Unmatched); | ||
| lineFields = unmParamNames(ismember(unmParamNames, lineFieldNames)); | ||
| lineValues = struct2cell(p.Unmatched); | ||
| lineValues = lineValues(ismember(unmParamNames, lineFieldNames)); | ||
| lineVarargin = reshape([lineFields, lineValues]', 1, []); | ||
| % Filter text properites from Unmatched | ||
| textFields = unmParamNames(ismember(unmParamNames, textFieldNames)); | ||
| textValues = struct2cell(p.Unmatched); | ||
| textValues = textValues(ismember(unmParamNames, textFieldNames)); | ||
| textVarargin = reshape([textFields, textValues]', 1, []); | ||
|
|
||
| %% Plot ct slice | ||
| matRad_cfg = MatRad_Config.instance(); | ||
|
|
||
| % Flip axes direction | ||
| set(p.Results.axesHandle,'YDir','Reverse'); | ||
| % plot ct slice | ||
| if p.Results.showCt | ||
| hCt = matRad_plotCtSlice(p.Results.axesHandle,p.Results.ct.cubeHU,p.Results.cubeIdx,p.Results.plane,p.Results.slice, [], []); | ||
| else | ||
| %figure() | ||
| end | ||
| hold on; | ||
|
|
||
| %% Plot dose | ||
| if ~isempty(p.Results.dose) | ||
| if ~isempty(p.Results.doseWindow) && p.Results.doseWindow(2) - p.Results.doseWindow(1) <= 0 | ||
| p.Results.doseWindow = [0 2]; | ||
| end | ||
|
|
||
| [hDose,doseColorMap,doseWindow] = matRad_plotDoseSlice(p.Results.axesHandle, p.Results.dose, p.Results.plane, p.Results.slice, p.Results.thresh, p.Results.alpha, p.Results.doseColorMap, p.Results.doseWindow); | ||
|
|
||
| %% Plot iso dose lines | ||
| if ~isempty(p.Results.doseIsoLevels) | ||
| hIsoDose = matRad_plotIsoDoseLines(p.Results.axesHandle,p.Results.dose,[],p.Results.doseIsoLevels,false,p.Results.plane,p.Results.slice,p.Results.doseColorMap,p.Results.doseWindow, lineVarargin{:}); | ||
| hold on; | ||
| else | ||
| hIsoDose = []; | ||
| end | ||
|
|
||
| %% Set Colorbar | ||
| hCMap = matRad_plotColorbar(p.Results.axesHandle,doseColorMap,doseWindow,'Location','EastOutside'); | ||
| set(hCMap,'Color',matRad_cfg.gui.textColor); | ||
| if ~isempty(p.Results.colorBarLabel) | ||
| set(get(hCMap,'YLabel'),'String', p.Results.colorBarLabel,'FontSize',matRad_cfg.gui.fontSize); | ||
| end | ||
| set(get(hCMap,'YLabel'),'String', p.Results.colorBarLabel, textVarargin{:}); | ||
| end | ||
| %% Plot VOI contours & Legend | ||
|
|
||
| if ~isempty(p.Results.cst) | ||
| [hContour,~] = matRad_plotVoiContourSlice(p.Results.axesHandle, p.Results.cst, p.Results.ct, p.Results.cubeIdx, p.Results.voiSelection, p.Results.plane, p.Results.slice, p.Results.contourColorMap, lineVarargin{:}); | ||
|
|
||
| if p.Results.boolPlotLegend | ||
| visibleOnSlice = (~cellfun(@isempty,hContour)); | ||
| ixLegend = find(p.Results.voiSelection); | ||
| hContourTmp = cellfun(@(X) X(1),hContour(visibleOnSlice),'UniformOutput',false); | ||
| if ~isempty(p.Results.voiSelection) | ||
| hLegend = legend(p.Results.axesHandle,[hContourTmp{:}],[p.Results.cst(ixLegend(visibleOnSlice),2)],'AutoUpdate','off','TextColor',matRad_cfg.gui.textColor); | ||
| else | ||
| hLegend = legend(p.Results.axesHandle,[hContourTmp{:}],[p.Results.cst(visibleOnSlice,2)],'AutoUpdate','off','TextColor',matRad_cfg.gui.textColor); | ||
| end | ||
| set(hLegend,'Box','On'); | ||
| set(hLegend,'TextColor',matRad_cfg.gui.textColor); | ||
| if ~isempty(textVarargin) | ||
| set(hLegend, textVarargin{:}); | ||
| else | ||
| set(hLegend,'FontSize',matRad_cfg.gui.fontSize); | ||
| end | ||
| end | ||
| else | ||
| hContour = []; | ||
| end | ||
|
|
||
| %% Adjust axes | ||
| axis(p.Results.axesHandle,'tight'); | ||
| set(p.Results.axesHandle,'xtick',[],'ytick',[]); | ||
| colormap(p.Results.axesHandle,p.Results.doseColorMap); | ||
|
|
||
| if isfield(p.Unmatched, 'FontSize') | ||
| matRad_plotAxisLabels(p.Results.axesHandle,p.Results.ct,p.Results.plane,p.Results.slice, p.Unmatched.FontSize, []) | ||
| else | ||
| matRad_plotAxisLabels(p.Results.axesHandle,p.Results.ct,p.Results.plane,p.Results.slice, [], []) | ||
| end | ||
|
|
||
| % Set axis ratio. | ||
| ratios = [1/p.Results.ct.resolution.x 1/p.Results.ct.resolution.y 1/p.Results.ct.resolution.z]; | ||
|
|
||
| set(p.Results.axesHandle,'DataAspectRatioMode','manual'); | ||
| if p.Results.plane == 1 | ||
| res = [ratios(3) ratios(2)]./max([ratios(3) ratios(2)]); | ||
| set(p.Results.axesHandle,'DataAspectRatio',[res 1]) | ||
| elseif p.Results.plane == 2 % sagittal plane | ||
| res = [ratios(3) ratios(1)]./max([ratios(3) ratios(1)]); | ||
| set(p.Results.axesHandle,'DataAspectRatio',[res 1]) | ||
| elseif p.Results.plane == 3 % Axial plane | ||
| res = [ratios(2) ratios(1)]./max([ratios(2) ratios(1)]); | ||
| set(p.Results.axesHandle,'DataAspectRatio',[res 1]) | ||
| end | ||
|
|
||
| %% Set text properties | ||
| if ~isempty(textVarargin) | ||
| set(p.Results.axesHandle, textVarargin{:}) | ||
| set(p.Results.axesHandle.Title, textVarargin{:}) | ||
| end | ||
|
|
||
| end | ||
wahln marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,6 +63,8 @@ | |
| % | ||
| % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
|
|
||
| warning('Deprecation warning: matRad_plotSliceWrapper is deprecated. Using matRad_plot_Slice instead'); | ||
|
||
|
|
||
| % Handle the argument list | ||
| if ~exist('thresh','var') || isempty(thresh) | ||
| thresh = []; | ||
|
|
@@ -101,6 +103,11 @@ | |
|
|
||
| matRad_cfg = MatRad_Config.instance(); | ||
|
|
||
| warning('Deprecation warning: matRad_plotSliceWrapper is deprecated. Using matRad_plot_Slice instead'); | ||
wahln marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| [hCMap,hDose,hCt,hContour,hIsoDose] = matRad_plotSlice(ct, 'axesHandle', axesHandle, 'cst', cst, 'cubeIdx', cubeIdx, 'dose', dose, 'plane', plane, 'slice', slice,'thresh', thresh, 'alpha', alpha, 'contourColorMap', contourColorMap, 'doseColorMap', doseColorMap, 'doseWindow', doseWindow, 'doseIsoLevels', doseIsoLevels, 'voiSelection', voiSelection, 'colorBarLabel', colorBarLabel, 'boolPlotLegend', boolPlotLegend, 'others', varargin); | ||
|
|
||
| %{ | ||
| set(axesHandle,'YDir','Reverse'); | ||
| % plot ct slice | ||
| hCt = matRad_plotCtSlice(axesHandle,ct.cubeHU,cubeIdx,plane,slice); | ||
|
|
@@ -171,6 +178,6 @@ | |
| if ~isempty(colorBarLabel) | ||
| set(get(hCMap,'YLabel'),'String', colorBarLabel,'FontSize',matRad_cfg.gui.fontSize); | ||
| end | ||
|
|
||
| %} | ||
| end | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.