matRad function that generates a dose plot of a selected slice in 3D view call [doseHandle,cMap,window] = matRad_plotDose3DSlice(axesHandle, doseCube,plane,slice,threshold) [doseHandle,cMap,window] = matRad_plotDose3DSlice(axesHandle, doseCube,plane,slice,threshold,alpha) [doseHandle,cMap,window] = matRad_plotDose3DSlice(axesHandle, doseCube,plane,slice,threshold,cMap) [doseHandle,cMap,window] = matRad_plotDose3DSlice(axesHandle, doseCube,plane,slice,threshold,window) [doseHandle,cMap,window] = matRad_plotDose3DSlice(axesHandle, doseCube,plane,slice,threshold,alpha,cMap) [doseHandle,cMap,window] = matRad_plotDose3DSlice(axesHandle, doseCube,plane,slice,threshold,alpha,window) [doseHandle,cMap,window] = matRad_plotDose3DSlice(axesHandle, doseCube,plane,slice,threshold,cMap,window) [doseHandle,cMap,window] = matRad_plotDose3DSlice(axesHandle, doseCube,plane,slice,threshold,alpha,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 dose to select the slice from plane plane view (coronal=1,sagittal=2,axial=3) slice slice in the selected plane of the 3D cube threshold threshold above which the dose shall be displayed for negative values (i.e. difference maps), also the values smaller than the negative threshold will be displayed if empty, no threshold will be applied alpha optional argument defining the alpha value, default is 0.6. To use the default when providing a custom culormap, put in an empty array by []. 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(:))] output doseHandle: handle of the plotted dose axes cMap used colormap (same as input if set) window used window (same as input if set) 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 [doseHandle,cMap,window] = matRad_plotDoseSlice3D(axesHandle,ct,doseCube,plane,slice,threshold,alpha,cMap,window) 0002 % matRad function that generates a dose plot of a selected slice in 3D view 0003 % 0004 % call 0005 % [doseHandle,cMap,window] = matRad_plotDose3DSlice(axesHandle, doseCube,plane,slice,threshold) 0006 % [doseHandle,cMap,window] = matRad_plotDose3DSlice(axesHandle, doseCube,plane,slice,threshold,alpha) 0007 % [doseHandle,cMap,window] = matRad_plotDose3DSlice(axesHandle, doseCube,plane,slice,threshold,cMap) 0008 % [doseHandle,cMap,window] = matRad_plotDose3DSlice(axesHandle, doseCube,plane,slice,threshold,window) 0009 % [doseHandle,cMap,window] = matRad_plotDose3DSlice(axesHandle, doseCube,plane,slice,threshold,alpha,cMap) 0010 % [doseHandle,cMap,window] = matRad_plotDose3DSlice(axesHandle, doseCube,plane,slice,threshold,alpha,window) 0011 % [doseHandle,cMap,window] = matRad_plotDose3DSlice(axesHandle, doseCube,plane,slice,threshold,cMap,window) 0012 % [doseHandle,cMap,window] = matRad_plotDose3DSlice(axesHandle, doseCube,plane,slice,threshold,alpha,cMap,window) 0013 % 0014 % input 0015 % axesHandle handle to axes the slice should be displayed in 0016 % ct matRad CT struct which contains resolution 0017 % doseCube 3D array of the dose to select the slice from 0018 % plane plane view (coronal=1,sagittal=2,axial=3) 0019 % slice slice in the selected plane of the 3D cube 0020 % threshold threshold above which the dose shall be displayed 0021 % for negative values (i.e. difference maps), also the values 0022 % smaller than the negative threshold will be displayed 0023 % if empty, no threshold will be applied 0024 % alpha optional argument defining the alpha value, default is 0.6. 0025 % To use the default when providing a custom culormap, put in 0026 % an empty array by []. 0027 % cMap optional argument defining the colormap, default is jet 0028 % if you want to use the default map with the window argument 0029 % you can use an empty array [] 0030 % window optional argument defining the displayed range. default is 0031 % [min(doseCube(:)) max(doseCube(:))] 0032 % 0033 % output 0034 % doseHandle: handle of the plotted dose axes 0035 % cMap used colormap (same as input if set) 0036 % window used window (same as input if set) 0037 % 0038 % References 0039 % - 0040 % 0041 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0042 % 0043 % Copyright 2015 the matRad development team. 0044 % 0045 % This file is part of the matRad project. It is subject to the license 0046 % terms in the LICENSE file found in the top-level directory of this 0047 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part 0048 % of the matRad project, including this file, may be copied, modified, 0049 % propagated, or distributed except according to the terms contained in the 0050 % LICENSE file. 0051 % 0052 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0053 0054 matRad_cfg = MatRad_Config.instance(); 0055 0056 %Use default colormap? 0057 if nargin < 8 || isempty(cMap) 0058 cMap = jet(64); 0059 end 0060 if nargin < 7 || isempty(alpha) 0061 alpha = 0.6; 0062 end 0063 if nargin < 9 || isempty(window) 0064 window = [min(doseCube(:)) max(doseCube(:))]; 0065 end 0066 0067 cMapScale = size(cMap,1) - 1; 0068 maxDose = max(doseCube(:)); 0069 0070 %Create the coordinates 0071 coords{1} = ct.resolution.x * (1:ct.cubeDim(2)); 0072 coords{2} = ct.resolution.y * (1:ct.cubeDim(1)); 0073 coords{3} = ct.resolution.z * (1:ct.cubeDim(3)); 0074 0075 if plane == 1 % Coronal plane 0076 [xMesh,zMesh] = meshgrid(coords{2},coords{3}); 0077 yMesh = slice*ct.resolution.x*ones(size(xMesh)); 0078 %dose_slice = uint8(cMapScale*(squeeze(doseCube(slice,:,:)) - window(1))/(window(2)-window(1))); 0079 doseSlice = permute(squeeze(doseCube(slice,:,:)),[2 1]); 0080 elseif plane == 2 % sagittal plane 0081 [yMesh,zMesh] = meshgrid(coords{1},coords{3}); 0082 xMesh = slice*ct.resolution.y*ones(size(yMesh)); 0083 %dose_slice = uint8(cMapScale*(squeeze(doseCube(:,slice,:)) - window(1))/(window(2)-window(1))); 0084 dose_slice = permute(squeeze(doseCube(:,slice,:)),[2 1]); 0085 elseif plane == 3 % Axial plane 0086 [xMesh,yMesh] = meshgrid(coords{2},coords{1}); 0087 zMesh = slice*ct.resolution.z*ones(size(xMesh)); 0088 %dose_slice = uint8(cMapScale*(squeeze(doseCube(:,:,slice)) - window(1))/(window(2)-window(1))); 0089 dose_slice = squeeze(doseCube(:,:,slice)); 0090 end 0091 0092 if ~isempty(threshold) 0093 dose_mask = alpha * (dose_slice < window(2) & dose_slice > window(1) & dose_slice > threshold*maxDose); 0094 else 0095 dose_mask = alpha * (dose_slice < window(2) & dose_slice > window(1)); 0096 end 0097 0098 dose_slice = uint8(cMapScale* (dose_slice - window(1))/(window(2)-window(1))); 0099 0100 %This circumenvents a bug in Octave when the index in the image hase the maximum value of uint8 0101 if matRad_cfg.isOctave 0102 dose_slice(dose_slice == 255) = 254; 0103 end 0104 0105 dose_rgb = ind2rgb(dose_slice,cMap); 0106 % slice plot with surface(...), colormapping can be done by texture 0107 % mapping, this is why we use surface instead of slice 0108 doseHandle = surface('XData',xMesh, 'YData',yMesh, 'ZData',zMesh,'AlphaData',dose_mask, ... 0109 'CData',dose_rgb, 'CDataMapping','direct', ... 0110 'EdgeColor','none', 'FaceColor','texturemap', 'BackFaceLighting','unlit','FaceLighting','flat','FaceAlpha','texture','Parent',axesHandle); 0111 0112 end 0113 0114