matRad_plotCtSlice

Purpose ^

matRad function that generates the plot for the CT in the GUI

Synopsis ^

function [ctHandle,cMap,window] = matRad_plotCtSlice(axesHandle,ctCube,cubeIdx,plane,slice,cMap,window)

Description ^

 matRad function that generates the plot for the CT in the GUI 
 The function can also be used in personal matlab figures by passing the
 corresponding axes handle

 call
   [ctHandle,cMap,window] = matRad_plotCtSlice(axesHandle,ctCube,cubeIdx,plane,slice)
   [ctHandle,cMap,window] = matRad_plotCtSlice(axesHandle,ctCube,cubeIdx,plane,slice,cMap)
   [ctHandle,cMap,window] = matRad_plotCtSlice(axesHandle,ctCube,cubeIdx,plane,slice,window)
   [ctHandle,cMap,window] = matRad_plotCtSlice(axesHandle,ctCube,cubeIdx,plane,slice,cMap,window)

 input
   axesHandle  handle to axes the slice should be displayed in
   ctCube      the cell of ct cubes
   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
   cMap        optional argument defining the colormap, default is bone
               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(ctCube(:)) max(ctCube(:))]

 output
   ctHandle    handle of the plotted CT 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.

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

Cross-reference information ^

This function calls: This function is called by:

Source code ^

0001 function [ctHandle,cMap,window] = matRad_plotCtSlice(axesHandle,ctCube,cubeIdx,plane,slice,cMap,window)
0002 % matRad function that generates the plot for the CT in the GUI
0003 % The function can also be used in personal matlab figures by passing the
0004 % corresponding axes handle
0005 %
0006 % call
0007 %   [ctHandle,cMap,window] = matRad_plotCtSlice(axesHandle,ctCube,cubeIdx,plane,slice)
0008 %   [ctHandle,cMap,window] = matRad_plotCtSlice(axesHandle,ctCube,cubeIdx,plane,slice,cMap)
0009 %   [ctHandle,cMap,window] = matRad_plotCtSlice(axesHandle,ctCube,cubeIdx,plane,slice,window)
0010 %   [ctHandle,cMap,window] = matRad_plotCtSlice(axesHandle,ctCube,cubeIdx,plane,slice,cMap,window)
0011 %
0012 % input
0013 %   axesHandle  handle to axes the slice should be displayed in
0014 %   ctCube      the cell of ct cubes
0015 %   cubeIdx     Index of the desired cube in the ct struct
0016 %   plane       plane view (coronal=1,sagittal=2,axial=3)
0017 %   slice       slice in the selected plane of the 3D cube
0018 %   cMap        optional argument defining the colormap, default is bone
0019 %               if you want to use the default map with the window argument
0020 %               you can use an empty array []
0021 %   window      optional argument defining the displayed range. default is
0022 %               [min(ctCube(:)) max(ctCube(:))]
0023 %
0024 % output
0025 %   ctHandle    handle of the plotted CT axes
0026 %   cMap        used colormap (same as input if set)
0027 %   window      used window (same as input if set)
0028 %
0029 % References
0030 %   -
0031 %
0032 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0033 %
0034 % Copyright 2015 the matRad development team.
0035 %
0036 % This file is part of the matRad project. It is subject to the license
0037 % terms in the LICENSE file found in the top-level directory of this
0038 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part
0039 % of the matRad project, including this file, may be copied, modified,
0040 % propagated, or distributed except according to the terms contained in the
0041 % LICENSE file.
0042 %
0043 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0044 
0045 matRad_cfg = MatRad_Config.instance();
0046 
0047 %Use default colormap?
0048 if nargin < 6 || isempty(cMap)
0049     cMap = bone(64);
0050 end
0051 
0052 if nargin < 7 || isempty(window)
0053     window = [min(ctCube{cubeIdx}(:)) max(ctCube{cubeIdx}(:))];    
0054 end
0055 
0056 cMapScale = size(cMap,1) - 1;
0057 
0058 %Prepare the slice and convert it to uint8
0059 if plane == 1 % Coronal plane
0060     ctIndexed = uint8(cMapScale*(squeeze((ctCube{cubeIdx}(slice,:,:)-window(1))/(window(2) - window(1)))));      
0061 elseif plane == 2 % sagittal plane
0062     ctIndexed = uint8(cMapScale*(squeeze((ctCube{cubeIdx}(:,slice,:)-window(1))/(window(2) - window(1)))));    
0063 elseif plane == 3 % Axial plane
0064     ctIndexed = uint8(cMapScale*(squeeze((ctCube{cubeIdx}(:,:,slice)-window(1))/(window(2) - window(1)))));
0065 else
0066     matRad_cfg.dispError('Invalid plane ''%d'' selected for visualization!',plane);
0067 end
0068 
0069 %This circumenvents a bug in Octave when the index in the image hase the maximum value of uint8
0070 if matRad_cfg.isOctave
0071     ctIndexed(ctIndexed == 255) = 254;
0072 end
0073 
0074 ct_rgb = ind2rgb(ctIndexed,cMap);
0075 
0076 ctHandle = image('CData',ct_rgb,'Parent',axesHandle);
0077 
0078 end
0079

| Generated by m2html © 2005