A closed loop system uses (a) the intensity of the diaphragm electromyogram (EMG) for a given inspiratory volum (b) the inspiratory volume for a given EMG intensity or (c) a combination of (a) and (b) in view of controlling the level of gas flow, gas volume or gas pressure delivered by a mechanical (lung) ventilator. The closed loop ventilator system enables for automatic or manual adjustment of the level of inspiratory support in proportion to changes in the neuro-ventilatory efficiency such that the neural drive remains stable at a desired target level. An alarm can also be used to detect changes in neuro-ventilatory efficiency in view of performing manual adjustments.