The invention relates to a method and an apparatus to identify alveolar
opening and collapse of a lung. To automatically generate the settings of
ventilator parameters in a simple and gentle way, the hemoglobin oxygen
saturation and/or the endtidal CO.sub.2 concentration and/or the CO.sub.2
output are-measured and processing to detect alveolar opening and
closing. From the knowledge of the corresponding airway pressures, a
central processing unit may generate the settings of ventilation
parameters such that gas exchange is maximal while the mechanical stress
of the lung tissue is minimal.