doseGradDiscretePhantom.m 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. addpath('C:\Documents and Settings\Steve\My Documents\Research\matlab')
  2. addpath('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqUtil')
  3. for i=1:3
  4. for j=1:1
  5. for k=1:3
  6. for m=1:1
  7. folder = (['C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\tomo\phantrad' num2str(i-1) ...
  8. '\boostrad' num2str(j-1) '\contrast' num2str(k-1) '\a' num2str(m-1) '\input']);
  9. cd(folder)
  10. presc = open_presc(['TumorMinusBoostDosePlus.bin']);
  11. Nstep = 20;
  12. dpresc = (max(presc.non_zero_values)-min(presc.non_zero_values))./Nstep;
  13. minpresc = min(presc.non_zero_values);
  14. ind = {};
  15. for n=1:Nstep;
  16. ind{n} = find(presc.non_zero_values >= (n-1)*dpresc + minpresc ...
  17. & presc.non_zero_values < n*dpresc + minpresc);
  18. presc.non_zero_values(ind{n}) = mean(presc.non_zero_values(ind{n}));
  19. end
  20. fid = fopen(['TumorMinusBoostDosePlus.bin'],'wb');
  21. fwrite(fid,presc.x_count,'int');
  22. fwrite(fid,presc.y_count,'int');
  23. fwrite(fid,presc.z_count,'int');
  24. fwrite(fid,presc.Nind,'int32');
  25. fwrite(fid,presc.non_zero_indices,'int32');
  26. fwrite(fid,presc.non_zero_values,'single');
  27. fclose(fid);
  28. fid = fopen(['TumorMinusBoostDoseMinus.bin'],'wb');
  29. fwrite(fid,presc.x_count,'int');
  30. fwrite(fid,presc.y_count,'int');
  31. fwrite(fid,presc.z_count,'int');
  32. fwrite(fid,presc.Nind,'int32');
  33. fwrite(fid,presc.non_zero_indices,'int32');
  34. fwrite(fid,presc.non_zero_values,'single');
  35. fclose(fid);
  36. end
  37. end
  38. end
  39. end
  40. fprintf(['Prescription discretized into ' num2str(Nstep) ' steps successfully.\n'])