% 01/25/2015
% use [xc,yc,R] = cirfit(x,y) to find the center and the diameter of the track
% let the headstage go around the track

% beep at the beginning of the tracking
fs_sin=8000;
fs0=800;
t=0 : 1/fs_sin : 0.1;
beep0 = sin(fs0*2*pi*t);

fprintf('Start tracking: ');
pause(20);
% drop the old data
[~, ~, locationArray, ~, VTRecsReturned, ~] = NlxGetNewVTData(vt_acq_ent);
sound(beep0,fs_sin);
pause(20);
[~, ~, locationArray, ~, VTRecsReturned, ~] = NlxGetNewVTData(vt_acq_ent);
sound(beep0,fs_sin);

x_circle=double(locationArray(1:2:end-1))*scale_x;
y_circle=(-1)*double(locationArray(2:2:end))*scale_y;
ind=find(x_circle>0.1); % exclude missing data
x_circle=x_circle(ind);
y_circle=y_circle(ind);

[x_center,y_center,R_inner] = cirfit(x_circle,y_circle);
diam_inner=R_inner*2;

fprintf('center: %s , %s, \r',num2str(x_center),num2str(y_center));