matRad function that plots the contours of the segmentations given in cst call voiContourHandles = matRad_plotVoiContourSlice(axesHandle,cst,ct,ctIndex,selection,plane,slice) voiContourHandles = matRad_plotVoiContourSlice(axesHandle,cst,ct,ctIndex,selection,plane,slice,cMap) voiContourHandles = matRad_plotVoiContourSlice(axesHandle,cst,ct,ctIndex,selection,plane,slice,cMap,...) input axesHandle handle to axes the slice should be displayed in cst matRad cst cell array ct matRad ct structure ctIndex index of the ct cube selection logicals defining the current selection of contours that should be plotted. Can be set to [] to plot all non-ignored 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 colorcube varargin Additional Matlab Line-Property/value pairs output voiContourHandles: handles of the plotted contours visibleOnSlice: logicals defining if the contour is actually visible on the current slice 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 [voiContourHandles] = matRad_plotVoiContourSlice(axesHandle,cst,ct,ctIndex,selection,plane,slice,cMap,varargin) 0002 % matRad function that plots the contours of the segmentations given in cst 0003 % 0004 % call 0005 % voiContourHandles = matRad_plotVoiContourSlice(axesHandle,cst,ct,ctIndex,selection,plane,slice) 0006 % voiContourHandles = matRad_plotVoiContourSlice(axesHandle,cst,ct,ctIndex,selection,plane,slice,cMap) 0007 % voiContourHandles = matRad_plotVoiContourSlice(axesHandle,cst,ct,ctIndex,selection,plane,slice,cMap,...) 0008 % 0009 % input 0010 % axesHandle handle to axes the slice should be displayed in 0011 % cst matRad cst cell array 0012 % ct matRad ct structure 0013 % ctIndex index of the ct cube 0014 % selection logicals defining the current selection of contours 0015 % that should be plotted. Can be set to [] to plot 0016 % all non-ignored contours. 0017 % plane plane view (coronal=1,sagittal=2,axial=3) 0018 % slice slice in the selected plane of the 3D cube 0019 % cMap optional argument defining the colormap, default is 0020 % colorcube 0021 % varargin Additional Matlab Line-Property/value pairs 0022 % 0023 % output 0024 % voiContourHandles: handles of the plotted contours 0025 % visibleOnSlice: logicals defining if the contour is actually 0026 % visible on the current slice 0027 % 0028 % References 0029 % - 0030 % 0031 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0032 % 0033 % Copyright 2015 the matRad development team. 0034 % 0035 % This file is part of the matRad project. It is subject to the license 0036 % terms in the LICENSE file found in the top-level directory of this 0037 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part 0038 % of the matRad project, including this file, may be copied, modified, 0039 % propagated, or distributed except according to the terms contained in the 0040 % LICENSE file. 0041 % 0042 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0043 0044 [env, ~] = matRad_getEnvironment(); 0045 0046 % overwrite colormap 0047 if exist('cMap', 'var') && ~isempty(cMap) 0048 cMapScale = size(cMap,1)-1; 0049 %determine colors 0050 colors = cMap(round(linspace(1,cMapScale,size(cst,1))),:); 0051 else 0052 for i = 1:size(cst,1) 0053 if isfield(cst{i,5},'visibleColor') 0054 colors(i,:) = cst{i,5}.visibleColor; 0055 else 0056 colors(i,:) = [0 0 0]; 0057 end 0058 end 0059 end 0060 0061 if isempty(selection) || numel(selection) ~= size(cst,1) 0062 selection = true(size(cst,1),1); 0063 end 0064 0065 voiContourHandles = cell(0); 0066 switch env 0067 case 'MATLAB' 0068 voiContourHandles = gobjects(0); 0069 case 'OCTAVE' 0070 voiContourHandles = []; 0071 end 0072 0073 0074 for s = 1:size(cst,1) 0075 0076 if ~strcmp(cst{s,3},'IGNORED') && selection(s) 0077 %Check for precalculated contours 0078 C =[]; 0079 if size(cst,2) >= 7 && ~isempty(cst{s,7}) 0080 C = cst{s,7}{slice,plane}; 0081 else 0082 %If we do not have precomputed contours available, then compute them 0083 mask = zeros(size(ct{ctIndex})); 0084 mask(cst{s,4}{ctIndex}) = 1; 0085 0086 if plane == 1 && any(any(mask(slice,:,:) > 0)) 0087 C = contourc(squeeze(mask(slice,:,:)),.5*[1 1]); 0088 elseif plane == 2 && any(any(mask(:,slice,:) > 0)) 0089 C = contourc(squeeze(mask(:,slice,:)),.5*[1 1]); 0090 elseif plane == 3 && any(any(mask(:,:,slice) > 0)) 0091 C = contourc(squeeze(mask(:,:,slice)),.5*[1 1]); 0092 end 0093 end 0094 0095 % plot precalculated contourc data 0096 0097 switch env 0098 case 'MATLAB' 0099 tmpLineHandle = gobjects(0); 0100 case 'OCTAVE' 0101 tmpLineHandle = []; 0102 end 0103 0104 if any(C(:)) 0105 lower = 1; % lower marks the beginning of a section 0106 while lower-1 ~= size(C,2) 0107 hold on 0108 steps = C(2,lower); % number of elements of current line section 0109 tmpLineHandle(end+1) = line(C(1,lower+1:lower+steps),... 0110 C(2,lower+1:lower+steps),... 0111 'Color',colors(s,:),'Parent',axesHandle,varargin{:}); 0112 0113 lower = lower+steps+1; 0114 end 0115 voiContourHandles{end+1} = tmpLineHandle; 0116 else 0117 % create empty line object 0118 voiContourHandles{end+1} = {}; 0119 end 0120 0121 0122 end 0123 end 0124 0125 0126 end