function  a = AdjustChiAngle(bandData, numberBins, numberAngleSets)

numberAngleSets = numberAngleSets * 6;

for j = 5:6:numberAngleSets
		% Find base chi angle to start with
	
	for i=1:numberBins
		if bandData(i,j) >= -90 & bandData(i,j) <= 90
			baseChiAngle = bandData(i,j);
			istart = i + 1;
			break;
			end;
			
		end;	% for i=1:numberBins
	
	for i=istart:numberBins
		
			if abs( bandData(i,j) - baseChiAngle) > 100
				if baseChiAngle < 0
					if bandData(i,j) > 0
						bandData(i,j) = bandData(i,j) - 180;
						end;
					
				else	% baseChiAngle > 0
					if bandData(i,j) < 0
						bandData(i,j) = bandData(i,j) + 180;
						end;
					
				end;		% if baseChiAngle < 0, else...
				
				end;	% if abs( bandData(i,j) - baseChiAngle) > 100
				
			baseChiAngle = bandData(i,j);
			
		end;	% for i=1:numberBins
			
	end;	% for j = 5:6:numberAngleSets

a = bandData;
