

if true
    %% load up NRRD

    
    load('C:\010-work\003_localGit\WiscPlan_v2\data\PD_HD_dicomPhantom\matlab_files\Geometry.mat')
    
    CTin = Geometry.data;
%     orthoslice(CTin)
    
    ROImap=zeros(size(CTin));
    ROImap(Geometry.ROIS{1, 2}.ind)=1;
    
    doseMap = zeros(size(ROImap));
    for z = 1:size(ROImap, 3)
        doseMap(:,:,z) = bwdist(1-ROImap(:,:,z));
    end
%     orthoslice(doseMap)
    
    matrix = 50* ones(size(CTin))+2* doseMap;
    
%     matrix = 50* ones(size(CTin));
%     temp = 50* ones(size(CTin)) + 2*(max(doseMap(:))-doseMap);
%     matrix(Geometry.ROIS{1, 2}.ind)=temp(Geometry.ROIS{1, 2}.ind);
%     orthoslice(matrix)
    
    
    % save nrrds
    filename = ['C:\010-work\003_localGit\WiscPlan_v2\data\PD_HD_dicomPhantom\Tomo_DP_target.nrrd'];
    pixelspacing = Geometry.voxel_size;
    origin = Geometry.start;
    encoding ='raw'; % 'raw', 'ascii' or 'gzip'

    ok = nrrdWriter(filename, matrix, pixelspacing, origin, encoding)

end
if false
    
    [D_full, w_fin, Geometry, optGoal] = NLP_beamlet_optimizer;
    
    orthoslice(matrix)
    orthoslice(D_full)
    
    colorwash(Geometry.data, matrix, [500, 1500], [0,70])
    colorwash(Geometry.data, D_full, [500, 1500], [0,70])
    
    slice_i = 24;
    
    D_diff = D_full - matrix;
    orthoslice(D_diff)
    
    
end
