
%%% returns the "power ratio" of a signal 'S' with 'fs' sampling frequency
%%%% power ratio is defined as the ratio of power in the lower frequency band (2.5-12 Hz) to that in the higher frequency band (12-80 Hz). 

function PR = power_ratio(S, fs)

    filter_low = bandp_filter(2.5, 12, fs);
    signal_lowpass = fliplr(filter(filter_low,fliplr(filter(filter_low,S))));  
    power_low = mean(signal_lowpass.^2);

    
    filter_high = bandp_filter(12, 80, fs);
    signal_highpass = fliplr(filter(filter_high,fliplr(filter(filter_high,S))));  
    power_high = mean(signal_highpass.^2);


    PR = power_low / power_high;

end

