function importanovadata

%   importanovadata

%   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.                                                                      
%   This software is protected by german copyright and international treaties.             
%   Copyright 2004 Markus Junghöfer & Peter Peyk. All Rights Reserved.                                                                                         

global hPlot3dMenuFig hPlot2dMenuFig 
hPlot3dList=get(hPlot3dMenuFig,'Userdata'); 
hList=get(hPlot2dMenuFig,'Userdata'); 

uigettextfigure = findobj('tag','uigettextfigure');
uiwait(errordlg(char('Please note that the data file must be a textfile, containing one headerrow and exactly as many following rows as your number of subjects!'...
        ,'The first column must contain the subject numbers (without non-numerical characters (e.g. ''13'', not ''subj13''))!','The decimal separator must be a dot, not a komma!'),'Data import:'));
[sourcefilename,sourcefilepath] = uigetfile('*.*','Please choose data file:');
sourcefile = [sourcefilepath,sourcefilename];
data = textread(sourcefile,'','headerlines',1,'emptyvalue',0,'whitespace',' \t\b\n');
data = data(:,2:end);
if sum(data(:,end)==0)==length(data(:,end))
    data(:,end)=[];
end
nrofsubjects = size(data,1);
nrofcolumns = size(data,2);
message = '';
message = char(message,'Data imported:');
message = char(message,[num2str(nrofsubjects),' subjects (rows) and ',num2str(nrofcolumns),' columns!']);
uiwait(msgbox(message,'Data import:'));

hanovadata = findobj('tag','hanovadata');
set(hanovadata,'userdata',data);
if ~isempty(hPlot3dList) 
   set(hPlot3dList(133),'userdata',data);
end
data = data
return
