CPAP treatment apparatus is disclosed having a controllable positive airway pressure device. A sensor generates a signal representative of patient respiratory flow that is provided to a controller. The controller is operable to determine the occurrence of an apnea from a reduction in respiratory airflow below a threshold determined from long term ventilation. When an apnea or hypopnea has occurred the calculation of the threshold is suspended until the end of that event.