function varargout = reseteegviewer(varargin)

%   reseteegviewer

%   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.                                                                      

% EEGVIEWER Application M-file for eegviewer.fig
%    FIG = EEGVIEWER launch eegviewer GUI.
%    EEGVIEWER('callback_name', ...) invoke the named callback.

% Last Modified by GUIDE v2.0 04-Aug-2003 08:07:55



if nargin == 0  % LAUNCH GUI
    
    close(findobj('tag','eegviewer'));
    clear all;
    global datamat NChan NEvents NPoints axeshandles channelscaling ampscaling timescaling timewindow lowerlimit
	%figure
	%--------------
	fig = openfig('eegviewer.fig','new');
	handles = guihandles(fig);
	guidata(fig, handles);
    ampscaling = 1;
    channelscaling = 1;
    
	if nargout > 0
		varargout{1} = fig;
	end

elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK
    global datamat NChan NEvents NPoints axeshandles channelscaling ampscaling timescaling timewindow lowerlimit
	try
		if (nargout)
            evalstring='[varargout{1:nargout}] = feval(varargin{1}';
            for j=2:nargin
                if ~isnumeric(varargin{j}) & exist(varargin{j})==1
                    evalstring=[evalstring,',eval(varargin{',num2str(j),'})'];
                elseif isstr(varargin{j})
                    evalstring=[evalstring,',varargin{',num2str(j),'}'];
                elseif isnumeric(varargin{j})
                    evalstring=[evalstring,',',num2str(varargin{j})];
                end
            end
            evalstring=[evalstring,');'];
            eval(evalstring);
            
            for i=2:nargout
                if ~isstr(varargout{i})
                    eval([varargout{1}{i-1},'=',num2str(varargout{i}),';']);
                else
                    eval([varargout{1}{i-1},'=',char(39),num2str(varargout{i}),char(39),';']);
                end
            end
            
		else
            evalstring='feval(varargin{1}';
            for j=2:nargin
                if isstr(varargin{j})
                    evalstring=[evalstring,',varargin{',num2str(j),'}'];
                elseif isnumeric(varargin{j})
                    evalstring=[evalstring,',',num2str(varargin{j})];
                end
            end
            evalstring=[evalstring,');'];
            eval(evalstring);
		end
        
        
	catch
		disp(lasterr);
	end

end



