matRad_convRtssContours2Indices

Purpose ^

matRad function to convert a polygon segmentation from an rt structure

Synopsis ^

function indices = matRad_convRtssContours2Indices(structure,ct)

Description ^

 matRad function to convert a polygon segmentation from an rt structure
 set into a binary segmentation as required within matRad's cst struct
 
 call
   indices = matRad_convRtssContours2Indices(contPoints,ct)

 input
   structure:      information about a single structure
   ct:             matRad ct struct where the binary segmentations will
                   be aligned to

 output
   indicies:       indices of voxels of the ct cube that are inside the
                   contour

 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 indices = matRad_convRtssContours2Indices(structure,ct)
0002 % matRad function to convert a polygon segmentation from an rt structure
0003 % set into a binary segmentation as required within matRad's cst struct
0004 %
0005 % call
0006 %   indices = matRad_convRtssContours2Indices(contPoints,ct)
0007 %
0008 % input
0009 %   structure:      information about a single structure
0010 %   ct:             matRad ct struct where the binary segmentations will
0011 %                   be aligned to
0012 %
0013 % output
0014 %   indicies:       indices of voxels of the ct cube that are inside the
0015 %                   contour
0016 %
0017 % References
0018 %   -
0019 %
0020 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0021 %
0022 % Copyright 2015 the matRad development team.
0023 %
0024 % This file is part of the matRad project. It is subject to the license
0025 % terms in the LICENSE file found in the top-level directory of this
0026 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part
0027 % of the matRad project, including this file, may be copied, modified,
0028 % propagated, or distributed except according to the terms contained in the
0029 % LICENSE file.
0030 %
0031 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0032 
0033 voiCube = zeros(ct.cubeDim);
0034 
0035 % loop over all closed contour items
0036 for i = 1:size(structure.item,2)
0037 
0038     if ~isempty(structure.item(i).points)
0039 
0040         dicomCtSlicePos = unique(structure.item(i).points(:,3));
0041         
0042         if numel(dicomCtSlicePos) > 1
0043             error('Contour defined over multiple planes\n');
0044         end
0045     
0046         round2 = @(a,b) round(a*10^b)/10^b;
0047         dicomCtSliceThickness = ct.dicomInfo.SliceThickness(round2(ct.dicomInfo.SlicePositions,1)==round2(dicomCtSlicePos,1));
0048         
0049         coords1 = interp1(ct.x,1:ct.cubeDim(2),structure.item(i).points(:,1),'linear','extrap');
0050         coords2 = interp1(ct.y,1:ct.cubeDim(1),structure.item(i).points(:,2),'linear','extrap');
0051         
0052         binIn = poly2mask(coords1,coords2,ct.cubeDim(1),ct.cubeDim(2));
0053         
0054         slicesInMatradCt = find(dicomCtSlicePos+dicomCtSliceThickness/2 > ct.z & dicomCtSlicePos-dicomCtSliceThickness/2 <= ct.z);
0055 
0056         % loop over all slices in matRad ct
0057         for j = 1:numel(slicesInMatradCt)
0058             voiCube(:,:,slicesInMatradCt(j)) = voiCube(:,:,slicesInMatradCt(j)) | binIn;
0059         end
0060         
0061     end
0062     
0063 end
0064 
0065 indices = find(voiCube(:));

| Generated by m2html © 2005