function [filtdata] = rampfilter1(data,percent,order)
%------------------------------------------------------------------
% Function: rampfilter(data)
%
% Inputs:     data - 2 Dimensional projection data 
%          percent - Percent of max frequency
%            order - Filter order (controls roll-off)
%
% Output: filtdata - 2 Dimensional ramp-filtered data
%------------------------------------------------------------------

    %Find the number of projection angles and bins
    [M N] = size(data);
    nangles = M;
    npixels = N;
    
    %Create spatial-domain ramp filter
    tau = 1./2;
    for i=0:npixels-1
        var=i-npixels/2+1;
        if (var == 0)
            h(i+1) = 1./(4.*tau.^2);
        elseif (mod(var,2) == 0)
            h(i+1) = 0.0;
        else
            h(i+1) = -1./((var.^2).*(pi.^2).*(tau.^2));
        end
    end

    %Fourier transform spatial-domain filter
    w = fft(h);
    filt = abs(w).*pi./4;
    
    % Create Butterworth apodization filter
    wc = percent.*filt(npixels./2);
    for i=1:npixels./2
        b(i) = 1./(1+(filt(i)/wc).^(2.*order));
        b(npixels-i+1)=b(i);
    end

    % Apodize ramp filter
    filt = filt.*b;
     
    %Filter each projection
    for i = 1:nangles
        temp = fft(data(i,:));
        ftemp = temp.*filt;
        filtemp(i,:) = ifft(ftemp);
    end
    
    filtdata = real(filtemp);
    