truncate function written using thresholdindex

truncate function cuts the samples at a percent of the max