matRad function that plots isolines, by precomputed contourc data computed by matRad_computeIsoDoseContours or manually by calling contourc itself call isoLineHandles = matRad_plotIsoDoseLines(axesHandle,doseCube,isoContours,isoLevels,plotLabels,plane,slice,cMap) isoLineHandles = matRad_plotIsoDoseLines(axesHandle,doseCube,isoContours,isoLevels,plotLabels,plane,slice,window) isoLineHandles = matRad_plotIsoDoseLines(axesHandle,doseCube,isoContours,isoLevels,plotLabels,plane,slice,cMap,window) isoLineHandles = matRad_plotIsoDoseLines(axesHandle,doseCube,isoContours,isoLevels,plotLabels,plane,slice,cMap,window, ...) input axesHandle handle to axes the slice should be displayed in doseCube 3D array of the corresponding dose cube isoContours precomputed isodose contours in a cell array {maxDim,3} if the parameter is empty, contours will be plotted the slow way with MATLABs contour function isoLevels the levels of the isodose (same units as doseCube) plotLabels if set to true labels will be added to the contours plane plane view (coronal=1,sagittal=2,axial=3) slice slice in the selected plane of the 3D cube cMap optional argument defining the colormap, default is jet if you want to use the default map with the window argument you can use an empty array [] window optional argument defining the displayed range. default is [min(doseCube(:)) max(doseCube(:))] varargin Additional MATLAB Line-Property/Value-Pairs etc. output isoLineHandles: handle to the plotted isolines 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/LICENSES.txt. 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. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function isoLineHandles = matRad_plotIsoDoseLines(axesHandle,doseCube,isoContours,isoLevels,plotLabels,plane,slice,cMap,window,varargin) 0002 % matRad function that plots isolines, by precomputed contourc data 0003 % computed by matRad_computeIsoDoseContours or manually by calling contourc 0004 % itself 0005 % 0006 % call 0007 % isoLineHandles = matRad_plotIsoDoseLines(axesHandle,doseCube,isoContours,isoLevels,plotLabels,plane,slice,cMap) 0008 % isoLineHandles = matRad_plotIsoDoseLines(axesHandle,doseCube,isoContours,isoLevels,plotLabels,plane,slice,window) 0009 % isoLineHandles = matRad_plotIsoDoseLines(axesHandle,doseCube,isoContours,isoLevels,plotLabels,plane,slice,cMap,window) 0010 % isoLineHandles = matRad_plotIsoDoseLines(axesHandle,doseCube,isoContours,isoLevels,plotLabels,plane,slice,cMap,window, ...) 0011 % 0012 % input 0013 % axesHandle handle to axes the slice should be displayed in 0014 % doseCube 3D array of the corresponding dose cube 0015 % isoContours precomputed isodose contours in a cell array {maxDim,3} 0016 % if the parameter is empty, contours will be plotted the 0017 % slow way with MATLABs contour function 0018 % isoLevels the levels of the isodose (same units as doseCube) 0019 % plotLabels if set to true labels will be added to the contours 0020 % plane plane view (coronal=1,sagittal=2,axial=3) 0021 % slice slice in the selected plane of the 3D cube 0022 % cMap optional argument defining the colormap, default is jet 0023 % if you want to use the default map with the window argument 0024 % you can use an empty array [] 0025 % window optional argument defining the displayed range. default is 0026 % [min(doseCube(:)) max(doseCube(:))] 0027 % varargin Additional MATLAB Line-Property/Value-Pairs etc. 0028 % 0029 % output 0030 % isoLineHandles: handle to the plotted isolines 0031 % 0032 % References 0033 % - 0034 % 0035 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0036 % 0037 % Copyright 2015 the matRad development team. 0038 % 0039 % This file is part of the matRad project. It is subject to the license 0040 % terms in the LICENSE file found in the top-level directory of this 0041 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part 0042 % of the matRad project, including this file, may be copied, modified, 0043 % propagated, or distributed except according to the terms contained in the 0044 % LICENSE file. 0045 % 0046 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0047 0048 matRad_cfg = MatRad_Config.instance(); 0049 0050 %% manage optional arguments 0051 %Use default colormap? 0052 if nargin < 8 || isempty(cMap) 0053 cMap = jet(64); 0054 end 0055 if nargin < 9 || isempty(window) 0056 window = [min(doseCube(:)) max(doseCube(:))]; 0057 end 0058 0059 %Check if precomputed contours where passed, if not, calculate it on the 0060 %fly 0061 if isempty(isoContours) 0062 if plane == 1 0063 C = contourc(doseCube(slice,:,:),isoLevels); 0064 elseif plane == 2 0065 C = contourc(doseCube(:,slice,:),isoLevels); 0066 elseif plane == 3 0067 C = contourc(doseCube(:,:,slice),isoLevels); 0068 end 0069 isoContours{slice,plane} = C; 0070 end 0071 0072 %% Plotting 0073 cMapScale = size(cMap,1) - 1; 0074 0075 isoColorLevel = uint8(cMapScale*(isoLevels - window(1))./(window(2)-window(1))); 0076 0077 %This circumenvents a bug in Octave when the index in the image hase the maximum value of uint8 0078 if matRad_cfg.isOctave 0079 isoColorLevel(isoColorLevel == 255) = 254; 0080 isoLineHandles = []; 0081 0082 elseif matRad_cfg.isMatlab 0083 isoLineHandles = gobjects(0); 0084 end 0085 0086 colors = squeeze(ind2rgb(isoColorLevel,cMap)); 0087 0088 axes(axesHandle); 0089 hold on; 0090 0091 %Check if there is a contour in the plane 0092 if any(isoContours{slice,plane}(:)) 0093 % plot precalculated contourc data 0094 0095 lower = 1; % lower marks the beginning of a section 0096 while lower-1 ~= size(isoContours{slice,plane},2) 0097 steps = isoContours{slice,plane}(2,lower); % number of elements of current line section 0098 if numel(unique(isoLevels)) > 1 0099 color = colors(isoLevels(:) == isoContours{slice,plane}(1,lower),:); 0100 else 0101 color = unique(colors,'rows'); 0102 end 0103 isoLineHandles(end+1) = line(isoContours{slice,plane}(1,lower+1:lower+steps),... 0104 isoContours{slice,plane}(2,lower+1:lower+steps),... 0105 'Color',color,'Parent',axesHandle,varargin{:}); 0106 if plotLabels 0107 text(isoContours{slice,plane}(1,lower+1),... 0108 isoContours{slice,plane}(2,lower+1),... 0109 num2str(isoContours{slice,plane}(1,lower)),'Parent',axesHandle) 0110 end 0111 lower = lower+steps+1; 0112 0113 end 0114 end 0115 0116 hold off; 0117 0118 end