%   xy2jpg.m

%   This software is protected by german copyright and international treaties.             
%   Copyright 2004 Markus Junghöfer & Peter Peyk. All Rights Reserved.                     
%                                                                                          
%   THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE        
%   NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,    
%   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE    
%   OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
%   TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT,       
%   INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE      
%   OR DOCUMENTATION.  


DefFilePath=SetDefPath('r','*.xy.*');
[xy,xyFile,xyPath,xyFilePath]=ReadAscii(['Paul:Data:EEG:ET:C1:ET00C1.xy.txt'],'Read xy from file',[],[],[],DefFilePath);
Print2Path='Paul:Data:EEG:ET:C1:Jpg:'
Print2FileCompVal=90;
xy=xy';
                                                                    
NTrials=size(xy,1);
TrialVec=[1:2:NTrials];
NTrials=length(TrialVec);
xy=xy(TrialVec,:);
hFig=figure('Units','normal','Position',[0 .5 .5 .5], 'Name','Calibration:', 'NumberTitle','off');
axes('Units','normal','Position',[0 0 1 1])
for i=1:NTrials
	ImMat=zeros(480,640,3);
	x=xy(i,1); 
	y=481-xy(i,2);
	ImMat(240-3:240+3,320-4:320+4,:)=ones(7,9,3);
	ImMat(y-6:y+6,x-8:x+8,1)=ones(13,17,1);
	image(ImMat);
	axis('off');
	pause(.001)
	CountStr=AddZeros2CountStr(i,3);
	set(hFig,'Name',['x=',int2str(xy(i,1)),'; y=',int2str(xy(i,2)),'; Trial ',int2str(i),' of ',int2str(NTrials),'; ',CountStr,'.jpg'])
	Print2FilePath=[Print2Path,CountStr];
	Print2FileString=['print -djpeg',int2str(Print2FileCompVal),' ',Print2FilePath];
	eval(Print2FileString)
end
