function buttoninitialnmfRAY(hObject, eventdata, Empty_Button, Buttons, Footnote, AxesNMF, AxesAFS, AxesSOL, NMFparameter, NMFinfo, Polysettings, lcs, usmn, usmf, IPonoff)
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(usmn,'Value',0);
set(usmf,'Value',1);

data = get(Empty_Button,'UserData');
if (isfield(data,'ismatrix') == 0) || (data.ismatrix == 0)
    set(Footnote,'String',' Warning, no data has been loaded.','ForegroundColor','red');
    return;
end

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

data.z = getsetvar(NMFparameter(2), data.s, min([size(data.Draw) 5]), 1, 0);

singv = diag(data.Sraw);
if singv(2)/singv(1)-1 > -1.E-15
    str = ['No NMF computed: matrix D^TD is reducible, ',char(963),'(1)/',char(963),'(2)-1 = ', num2str(singv(2)/singv(1)-1,'%3.3e'),'.'];
    set(Footnote,'String',str,'ForegroundColor','red');
    
    plot(AxesNMF,1,0,'w');
    plot(AxesAFS,0,0,'w');
    plot(AxesSOL,1,0,'w');
    
    onoffButton(Buttons,[],4:11);
    return;
end
posSV = [];
for i=2:data.z
    mi = min(data.Vraw(:,i));
    if (mi > 0) || (-mi < 1.E-16*max(data.Vraw(:,i)))
        posSV = [posSV, i];
    end
end

if isempty(posSV) == 0
    str = 'Warning: matrix D^TD is reducible, positive singular vectors: 1';
    for i=1:length(posSV)
        str = [str, ', ', num2str(posSV(i))];
    end
    set(Footnote,'String',[str, '.'],'ForegroundColor','red');
    
    plot(AxesNMF,1,0,'w');
    plot(AxesAFS,0,0,'w');
    plot(AxesSOL,1,0,'w');
    
    onoffButton(Buttons,[],4:11);
    return;
end

set(Footnote,'String',' C routine in progress ... (press CTRL + C in the command window to cancel) ...','ForegroundColor','k');
fprintf(' C routine (NMF) in progress ... (press CTRL + C to cancel) ... ');

set(hObject,'Enable','off');
[data.InitT,tim,suc,data.D,data.U,data.S,data.V] = computeinitialnmfRAY(data.Draw,...
    data.s,data.Uraw,data.Sraw,data.Vraw, data.z, data.calcp);
set(hObject,'Enable','on');

if suc == -3
    fprintf('computation canceled.\n');
    set(Footnote,'String','Computation canceled.','ForegroundColor','red');
    
    plot(AxesNMF,1,0,'w');
    plot(AxesAFS,0,0,'w');
    plot(AxesSOL,1,0,'w');
    
    onoffButton(Buttons,[],4:11);
elseif suc == -2
    fprintf('stopped: Rank deficient.\n');
    set(Footnote,'String','No initial NMF computed: Rank deficient.','ForegroundColor','red');
    
    plot(AxesNMF,1,0,'w');
    plot(AxesAFS,0,0,'w');
    plot(AxesSOL,1,0,'w');
    
    onoffButton(Buttons,[],4:11);
elseif suc > 0
    
    singv = diag(data.S);
    if singv(2)/singv(1)-1 > -1.E-15
        str = ['Warning after computing an nmf: matrix (CA)^T(CA) is reducible, ',char(963),'(1)/',char(963),'(2)-1 = ', num2str(singv(2)/singv(1)-1,'%3.3e'),'.'];
        set(Footnote,'String',str,'ForegroundColor','red');

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

        onoffButton(Buttons,[],4:11);
        return;
    end
    posSV = [];
    for i=2:data.s
        mi = min(data.V(:,i));
        if (mi > 0) || (-mi < 1.E-16*max(data.V(:,i)))
            posSV = [posSV, i];
        end
    end
    
    if isempty(posSV) == 0
        str = 'Warning after computing an nmf: matrix (CA)^T(CA) is reducible, positive singular vectors: 1';
        for i=1:length(posSV)
            str = [str, ', ', num2str(posSV(i))];
        end
        set(Footnote,'String',[str, '.'],'ForegroundColor','red');

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

        onoffButton(Buttons,[],4:11);
        return;
    end
    
    a = data.InitT*data.V(:,1:data.s)';
    c = data.U*data.S(:,1:data.s)*pinv(data.InitT);
    
    fprintf('ready, time: %2.2f s.\n',tim);
    set(Footnote,'String',['NMF computation-time:  ',num2str(tim),' s'],'ForegroundColor','black');
    if min(min(c)./max(c)) < -0.01
        set(NMFinfo(2),'String',[' min(C):  ',num2str(min(min(c)./max(c)),'%1.1e')],'ForegroundColor','red');
    else
        set(NMFinfo(2),'String',[' min(C):  ',num2str(min(min(c)./max(c)),'%1.1e')],'ForegroundColor','black');
    end
    if min(min(a')./max(a')) < -0.01
        set(NMFinfo(3),'String',[' min(S):  ',num2str(min(min(a')./max(a')),'%1.1e')],'ForegroundColor','red');
    else
        set(NMFinfo(3),'String',[' min(S):  ',num2str(min(min(a')./max(a')),'%1.1e')],'ForegroundColor','black');
    end
    
    for i=1:4
        plot(AxesNMF,data.x,a(i,:),'color',lcs(i,:),'Linewidth',2);
        hold(AxesNMF,'on');
    end
    hold(AxesNMF,'off');
    axis(AxesNMF,'tight');
    yl = get(AxesNMF,'ylim');
    set(AxesNMF,'ylim',[min(0,yl(1)), yl(2)*1.1]);
    xlabel(AxesNMF,'channel');
    
    plot3(AxesAFS,data.InitT(1,2),data.InitT(1,3),data.InitT(1,4),'+','color',lcs(1,:),'Linewidth',2);
    hold(AxesAFS,'on');
    plot3(AxesAFS,data.InitT(2,2),data.InitT(2,3),data.InitT(2,4),'+','color',lcs(2,:),'Linewidth',2);
    plot3(AxesAFS,data.InitT(3,2),data.InitT(3,3),data.InitT(3,4),'+','color',lcs(3,:),'Linewidth',2);
    plot3(AxesAFS,data.InitT(4,2),data.InitT(4,3),data.InitT(4,4),'+','color',lcs(4,:),'Linewidth',2);
    hold(AxesAFS,'off');
    
    data.Dpoints = data.D*data.V(:,1:4);
    data.Dpoints(:,2) = data.Dpoints(:,2)./data.Dpoints(:,1);
    data.Dpoints(:,3) = data.Dpoints(:,3)./data.Dpoints(:,1);
    data.Dpoints(:,4) = data.Dpoints(:,4)./data.Dpoints(:,1);
    
    data.Dpoints = data.Dpoints(:,2:4);
    
    plot(AxesSOL,1,0,'w');
    
    mimi = max(-min(min(c)./max(c)), -min(min(a')./max(a')));
    if mimi > 1.E-12
        mimi = ceil(mimi/10^(floor(log10(mimi))-1))*10^(floor(log10(mimi))-1);
    else
        mimi = 1.E-12;
    end
    
    set(Polysettings(1),'String',num2str(mimi,'%1.1e'));
    data.miminmf = mimi;
    
    onoffButton(Buttons,4:7,8:11);
    
    data.isnmf = 1;
    data.isafs = 0;
    set(Empty_Button,'UserData',data);
end
