add median_ratio parameter, fix median quality selector