matRad function to calculate recalculate HU values from equivalent densities This is done to provide downward compatability to previous matRad versions where HU values were not automatically saved during the import process. HU values can only be calculated if the HLUT is bijective. call ct = matRad_electronDensitiesToHU(ct) input ct: matRad ct struct containing cube and all additional information output ct: ct struct with HU and equivalent density cube 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 ct = matRad_electronDensitiesToHU(ct) 0002 % matRad function to calculate recalculate HU values from equivalent densities 0003 % This is done to provide downward compatability to previous matRad 0004 % versions where HU values were not automatically saved during the 0005 % import process. HU values can only be calculated if the HLUT is 0006 % bijective. 0007 % 0008 % call 0009 % ct = matRad_electronDensitiesToHU(ct) 0010 % 0011 % input 0012 % ct: matRad ct struct containing cube and all additional information 0013 % 0014 % output 0015 % ct: ct struct with HU and equivalent density cube 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 0034 0035 % load hlut 0036 if isfield(ct,'hlut') % if hlut stored upon import use this one! 0037 hlut = ct.hlut; 0038 else 0039 hlut = matRad_loadHLUT(ct); 0040 end 0041 0042 % interpolate rel. electron dens. to HU based on lookup table 0043 if isequal(hlut(:,2),unique(hlut(:,2))) && isequal(hlut(:,1),unique(hlut(:,1))) 0044 0045 for i = 1:ct.numOfCtScen 0046 % Manual adjustments if ct data is corrupt. If some values are out of range 0047 % of the LUT, then these values are adjusted. 0048 if max(ct.cube{i}(:)) > max(hlut(:,2)) 0049 warning('projecting out of range electron density values'); 0050 ct.cube{i}(ct.cube{i}(:) > max(hlut(:,2))) = max(hlut(:,2)); 0051 end 0052 if min(ct.cube{i}(:)) < min(hlut(:,2)) 0053 warning('projecting out of range electron density values'); 0054 ct.cube{i}(ct.cube{i}(:) < min(hlut(:,2))) = min(hlut(:,2)); 0055 end 0056 0057 ct.cubeHU{i} = interp1(hlut(:,2),hlut(:,1),ct.cube{i}); 0058 end 0059 0060 else 0061 fprintf('Reconversion of HU values could not be done because HLUT is not bijective.\n'); 0062 end