function phaseAngle = getPhase(signal)
% extract from a signal the phase, modulo 8 symmetries

% find zero-crossings
thresh = (max(signal)+min(signal))/2;
state = signal>thresh;
zc = (state([2:end,1]) - state(1:end))~=0;
zci = find(zc)*2*pi/length(signal);

numrots = 20;
lim = pi/2;
rotAngles = linspace(0,lim*(numrots-1)/numrots,numrots);
for i=1:numrots,
	testPhase(rotAngles(i), zci);
	drawnow
end

% fold zci different ways
