matRad_interpDicomCtCube

Purpose ^

matRad function to interpolate a 3D ct cube to a different resolution

Synopsis ^

function interpCt = matRad_interpDicomCtCube(origCt, origCtInfo, resolution, grid)

Description ^

 matRad function to interpolate a 3D ct cube to a different resolution

 call
   interpCt = matRad_interpDicomCtCube(origCt, origCtInfo, resolution)
   interpCt = matRad_interpDicomCtCube(origCt, origCtInfo, resolution, grid)

 input
   origCt:         original CT as matlab 3D array
   origCtInfo:     meta information about the geometry of the orgiCt cube
   resolution:     target resolution [mm] in x, y, an z direction for the
                   new cube
   grid:           optional: externally specified grid vector

 output
   interpCt:       interpolated ct cube as matlab 3D array

 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 interpCt = matRad_interpDicomCtCube(origCt, origCtInfo, resolution, grid)
0002 % matRad function to interpolate a 3D ct cube to a different resolution
0003 %
0004 % call
0005 %   interpCt = matRad_interpDicomCtCube(origCt, origCtInfo, resolution)
0006 %   interpCt = matRad_interpDicomCtCube(origCt, origCtInfo, resolution, grid)
0007 %
0008 % input
0009 %   origCt:         original CT as matlab 3D array
0010 %   origCtInfo:     meta information about the geometry of the orgiCt cube
0011 %   resolution:     target resolution [mm] in x, y, an z direction for the
0012 %                   new cube
0013 %   grid:           optional: externally specified grid vector
0014 %
0015 % output
0016 %   interpCt:       interpolated ct cube as matlab 3D array
0017 %
0018 % References
0019 %   -
0020 %
0021 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0022 %
0023 % Copyright 2015 the matRad development team.
0024 %
0025 % This file is part of the matRad project. It is subject to the license
0026 % terms in the LICENSE file found in the top-level directory of this
0027 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part
0028 % of the matRad project, including this file, may be copied, modified,
0029 % propagated, or distributed except according to the terms contained in the
0030 % LICENSE file.
0031 %
0032 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0033 
0034 coordsOfFirstPixel = [origCtInfo.ImagePositionPatient];
0035 
0036 % set up grid vectors
0037 x = coordsOfFirstPixel(1,1) + origCtInfo(1).ImageOrientationPatient(1) * ...
0038                               origCtInfo(1).PixelSpacing(1)*double([0:origCtInfo(1).Columns-1]);
0039 y = coordsOfFirstPixel(2,1) + origCtInfo(1).ImageOrientationPatient(5) * ...
0040                               origCtInfo(1).PixelSpacing(2)*double([0:origCtInfo(1).Rows-1]);
0041 z = coordsOfFirstPixel(3,:);
0042 
0043 if exist('grid','var')
0044     xq = grid{1};
0045     yq = grid{2};
0046     zq = grid{3};
0047     
0048     % calculate intersection of regions to avoid interpolation issues
0049     xqRe = coordsOfFirstPixel(1,1):origCtInfo(1).ImageOrientationPatient(1)*resolution.x: ...
0050         (coordsOfFirstPixel(1,1)+origCtInfo(1).ImageOrientationPatient(1)*origCtInfo(1).PixelSpacing(1)*double(origCtInfo(1).Columns-1));
0051     yqRe = [coordsOfFirstPixel(2,1):origCtInfo(1).ImageOrientationPatient(5)*resolution.y: ...
0052         (coordsOfFirstPixel(2,1)+origCtInfo(1).ImageOrientationPatient(5)*origCtInfo(1).PixelSpacing(2)*double(origCtInfo(1).Rows-1))];
0053     zqRe = coordsOfFirstPixel(3,1):resolution.z: coordsOfFirstPixel(3,end);
0054     
0055     % cut values
0056     xq(xq < min(xqRe)) = [];
0057     xq(xq > max(xqRe)) = [];
0058     yq(yq < min(yqRe)) = [];
0059     yq(yq > max(yqRe)) = [];
0060     zq(zq < min(zqRe)) = [];
0061     zq(zq > max(zqRe)) = [];
0062 else
0063     xq = coordsOfFirstPixel(1,1):origCtInfo(1).ImageOrientationPatient(1)*resolution.x: ...
0064         (coordsOfFirstPixel(1,1)+origCtInfo(1).ImageOrientationPatient(1)*origCtInfo(1).PixelSpacing(1)*double(origCtInfo(1).Columns-1));
0065     yq = [coordsOfFirstPixel(2,1):origCtInfo(1).ImageOrientationPatient(5)*resolution.y: ...
0066         (coordsOfFirstPixel(2,1)+origCtInfo(1).ImageOrientationPatient(5)*origCtInfo(1).PixelSpacing(2)*double(origCtInfo(1).Rows-1))];
0067     zq = coordsOfFirstPixel(3,1):resolution.z: coordsOfFirstPixel(3,end);
0068 end
0069 
0070 % set up grid matrices - implicit dimension permuation (X Y Z-> Y X Z)
0071 % Matlab represents internally in the first matrix dimension the
0072 % ordinate axis and in the second matrix dimension the abscissas axis
0073 [ X,  Y,  Z] = meshgrid(x,y,z);
0074 [Xq, Yq, Zq] = meshgrid(xq,yq,zq);
0075 
0076 % interpolate cube - cube is now stored in Y X Z
0077 interpCt.cubeIV{1} = interp3(X,Y,Z,double(origCt),Xq,Yq,Zq);
0078 
0079 % some meta information
0080 interpCt.resolution = resolution;
0081 
0082 interpCt.x = xq;
0083 interpCt.y = yq;
0084 interpCt.z = zq;
0085 
0086 interpCt.cubeDim     = [numel(yq) numel(xq) numel(zq)];
0087 interpCt.numOfCtScen = 1;

| Generated by m2html © 2005