A non-transitory, computer-readable storage medium encoded with programming instructions and being loadable into a control unit of a ventilator configured for connection to a patient for breathing therapy, said ventilator also comprising a pneumatic unit, said storage medium being loaded into said control unit and said programming instructions causing said control unit to:
- receive, via an electrical path from a detector, a bioelectrical signal representing electrical activity generated in the patient due to breathing by the patient;
- generate a first mode control signal from the electrical activity represented by said bioelectric signal and operate the pneumatic unit of the ventilator in a first mode using said first mode control signal;
- also receive a breathing parameter related to mechanical breathing dynamics of the patient;
- and
- determine when said bioelectrical signal is absent and to analyze said breathing parameter to determine whether the absence of the bioelectric signal is due to disruption of said electrical path, or a disturbance of said bioelectric signal, or a changed position of the detector, or no generation of the bioelectric signal by the patient, and, if said control signal is absent, switch from operating said pneumatic unit in said first mode to operating said pneumatic unit from the control unit in a second mode in which a second mode according to a second mode control signal and generate the second mode control signal from the mechanical breathing dynamics related to said breathing parameter.