function humaneDVH(planName245cm,planName0625cm) addpath('C:\Documents and Settings\Steve\My Documents\Research\matlab') addpath('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqUtil') addpath('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input') Ndvhbins = 1000; %number of dvh bins %prescTumor = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003linPrescVol\PTV70DosePlus.bin'); %open prescription in Matlab %prescTumor = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003rootPrescVol\PTV70DosePlus.bin'); prescTumor = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003quadPrescVol\PTV70DosePlus.bin'); %prescTumor = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003gompPrescVol\PTV70DosePlus.bin'); prescNormal = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003uniPrescVolNew\NormalDosePlus.bin'); prescLarynx = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003uniPrescVolNew\larynxDosePlus.bin'); prescRt = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003uniPrescVolNew\RtparotidDosePlus.bin'); prescLt = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003uniPrescVolNew\LtparotidDosePlus.bin'); prescCord = open_presc('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\input\HN003uniPrescVolNew\CordDosePlus.bin'); %dim = 1; %2D dim = 30; %3D fid = fopen(planName245cm,'rb'); %open plans in Matlab plan245cm = reshape(fread(fid,'float'),72,72,dim); fclose(fid); fid = fopen(planName0625cm,'rb'); %open plans in Matlab plan0625cm = reshape(fread(fid,'float'),72,72,dim); fclose(fid); for i=1:prescNormal.Nind; prescNormal.non_zero_values(i)=1; end for i=1:prescLarynx.Nind; prescLarynx.non_zero_values(i)=1; end for i=1:prescRt.Nind; prescRt.non_zero_values(i)=1; end for i=1:prescLt.Nind; prescLt.non_zero_values(i)=1; end for i=1:prescCord.Nind; prescCord.non_zero_values(i)=1; end tumorMask = single(~~(full3D(prescTumor))); %define tissue masks normalMask = single(~~(full3D(prescNormal))); larynxMask = single(~~(full3D(prescLarynx))); rtMask = single(~~(full3D(prescRt))); ltMask = single(~~(full3D(prescLt))); cordMask = single(~~(full3D(prescCord))); tumorDose245cm = plan245cm.*tumorMask; %dose distributions in each ROI tumorDose0625cm = plan0625cm.*tumorMask; normalDose245cm = plan245cm.*normalMask; normalDose0625cm = plan0625cm.*normalMask; larynxDose245cm = plan245cm.*larynxMask; larynxDose0625cm = plan0625cm.*larynxMask; rtDose245cm = plan245cm.*rtMask; rtDose0625cm = plan0625cm.*rtMask; ltDose245cm = plan245cm.*ltMask; ltDose0625cm = plan0625cm.*ltMask; cordDose245cm = plan245cm.*cordMask; cordDose0625cm = plan0625cm.*cordMask; tumorDoseSparse245cm = sparse3D(tumorDose245cm); %convert 3D matrices to sparse matrices tumorDoseSparse0625cm = sparse3D(tumorDose0625cm); normalDoseSparse245cm = sparse3D(normalDose245cm); normalDoseSparse0625cm = sparse3D(normalDose0625cm); larynxDoseSparse245cm = sparse3D(larynxDose245cm); larynxDoseSparse0625cm = sparse3D(larynxDose0625cm); rtDoseSparse245cm = sparse3D(rtDose245cm); rtDoseSparse0625cm = sparse3D(rtDose0625cm); ltDoseSparse245cm = sparse3D(ltDose245cm); ltDoseSparse0625cm = sparse3D(ltDose0625cm); cordDoseSparse245cm = sparse3D(cordDose245cm); cordDoseSparse0625cm = sparse3D(cordDose0625cm); tumorNormDose245cm = ((tumorDoseSparse245cm.non_zero_values)./(prescTumor.non_zero_values)); %calculate equivalent uniform dose tumorAverageDose245cm = mean(prescTumor.non_zero_values); tumorEdose245cm = tumorNormDose245cm.*tumorAverageDose245cm; tumorNormDose0625cm = ((tumorDoseSparse0625cm.non_zero_values)./(prescTumor.non_zero_values)); %calculate equivalent uniform dose tumorAverageDose0625cm = mean(prescTumor.non_zero_values); tumorEdose0625cm = tumorNormDose0625cm.*tumorAverageDose245cm; tumorPrescNorm = ((prescTumor.non_zero_values)./(prescTumor.non_zero_values)); tumorAverageDose = mean(prescTumor.non_zero_values); tumorPrescEdose = tumorPrescNorm.*tumorAverageDose; % NON UNIFORM PRESCRIPTIONS TO NORMAL TISSUE AND OAR % normalNormDose = ((normalDoseSparse.non_zero_values)./(prescNormal.non_zero_values)); % normalAverageDose = mean(normalDoseSparse.non_zero_values); % normalEdose = normalNormDose.*normalAverageDose; % % eyesNormDose = ((eyesDoseSparse.non_zero_values)./(prescEyes.non_zero_values)); % eyesAverageDose = mean(eyesDoseSparse.non_zero_values); % eyesEdose = eyesNormDose.*eyesAverageDose; dMax = 1.1*max(tumorEdose245cm); dvhbins = [0:Ndvhbins-1]*dMax/Ndvhbins; dHistTumor245cm = histc(tumorEdose245cm,dvhbins); dHistTumor0625cm = histc(tumorEdose0625cm,dvhbins); dHistPrescEdose = histc(tumorPrescEdose,dvhbins); % dHistNormal = histc(normalEdose,dvhbins); % dHistEyes = histc(eyesEdose,dvhbins); dHistTumor = histc(tumorDoseSparse245cm.non_zero_values,dvhbins); dHistTumor2 = histc(tumorDoseSparse0625cm.non_zero_values,dvhbins); dHistPresc = histc(prescTumor.non_zero_values,dvhbins); dHistNormal245cm = histc(normalDoseSparse245cm.non_zero_values,dvhbins); dHistNormal0625cm = histc(normalDoseSparse0625cm.non_zero_values,dvhbins); dHistLarynx245cm = histc(larynxDoseSparse245cm.non_zero_values,dvhbins); dHistLarynx0625cm = histc(larynxDoseSparse0625cm.non_zero_values,dvhbins); dHistRt245cm = histc(rtDoseSparse245cm.non_zero_values,dvhbins); dHistRt0625cm = histc(rtDoseSparse0625cm.non_zero_values,dvhbins); dHistLt245cm = histc(ltDoseSparse245cm.non_zero_values,dvhbins); dHistLt0625cm = histc(ltDoseSparse0625cm.non_zero_values,dvhbins); dHistCord245cm = histc(cordDoseSparse245cm.non_zero_values,dvhbins); dHistCord0625cm = histc(cordDoseSparse0625cm.non_zero_values,dvhbins); dHistTumorNorm245cm = 100*dHistTumor245cm./(double(tumorDoseSparse245cm.Nind)); dHistTumorNorm0625cm = 100*dHistTumor0625cm./(double(tumorDoseSparse0625cm.Nind)); dHistNormalNorm245cm = 100*dHistNormal245cm./(double(normalDoseSparse245cm.Nind)); dHistNormalNorm0625cm = 100*dHistNormal0625cm./(double(normalDoseSparse0625cm.Nind)); dHistLarynxNorm245cm = 100*dHistLarynx245cm./(double(larynxDoseSparse245cm.Nind)); dHistLarynxNorm0625cm = 100*dHistLarynx0625cm./(double(larynxDoseSparse0625cm.Nind)); dHistRtNorm245cm = 100*dHistRt245cm./(double(rtDoseSparse245cm.Nind)); dHistRtNorm0625cm = 100*dHistRt0625cm./(double(rtDoseSparse0625cm.Nind)); dHistLtNorm245cm = 100*dHistLt245cm./(double(ltDoseSparse245cm.Nind)); dHistLtNorm0625cm = 100*dHistLt0625cm./(double(ltDoseSparse0625cm.Nind)); dHistCordNorm245cm = 100*dHistCord245cm./(double(cordDoseSparse245cm.Nind)); dHistCordNorm0625cm = 100*dHistCord0625cm./(double(cordDoseSparse0625cm.Nind)); dHistTumor = 100*dHistTumor/(prescTumor.Nind); dHistTumor2 = 100*dHistTumor2/(prescTumor.Nind); dHistPresc = 100*dHistPresc/(prescTumor.Nind); dHistPrescEdose = 100*dHistPrescEdose/(prescTumor.Nind); DVHtumor = flipud(cumsum(flipud(dHistTumor))); DVHtumor2 = flipud(cumsum(flipud(dHistTumor))); DVHpresc = flipud(cumsum(flipud(dHistPresc))); DVHprescEdose = flipud(cumsum(flipud(dHistPrescEdose))); DVHtumor245cm = flipud(cumsum(flipud(dHistTumorNorm245cm))); DVHtumor0625cm = flipud(cumsum(flipud(dHistTumorNorm0625cm))); DVHnormal245cm = flipud(cumsum(flipud(dHistNormalNorm245cm))); DVHnormal0625cm = flipud(cumsum(flipud(dHistNormalNorm0625cm))); DVHlarynx245cm = flipud(cumsum(flipud(dHistLarynxNorm245cm))); DVHlarynx0625cm = flipud(cumsum(flipud(dHistLarynxNorm0625cm))); DVHrt245cm = flipud(cumsum(flipud(dHistRtNorm245cm))); DVHrt0625cm = flipud(cumsum(flipud(dHistRtNorm0625cm))); DVHlt245cm = flipud(cumsum(flipud(dHistLtNorm245cm))); DVHlt0625cm = flipud(cumsum(flipud(dHistLtNorm0625cm))); DVHcord245cm = flipud(cumsum(flipud(dHistCordNorm245cm))); DVHcord0625cm = flipud(cumsum(flipud(dHistCordNorm0625cm))); humanfigure(dvhbins,DVHtumor245cm,DVHtumor0625cm) % %DVHnormal245cm,DVHnormal0625cm,DVHlarynx245cm,DVHlarynx0625cm,DVHrt245cm,DVHrt0625cm,DVHlt245cm,DVHlt0625cm,DVHcord245cm,DVHcord0625cm) end