matRad_plotIsoDoseLines3D

Purpose ^

matRad function that plots isolines in 3D, by precomputed contourc data

Synopsis ^

function isoLineHandles = matRad_plotIsoDoseLines3D(axesHandle,ct,doseCube,isoContours,isoLevels,plane,slice,cMap,window,varargin)

Description ^

 matRad function that plots isolines in 3D, by precomputed contourc data 
 computed by matRad_computeIsoDoseContours or manually by calling 
 contourslice itself

 call
   isoLineHandles = matRad_plotIsoDoseLines3D(axesHandle,ct,doseCube,isoContours,isoLevels,plane,slice)
   isoLineHandles = matRad_plotIsoDoseLines3D(axesHandle,ct,doseCube,isoContours,isoLevels,plane,slice,cMap)
   isoLineHandles = matRad_plotIsoDoseLines3D(axesHandle,ct,doseCube,isoContours,isoLevels,plane,slice,window)
   isoLineHandles = matRad_plotIsoDoseLines3D(axesHandle,ct,doseCube,isoContours,isoLevels,plane,slice,cMap,window)
   isoLineHandles = matRad_plotIsoDoseLines3D(axesHandle,ct,doseCube,isoContours,isoLevels,plane,slice,cMap,window, ...)

 input
   axesHandle  handle to axes the slice should be displayed in
   ct          matRad ct struct which contains resolution
   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)
   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

 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.

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Cross-reference information ^

This function calls: This function is called by:

Source code ^

0001 function isoLineHandles = matRad_plotIsoDoseLines3D(axesHandle,ct,doseCube,isoContours,isoLevels,plane,slice,cMap,window,varargin)
0002 % matRad function that plots isolines in 3D, by precomputed contourc data
0003 % computed by matRad_computeIsoDoseContours or manually by calling
0004 % contourslice itself
0005 %
0006 % call
0007 %   isoLineHandles = matRad_plotIsoDoseLines3D(axesHandle,ct,doseCube,isoContours,isoLevels,plane,slice)
0008 %   isoLineHandles = matRad_plotIsoDoseLines3D(axesHandle,ct,doseCube,isoContours,isoLevels,plane,slice,cMap)
0009 %   isoLineHandles = matRad_plotIsoDoseLines3D(axesHandle,ct,doseCube,isoContours,isoLevels,plane,slice,window)
0010 %   isoLineHandles = matRad_plotIsoDoseLines3D(axesHandle,ct,doseCube,isoContours,isoLevels,plane,slice,cMap,window)
0011 %   isoLineHandles = matRad_plotIsoDoseLines3D(axesHandle,ct,doseCube,isoContours,isoLevels,plane,slice,cMap,window, ...)
0012 %
0013 % input
0014 %   axesHandle  handle to axes the slice should be displayed in
0015 %   ct          matRad ct struct which contains resolution
0016 %   doseCube    3D array of the corresponding dose cube
0017 %   isoContours precomputed isodose contours in a cell array {maxDim,3}
0018 %               if the parameter is empty, contours will be plotted the
0019 %               slow way with MATLABs contour function
0020 %   isoLevels   the levels of the isodose (same units as doseCube)
0021 %   plane       plane view (coronal=1,sagittal=2,axial=3)
0022 %   slice       slice in the selected plane of the 3D cube
0023 %   cMap        optional argument defining the colormap, default is jet
0024 %               if you want to use the default map with the window argument
0025 %               you can use an empty array []
0026 %   window      optional argument defining the displayed range. default is
0027 %               [min(doseCube(:)) max(doseCube(:))]
0028 %   varargin    Additional Matlab Line-Property/value pairs
0029 %
0030 % output
0031 %   isoLineHandles: handle to the plotted isolines
0032 %
0033 % References
0034 %   -
0035 %
0036 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0037 %
0038 % Copyright 2015 the matRad development team.
0039 %
0040 % This file is part of the matRad project. It is subject to the license
0041 % terms in the LICENSE file found in the top-level directory of this
0042 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part
0043 % of the matRad project, including this file, may be copied, modified,
0044 % propagated, or distributed except according to the terms contained in the
0045 % LICENSE file.
0046 %
0047 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0048 
0049 matRad_cfg = MatRad_Config.instance();
0050 
0051 %% manage optional arguments
0052 %Use default colormap?
0053 if nargin < 7 || isempty(cMap)
0054     cMap = jet(64);
0055 end
0056 if nargin < 8 || isempty(window)
0057     window = [min(doseCube(:)) max(doseCube(:))];
0058 end
0059 
0060 cMapScale = size(cMap,1) - 1;
0061 isoColorLevel = uint8(cMapScale*(isoLevels - window(1))./(window(2)-window(1)));
0062 
0063 %This circumenvents a bug in Octave when the index in the image hase the maximum value of uint8
0064 if matRad_cfg.isOctave
0065     isoColorLevel(isoColorLevel == 255) = 254;
0066     isoLineHandles = [];
0067 elseif matRad_cfg.isMatlab
0068     isoLineHandles = gobjects(0);
0069 end
0070 
0071 colors = squeeze(ind2rgb(isoColorLevel,cMap));
0072 
0073 slices = {[],[],[]};
0074 
0075 coords{1} = ct.resolution.x * double(1:ct.cubeDim(2));
0076 coords{2} = ct.resolution.y * double(1:ct.cubeDim(1));
0077 coords{3} = ct.resolution.z * double(1:ct.cubeDim(3));
0078 
0079 %slice spacing
0080 spacing = 5;
0081 sliceIndices = [1:spacing:ct.cubeDim(plane)];
0082 if isempty(sliceIndices(sliceIndices==slice))
0083     sliceIndices(end+1) = slice;
0084     sort(sliceIndices);
0085 end
0086 slices{plane} = coords{plane}(sliceIndices);
0087 
0088 %% Plotting
0089 %Check if precomputed contours where passed, if not, calculate it on the
0090 %fly
0091 if isempty(isoContours)
0092     
0093     [xMesh,yMesh,zMesh] = meshgrid(coords{1},coords{2},coords{3});
0094     isoLineHandles = contourslice(axesHandle,xMesh,yMesh,zMesh,doseCube,slices{[1 2 3]},isoLevels);
0095 else  
0096     axes(axesHandle);
0097     hold on;
0098     
0099     for s = 1:numel(sliceIndices)
0100         currSlice = sliceIndices(s);
0101         currSlicePlaneCoords = slices{plane}(s);
0102         
0103         %opacity of the isolines. Will be fully opaque if we are on the
0104         %requested (and shown) slice
0105         if currSlice == slice
0106             opacity = 1;
0107         else
0108             opacity = 0.4;
0109         end
0110         
0111         %Check if there is a contour in the plane
0112         if any(isoContours{currSlice,plane}(:))
0113             % plot precalculated contourc data
0114             lower = 1; % lower marks the beginning of a section
0115             while lower-1 ~= size(isoContours{currSlice,plane},2)
0116                 steps = isoContours{currSlice,plane}(2,lower); % number of elements of current line section
0117                 if numel(unique(isoLevels)) > 1
0118                     color = colors(isoLevels(:) == isoContours{currSlice,plane}(1,lower),:);
0119                 else
0120                     color = unique(colors,'rows');
0121                 end              
0122                 
0123                 % Align 2D Contours in3D
0124                 isoLine2Dx = isoContours{currSlice,plane}(1,lower+1:lower+steps);
0125                 isoLine2Dy = isoContours{currSlice,plane}(2,lower+1:lower+steps);
0126                 if plane == 2
0127                     isoLine3Dx = currSlicePlaneCoords*ones(1,numel(isoLine2Dx));
0128                     isoLine3Dz = interp1(double(1:ct.cubeDim(3)),coords{3},isoLine2Dx);
0129                     isoLine3Dy = interp1(double(1:ct.cubeDim(1)),coords{1},isoLine2Dy);
0130                 elseif plane == 1
0131                     isoLine3Dy = currSlicePlaneCoords*ones(1,numel(isoLine2Dx));
0132                     isoLine3Dx = interp1(double(1:ct.cubeDim(2)),coords{2},isoLine2Dy);
0133                     isoLine3Dz = interp1(double(1:ct.cubeDim(3)),coords{3},isoLine2Dx);
0134                 elseif plane == 3
0135                     isoLine3Dz = currSlicePlaneCoords*ones(1,numel(isoLine2Dx));
0136                     isoLine3Dx = interp1(double(1:ct.cubeDim(2)),coords{2},isoLine2Dx);
0137                     isoLine3Dy = interp1(double(1:ct.cubeDim(1)),coords{1},isoLine2Dy);
0138                 else 
0139                     continue;
0140                 end
0141                
0142                 %We render the isodose lines transparent by adding a fourth color value (undocumented)
0143                 if verLessThan('matlab','8.5')
0144                     isoLineHandles(end+1) = line(isoLine3Dx,isoLine3Dy,isoLine3Dz,'Color',[color        ],'Parent',axesHandle,varargin{:});
0145                 else
0146                     isoLineHandles(end+1) = line(isoLine3Dx,isoLine3Dy,isoLine3Dz,'Color',[color opacity],'Parent',axesHandle,varargin{:});
0147                 end
0148                 %We do not plot labels
0149                 %{
0150                 if plotLabels
0151                     text(isoLine3Dx,isoLine3Dy,isoLine3Dz,num2str(isoContours{currSlice,plane}(1,lower)),'Parent',axesHandle);
0152                 end
0153                 %}
0154                 lower = lower+steps+1;
0155                 
0156             end
0157         end
0158     end
0159     
0160     hold off;
0161 end
0162 
0163 end

| Generated by m2html © 2005