function buttonloadRAY(hObject, eventdata, Empty_Button, Buttons, Footnote, AxesD, AxesNMF, AxesAFS, AxesSOL, Datainfo, SVDinfo, Polysettings, usmn, usmf, IPonoff, FPonoff, titles, NMFparameter, NMFinfo, lcs)
data = get(Empty_Button,'UserData');
data.ismatrix = 0;
data.isnmf = 0;
data.isafs = 0;
data.isExpert1 = 0;
data.isExpert2 = 0;
data.isLastClickLockMode = 0;
data.isimport = 0;
data.import = [];
data.plotIP = 0;
data.plotFP = 0;

set(IPonoff(1), 'Value', 0);
set(IPonoff(2), 'Value', 1);

set(FPonoff(1), 'Value', 0);
set(FPonoff(2), 'Value', 1);

set(usmn,'Value',0);
set(usmf,'Value',1);

if data.islv == 1
    Mouse3D_modifiedRAY;
    data.islv = 0;
end


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): ');
set(SVDinfo(6),'String',' s(5): ');

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 canceled.','ForegroundColor','red');
    
    plot(AxesD,1,0,'w');
    plot(AxesNMF,1,0,'w');
    plot(AxesAFS,0,0,'w');
    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');
    onoffButton(Buttons,[],2:11);
    set(Empty_Button,'UserData',data);
    return
else
    k = size(D,1);
    n = size(D,2);
    if min(k,n) < 2
        set(Footnote,'String',[' Warning: no matrix D of bad dimension: ', num2str(k), ' x ', num2str(n)],'ForegroundColor','red');
        onoffButton(Buttons,[],2:11);
        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
    
    tim = cputime;
    
    [U,S,V] = svds(D,min(min(size(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')]);
        if min(k,n) > 3
            set(SVDinfo(5),'String',[' s(4): ',num2str(S(4,4),'%3.3f')]);
            if min(k,n) > 4
                set(SVDinfo(6),'String',[' s(5): ',num2str(S(5,5),'%3.3f')]);
            else
                set(SVDinfo(6),'String',[' s(5):  ---']);
            end
        else
            set(SVDinfo(5),'String',[' s(4):  ---']);
        end
    else
        set(SVDinfo(4),'String',[' s(3):  ---']);
    end
    
    set(titles(5),'String',['file: ', [PathName, FileName]]);
    
    for i=1:size(U,2)
        if -min(V(:,i)) > max(V(:,i))
            U(:,i) = -U(:,i);
            V(:,i) = -V(:,i);
        end
    end
    data.Uraw = U;
    data.Sraw = S;
    data.Vraw = V;
    
    if size(t,2) > size(t,1) t = t';end
    if size(x,2) > size(x,1) x = x';end
    
    data.ismatrix = 1;
    data.Draw = D;
    data.t = t;
    data.x = x;
    
    plot(AxesD,x,data.Draw','k');
    axis(AxesD,'tight');
    yl = get(AxesD,'ylim');
    set(AxesD,'ylim',[min(0,yl(1)), yl(2)*1.1]);
    xlabel(AxesD,'channel');
    
    set(Polysettings(1),'String','1.0e-12');
    set(Polysettings(2),'String','1.0e-3');
    set(Polysettings(3),'String','5000');
    
    onoffButton(Buttons,2:3,4:11);
end

plot(AxesNMF,1,0,'w');
plot(AxesAFS,0,0,'w');
plot(AxesSOL,1,0,'w');

data.s = 4;

set(Empty_Button,'UserData',data);

buttoninitialnmfRAY(hObject, eventdata, Empty_Button, Buttons, Footnote, AxesNMF, AxesAFS, AxesSOL, NMFparameter, NMFinfo, Polysettings, lcs, usmn, usmf, IPonoff);
