function makesens(~,~,Empty_Button, Buttons, AxesD, RegSlider, AutoPGAText, SensSlider)
% function makesens(~,~,Empty_Button, Buttons, rbgautopga, AxesD, RegSlider, AutoPGAText, SensSlider)
data = get(Empty_Button,'UserData');

if data.isautodetect == 1
    %% get data
    idall = data.autodetectall;
    id = data.bestpeak;
    scal = get(SensSlider(1),'Value');
    maxdet = str2num(get(AutoPGAText(3),'String')); 
    maxdet = round(maxdet);

    %% recalculate maximum number of plotted Peaks
    md = min(maxdet,length(idall));
    id = max(1,min(round(scal*id),md));
    tmp = idall(1:id);
    data.autodetect = sort(tmp);

    %% plot
    set(Empty_Button,'UserData',data);

    mid = min(0,min(min(data.D)));
    mad = max(max(data.D))*1.1;
    lgntxt = {};
    for i=1:length(data.autodetect)
        plot(AxesD,data.x(data.autodetect(i))*[1 1],[mid mad],'linewidth',1.5)
        hold(AxesD, 'on');
        lgntxt{end+1} = num2str(round(10*data.x(data.autodetect(i)))/10);
    end
    plot(AxesD,data.x,data.D','k');
    axis(AxesD,'tight');
    set(AxesD,'ylim',[mid mad]);
    xlabel(AxesD,'channel');
    lgn = legend(AxesD,lgntxt);
    set(lgn,'fontsize',12,'location','best');
    hold(AxesD, 'off');

    data.isautodetect = 1;
    set(Empty_Button,'UserData',data);

    if (isfield(data,'issvd')*isfield(data,'isnovctrs') == 1) && (data.issvd*data.isnovctrs == 1)
        if get(RegSlider(8), 'Value') > 0
            if (isfield(data,'isgivenspec') == 1) && (data.isgivenspec == 1)
                onoffButton(Buttons,17,[]);
            end
        else
            onoffButton(Buttons,17,[]);
        end
    end
% else
    %     newautodetectPGA_temp(0,0,Empty_Button, Buttons, rbgautopga, AxesD, RegSlider, AutoPGAText, SensSlider)
    %auch ok, wenn dann nichts passiert -> erst Wahl des Ansatzes, dann
    %Anpassung durch sens
end