make a threshold frequency based on percentage of frequencies less than that?
A Matlab code and illustration is given below, with the  discrete cosine transform (DCT):

nSample = 512;
pDataThreshold = 90/100 ; % percentage, as a float in [0 1]

time = linspace(0,1,nSample)';
data = sin(2*pi*4*sqrt(time));
dataTrans = dct(data);
dataThreshold = quantile(abs(dataTrans),pDataThreshold);
dataTransThreshold = dataTrans;
dataTransThreshold(abs(dataTrans) &lt; dataThreshold) = 0;
dataCompact = idct(dataTransThreshold);

plot(time,[data,dataCompact]);
xlabel('Time')
ylabel('Amplitude')
legend('Data',['DataCompact (',num2str(100*pDataThreshold),'%)'])
grid on