0001 function [ct,cst] = matRad_importPatient(ctFile,maskFiles,hlutFilename)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 [cube, metadata] = matRad_readCube(ctFile);
0036
0037 ct = struct();
0038 cst = cell(0,6);
0039
0040 ct.cubeHU{1} = cube;
0041
0042 if nargin == 3
0043 HLUT = matRad_readHLUT(hlutFilename);
0044 ct.cube{1} = interp1(HLUT(:,1),HLUT(:,2),double(cube));
0045 ct.hlut = HLUT;
0046 end
0047
0048 ct.cubeDim = metadata.cubeDim;
0049 ct.resolution.x = metadata.resolution(1);
0050 ct.resolution.y = metadata.resolution(2);
0051 ct.resolution.z = metadata.resolution(3);
0052
0053 ct.numOfCtScen = 1;
0054
0055 maskId = 1;
0056 hGlobalWaitbar = waitbar(0,'Importing Segmentations');
0057 set(findall(hGlobalWaitbar,'type','text'),'Interpreter','none');
0058
0059
0060
0061 for f=1:numel(maskFiles)
0062 maskFile = maskFiles{f};
0063 waitbar(f/numel(maskFiles),hGlobalWaitbar,['Importing Segmentations: ' maskFiles{f}]);
0064 if exist(maskFile,'dir')
0065 contents = dir(maskFile);
0066 hFolderWaitbar = waitbar(0,'Importing Folder');
0067 set(findall(hFolderWaitbar,'type','text'),'Interpreter','none');
0068 for s=1:numel(contents)
0069 waitbar(s/numel(contents),hFolderWaitbar,['Importing Folder: ' contents(s).name]);
0070 if(~contents(s).isdir)
0071 [mask, maskMeta] = matRad_readCube(fullfile(maskFile,contents(s).name));
0072 cstLine = importMaskToCstLine(maskId,mask,maskMeta);
0073 cst = [cst; cstLine];
0074 maskId = maskId + 1;
0075 end
0076 end
0077 delete(hFolderWaitbar);
0078 elseif exist(maskFile,'file')
0079 [mask,maskMeta] = matRad_readCube(maskFile);
0080 cstLine = importMaskToCstLine(maskId,mask,maskMeta);
0081 cst = [cst; cstLine];
0082 maskId = maskId + 1;
0083 else
0084 disp(['Ignored file/dir ' maskFile '!']);
0085 end
0086 end
0087
0088 delete(hGlobalWaitbar);
0089
0090
0091
0092 colors = colorcube(size(cst,1));
0093 for i = 1:size(cst,1)
0094 cst{i,5}.visibleColor = colors(i,:);
0095 end
0096
0097 end
0098
0099 function cstLine = importMaskToCstLine(maskId,mask,maskMeta)
0100 cstLine = cell(1,6);
0101 cstLine{1} = maskId - 1;
0102 cstLine{2} = maskMeta.name;
0103 cstLine{3} = tryToGetVoiTypeByName(maskMeta.name);
0104 cstLine{4}{1} = find(mask > 0);
0105 cstLine{5}.Priority = maskId;
0106 cstLine{5}.alphaX = 0.1;
0107 cstLine{5}.betaX = 0.05;
0108 cstLine{5}.Visible = 1;
0109 end
0110
0111 function type = tryToGetVoiTypeByName(voiName)
0112 targetNames = {'target'; 'ptv'; 'ctv'};
0113 for n=1:numel(targetNames)
0114 found = strfind(lower(voiName),lower(targetNames{n}));
0115 if ~isempty(found)
0116 type = 'TARGET';
0117 return;
0118 end
0119 end
0120 type = 'OAR';
0121 end
0122
0123