

if true
    %% load up NRRD

    [petIn, meta] = nrrdread('C:\010-work\003_localGit\WiscPlan_v2\data\CDP_data\CDP5_PET.nrrd');
    [segIn, meta] = nrrdread('C:\010-work\003_localGit\WiscPlan_v2\data\CDP_data\CDP5_SEG.nrrd');

    segIdx = find(segIn);
    
    matrix = 0.4*60 + 0.6*(70/0.03)*petIn;
%     matrix = 40 + 0*petIn;
    
    [X,Y,Z] = meshgrid(1:size(petIn, 1),1:size(petIn, 2),1:size(petIn, 3));
    Y_vox = Y(segIdx);
    matrix = 60*ones(size(Y));
    matrix(segIdx) = 60 + 5*(mean(Y_vox)-Y(segIdx));
    
%     orthoslice(matrix)
    
    % save nrrds
    filename = ['C:\010-work\003_localGit\WiscPlan_v2\data\CDP_data\CDP5_DP_target.nrrd'];
    pixelspacing = meta.spacedirections;
    origin = meta.spaceorigin;
    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
