Automatic detection of maximal oxygen uptake and ventilatory threshold