function loadButton(hObject, eventdata, Empty_Button, Buttons,AFS,LockMode, Footnote, AxesD, AxesAFS, AxesSOL, Datainfo, SVDinfo,EPSinfo,AFSinfo, Polysettings,borg,one_x, usmn, usmf, titles)
data = get(Empty_Button,'UserData');
data.ismatrix = 0;
data.isnmf = 0;
data.isafs = 0;
data.isExpert1 = 0;
data.isExpert2 = 0;
data.isLastClickLockMode = 0;
data.Borgen=1;
data.Polygon=0;

set(usmn,'Value',0);
set(usmf,'Value',1);
set(borg,'Value',1);
set(one_x,'Value',0);
set(titles(5),'String','filename');

set(Datainfo(2),'String',' spectra: ');
set(Datainfo(3),'String',' channels: ');

set(SVDinfo(2),'String',' s(1): ');
set(SVDinfo(3),'String',' s(2): ');
set(SVDinfo(4),'String',' s(3): ');
set(SVDinfo(5),'String',' s(4): ');

if ispc
    dlm = '\';
else
    dlm = '/';
end

if isfield(data,'PathName') == 0
    actpwd = pwd;
    if strcmp(actpwd(end-9:end), 'subfcnsAFS') == 1
        data.PathName = actpwd(1:end-10);
    else
        
        data.PathName = [pwd, dlm];
    end
end

actpwd = pwd;
cd(data.PathName);
[FileName,PathName,FilterIndex] = uigetfile('*.mat','Select *.mat file including the data Matrix D');
cd(actpwd);

if FilterIndex == 0
    set(hObject,'UserData',data);
    set(Footnote,'String',' Warning: data loading process cancelled.','ForegroundColor','red');
    
    hold(AxesD,'off');
    plot(AxesD,1,0,'w');
    hold(AxesAFS,'off');
    plot(AxesAFS,0,0,'w');
    hold(AxesSOL,'off');
    plot(AxesSOL,1,0,'w');
    set(Empty_Button,'UserData',data);
    return
end
data.FileName = FileName;
data.PathName = PathName;

load([PathName FileName]);
if ~exist('D')
    set(Footnote,'String',[' Warning: no matrix D in file "',FileName,'"'],'ForegroundColor','red');
    set(Empty_Button,'UserData',data);
    return
else
    data.D0=D;
    
    
    data.ismatrix = 1;
    k = size(D,1);
    n = size(D,2);
    
    
    
    if min(k,n) < 2
        set(Footnote,'String',[' Warning: matrix D of bad dimension: ', num2str(k), ' x ', num2str(n)],'ForegroundColor','red');
        onoffButton(Buttons,[],2:8);
        
        set(Empty_Button,'UserData',data);
        return
    end
    
    if (~exist('t')) && (exist('T')) && (max(size(T)) == k) && (min(size(T)) == 1)
        t = T;
    elseif (~exist('t')) || (max(size(t)) ~= k) || (min(size(t)) ~= 1)
        t = 0:k-1;
    end
    
    if (~exist('x')) && (exist('X')) && (max(size(X)) == n) && (min(size(X)) == 1)
        x = X;
    elseif (~exist('x')) || (max(size(x)) ~= n) || (min(size(x)) ~= 1)
        x = 0:n-1;
    end
    
    
    for i=1:k
        col_pos=0;
        col_neg=0;
        for j=1:n
            if D(i,j)>0
                col_pos=col_pos+D(i,j);
            else
                col_neg=col_neg-D(i,j);
            end
        end
        if 2*col_neg>col_pos
            set(Footnote,'String',[' Warning: too small ratio between sum of negative entries and sum of positive entries in a column of D', num2str(k), ' x ', num2str(n)],'ForegroundColor','red');
            onoffButton(Buttons,[],2:8);
            
            set(Empty_Button,'UserData',data);
            return
        end
    end
    
    
    
    tim = cputime;
    [U,S,V] = svds(D,6);
    tim = cputime-tim;
    
    set(Footnote,'String',['svds-computation-time:  ',num2str(tim),' s'],'ForegroundColor','black');
    
    set(Datainfo(2),'String',[' spectra: ',num2str(size(D,1))]);
    set(Datainfo(3),'String',[' channels: ',num2str(size(D,2))]);
    
    set(SVDinfo(2),'String',[' s(1): ',num2str(S(1,1),'%3.3f')]);
    set(SVDinfo(3),'String',[' s(2): ',num2str(S(2,2),'%3.3f')]);
    if min(k,n) > 2
        set(SVDinfo(4),'String',[' s(3): ',num2str(S(3,3),'%3.3f')]);
    else
        set(SVDinfo(4),'String',[' s(3):  ---']);
    end
    if min(k,n) > 3
        set(SVDinfo(5),'String',[' s(4): ',num2str(S(4,4),'%3.3f')]);
    else
        set(SVDinfo(5),'String',[' s(4):  ---']);
    end;
    
    Dtrunc=U(:,1:3)*S(1:3,1:3)*V(:,1:3)';
    data.D_scal=[];
    data.Uraw = U(:,1:3);
    data.Sraw = S(1:3,1:3);
    data.Vraw = V(:,1:3);
    data.Dtrunc=Dtrunc;
    [k,n]=size(D);
    e = ones(n,1);
    
    
  
    for i = 1:k
        if max(data.D0(i,:))>1.0e-12
            data.D_scal(i,:)=Dtrunc(i,:)/(Dtrunc(i,:)*e);
        else
           data.D_scal(i,:)=zeros(1,n);
           data.Dtrunc(i,:)=zeros(1,n);
       end
    end

    [data.U_scal,data.S_scal,data.V_scal]=svds(data.D_scal,3);
    data.sum_v1=ones(1,size(data.V_scal,1))*data.V_scal(:,1);
    data.sum_v2=ones(1,size(data.V_scal,1))*data.V_scal(:,2);
    data.sum_v3=ones(1,size(data.V_scal,1))*data.V_scal(:,3);
    
    
    [data.U_scal,data.S_scal,data.V_scal]=svds(data.D_scal,3);
    
    
    
    for i=1:3
        if -min(data.V_scal(:,i))>max(data.V_scal(:,i))
            data.V_scal(:,i)=-data.V_scal(:,i);
            data.U_scal(:,i)=-data.U_scal(:,i);
        end
    end
    
    for i=1:3
        if -min(data.Vraw(:,i))>max(data.Vraw(:,i))
            data.Vraw(:,i)=-data.Vraw(:,i);
            data.Uraw(:,i)=-data.Uraw(:,i);
        end
    end
    
    if size(t,2) > size(t,1) t = t';end
    if size(x,2) > size(x,1) x = x';end
    
    data.ismatrix = 1;
    data.isafs=0;
    data.Draw = Dtrunc;
    data.t = t;
    data.x = x;
    
    plot(AxesD,x,data.Draw','k');
    axis(AxesD,'tight');
    yl = get(AxesD,'ylim');
    xlabel(AxesD,'channel');
    
    
    
    set(AFSinfo(2),'String',['pts. T-bnd.: ']);
    set(AFSinfo(3),'String',['pts. T-bnd.: ']);
    [m,n]=size(data.Draw);

    if min(min(data.D0))>-1.0e-14 && min(k,n)>3 && S(4,4)<1.0e-12
    
         minD=0;
    else
    minD=min(min(data.D_scal));
    if minD<0
        minD=min(-10^(-8),minD);
    end
    if abs(minD)<1.0e-14
        minD=0;
    end
    end
    
    data.EPSd=minD;
    set(EPSinfo(2),'String',[num2str(0)]);
    
    if minD>=0
        set(EPSinfo(1),'String',[' min(A): ',num2str(0)]);
        set(EPSinfo(3),'String',[num2str(0)]);
        data.EPSa=0;
        data.EPSa=0;
        
        
    else
        set(EPSinfo(1),'String',[' min(A): ',num2str(minD)]);
        minD=ceil(-minD*10^6)/10^6;
        data.EPSa=minD;
        data.EPSc=0.000001;
        minA=max([minD 1e-4]);
        set(EPSinfo(3),'String',[num2str(minA)]);
        set(EPSinfo(2),'String',[num2str(1e-8)]);
    end
end

if (isfield(data,'ismatrix') == 0) || (data.ismatrix == 1)
    onoffButton_BKP(Buttons,2:3,4:8);
    onoffButton_BKP(AFS,[],1:3);
end
onoffButton_BKP(LockMode,[],2:5);

hold(AxesAFS,'off');
plot(AxesAFS,0,0,'w');

hold(AxesSOL,'off');
plot(AxesSOL,1,0,'w');
data.polygon=0;
data.Borgen=1;

data.isExpert1=0;
data.isExpert2=0;

data.AFSL_B=[];
data.AFSL2_B=[];
data.AFSL_SV=[];
data.AFSL2_SV=[];
data.numb_segmentsL2=[];
data.numb_segmentsL2=0;
data.numb_segmentsL=[];
data.numb_segmentsL=0;
set(Empty_Button,'UserData',data);

set(titles(5),'String',['file: ', [PathName FileName]]);

set(Empty_Button,'UserData',data)