A medical apparatus includes: a breathing device comprising an air pressure generator for generating air pressure, a tube for delivering the air pressure to a patient, and a sensor configured to sense a characteristic associated with a breathing of the patient and a processing unit configured to receive an output from the sensor, and generate a control signal for controlling a medical device based at least in part on the output from the sensor.