%% get_peturbed_image_beamlets



patientData_path= 'C:\010-work\003_localGit\WiscPlan_v2\data\PatientData';
load([patientData_path '\matlab_files\Geometry.mat']);

Geometry_old=Geometry;
clear Geometry

% do the data shift
shift=[0, 0];

valShift=1.30;

Geometry.data = imtranslate(Geometry_old.data, shift);
Geometry.rhomw = imtranslate(Geometry_old.rhomw, shift);
Geometry.Smw = imtranslate(Geometry_old.Smw, shift);
Geometry.Fmw2 = imtranslate(Geometry_old.Fmw2, shift);

Geometry.BTV = imtranslate(Geometry_old.BTV, shift);
Geometry.Ring = imtranslate(Geometry_old.Ring, shift);

Geometry.voxel_size = Geometry_old.voxel_size;
Geometry.start = Geometry_old.start;



Geometry.data = valShift*Geometry.data;
Geometry.rhomw = valShift*Geometry.rhomw;
Geometry.Smw = valShift*Geometry.Smw;
Geometry.Fmw2 = valShift*Geometry.Fmw2;


numROI = size(Geometry_old.ROIS, 2);
for i=1:numROI
    ind1 = Geometry_old.ROIS{i}.ind;
    Geometry.ROIS{i}.name = Geometry_old.ROIS{i}.name;
    
    canvas1 = zeros(size(Geometry.data));
    canvas1(ind1)=1;
%     canvas2 = imtranslate(canvas1, shift);
    canvas2 = canvas1;
    ind2=find(canvas2);
    Geometry.ROIS{i}.ind = ind2;
end


mkdir([patientData_path '\perturbed_output'])
mkdir([patientData_path '\perturbed_output\kernelfiles'])
copyfile([patientData_path '\kernelfiles\*'], [patientData_path '\perturbed_output\kernelfiles\'])
mkdir([patientData_path '\perturbed_output\matlab_files'])

save([patientData_path '\perturbed_output\matlab_files\Geometry.mat'], 'Geometry')

helicalDosecalcSetup7([patientData_path '\perturbed_output'])

%       merge_beamlets(4, [patientData_path '\perturbed_output']);

