function [newWaves,oldWaves,time,Vmaxs,imaxs,rawevstatsL2,RTFWHMbadwaves,DBLbadwaves,amplifications,DHwaves,flattops,lightsource,scopescale,triglevel] = L2proto(whichset)
    Vmaxs=[];
    theWaves=[];
    scopescale=[];
    triglevel=[];
    lightsource=[];
    
    [pname,fname,thresholdPercent,riseTimeMin,riseTimeMax,fwhmMin,fwhmMax,ampMin,ampMax,FW3Mcutoff,flat] = L2Params(whichset);

    TTn= [pname fname];
    load(TTn);
    newWaves=theWaves;
    oldWaves=theWaves;
    clear theWaves;

    time=theTimescale;
    tinc=time(5)-time(4);
    
    [~,rawevstatsL2(1),~] = size(oldWaves);
    
    disp('Its go time!');
    % --------------------------------------------
    % if signals plateau, remove them first
    if( flat == 1)
        [newWaves,flattops] = rmFlattops(newWaves,Vmaxs);
        [~,rawevstatsL2(2),~] = size(flattops);
        disp('Flat top waveforms removed');
        disp(rawevstatsL2(2));        
    else
        flattops=0;
        rawevstatsL2(2) = 0;
    end
    [Vmaxs,~] = getMaxs(newWaves);
    

    % ---------------------------------------------
    % Removing double pulses

    [newWaves,DBLbadwaves] = removeDBLwaves(newWaves,thresholdPercent,Vmaxs,time);
    
    [Vmaxs,~] = getMaxs(newWaves);
    
    [~,rawevstatsL2(3),~] = size(DBLbadwaves);
    
    disp('Double pulses cut');
    disp(rawevstatsL2(3));
    %---------------------------------------------
    % Removing waves with improper rise time and FWHM
    
    [newWaves,RTFWHMbadwaves] = RTFWHMcut(newWaves,Vmaxs,tinc,time,thresholdPercent,fwhmMin,fwhmMax,riseTimeMin,riseTimeMax);
    
    [~,rawevstatsL2(4),~] = size(RTFWHMbadwaves);
    
    disp('RT & FWHM cuts applied');
    disp(rawevstatsL2(4));
    %------------------------------------------------
    % Applying a FW 30% max cut to eviscerate double hump pulses
    
    [~,p,~] = size(newWaves);

    FW3Ms=zeros(p,1);
    for j=1:p
        [~,~,twidth,~] = findThresholds(newWaves(:,j,2),.199*max(newWaves(:,j,2)),time);
        FW3Ms(j) = twidth*tinc;
    end
    
    DHcuts = FW3Ms > FW3Mcutoff;
    
    DHwaves = newWaves(:,logical(DHcuts),:);
    newWaves = newWaves(:,~logical(DHcuts),:);
    
    rawevstatsL2(5) = sum(DHcuts);
    
    disp('Double hump waves cut');
    disp(rawevstatsL2(5));
    % ------------------------------------------------
    % Applying amplification cuts
    
    [newWaves,amplifications,rawevstatsL2] = amplificationControl(newWaves,time,ampMin,ampMax,rawevstatsL2);

    [Vmaxs,imaxs] = getMaxs(newWaves);
    
    disp('Amplification cut');
    disp(rawevstatsL2(6));
    
    % -----------------------------------------------
    % plot useful info
    disp('Plotting');
    
%    performL2plots;
end    