% Percentile temporal pooling method
%
% Only the a certain p% of values is taken into account and averaged.
%
% om - vector of objective metric scores for each frame
% p - the percentile value 

function pctp = temppool_percentile(om,p)
    if ~isvector(om)
        error('Input om must be a vector')
    end
    if ~isscalar(p) || p <= 0 || p > 100
        error('Input p must be a positive scalar between 0 and 100')
    end
    
    om_ordered = sort(om,'ascend');
    om_p = om_ordered(1: floor(length(om_ordered)*p/100));

    pctp = mean(om_p);
