|  | @@ -12,18 +12,15 @@ ROI_idxList = unique(ROI_idxList);
 | 
	
		
			
				|  |  |  %% add idx lists for each goal!
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  beamlet_batch_filename = [patient_dir '\' 'batch_dose.bin'];
 | 
	
		
			
				|  |  | -beamlet_cell_array = read_ryan_beamlets(beamlet_batch_filename, 'ryan');
 | 
	
		
			
				|  |  | +% beamlet_cell_array = read_ryan_beamlets(beamlet_batch_filename, 'ryan');
 | 
	
		
			
				|  |  | +beamlet_cell_array = read_ryan_beamlets(beamlet_batch_filename, 'peter', ROI_idxList);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  numVox  = numel(Geometry.data);
 | 
	
		
			
				|  |  |  numBeamlet = size(beamlet_cell_array,2);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -if size(Geometry.data, 1)<129
 | 
	
		
			
				|  |  | -    batchSize = 400;
 | 
	
		
			
				|  |  | -else
 | 
	
		
			
				|  |  | -    batchSize = 200;
 | 
	
		
			
				|  |  | -end
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +batchSize = 200;
 | 
	
		
			
				|  |  |  beamlets = get_beamlets2(beamlet_cell_array, numVox, batchSize, ROI_idxList);
 | 
	
		
			
				|  |  | +% beamlets = beamlet_cell_array;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  % --- join beamlets into beams
 | 
	
		
			
				|  |  |  % load([patient_dir '\all_beams.mat'])
 | 
	
		
			
				|  |  |  % beamletOrigin=[0 0 0];
 | 
	
	
		
			
				|  | @@ -58,9 +55,13 @@ function beamlets = get_beamlets2(beamlet_cell_array, numVox, batchSize, ROI_idx
 | 
	
		
			
				|  |  |      beamlets = sparse(0, 0);
 | 
	
		
			
				|  |  |      for beam_i=1:numBeam
 | 
	
		
			
				|  |  |          % for each beam define how much dose it delivers on each voxel
 | 
	
		
			
				|  |  | -        idx=beamlet_cell_array{1, beam_i}.non_zero_indices;
 | 
	
		
			
				|  |  | +%         idx=beamlet_cell_array{1, beam_i}.non_zero_indices;
 | 
	
		
			
				|  |  | +%         [ROI_idxIntersect, ia, ~] = intersect (idx, ROI_idxList);
 | 
	
		
			
				|  |  | +%         if ~isequal(ROI_idxIntersect,idx)
 | 
	
		
			
				|  |  | +%             warning('this')
 | 
	
		
			
				|  |  | +%         end
 | 
	
		
			
				|  |  |          
 | 
	
		
			
				|  |  | -        [ROI_idxIntersect, ia, ~] = intersect (idx, ROI_idxList);
 | 
	
		
			
				|  |  | +        ROI_idxIntersect = beamlet_cell_array{1, beam_i}.non_zero_indices;
 | 
	
		
			
				|  |  |          
 | 
	
		
			
				|  |  |          if isempty(ROI_idxIntersect)
 | 
	
		
			
				|  |  |              warning(['Beamlet ' num2str(beam_i) ' is empty!'])
 | 
	
	
		
			
				|  | @@ -73,7 +74,7 @@ function beamlets = get_beamlets2(beamlet_cell_array, numVox, batchSize, ROI_idx
 | 
	
		
			
				|  |  |          end
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  %         beamlet_batch(idx, beam_i_temp) = 1000*beamlet_cell_array{1, beam_i}.non_zero_values;
 | 
	
		
			
				|  |  | -        beamlet_batch(ROI_idxIntersect, beam_i_temp) = beamlet_cell_array{1, beam_i}.non_zero_values(ia);
 | 
	
		
			
				|  |  | +        beamlet_batch(ROI_idxIntersect, beam_i_temp) = beamlet_cell_array{1, beam_i}.non_zero_values;
 | 
	
		
			
				|  |  |          waitbar(beam_i/numBeam, wbar1, ['Adding beamlet array: #', num2str(beam_i)])
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          % add the batch to full set when filled
 |