A method of obtaining an indication of the position of an esophageal catheter inserted into a patient includes the steps of obtaining an electrical signal from the esophageal catheter, determining an ECG component of the electrical signal, determining the widths and/or rate of a number of periods in which the ECG component exceeds a threshold value, using the rate or widths of the periods to determine the presence of a P-wave in the ECG component, and concluding that the catheter is in a good position for obtaining a correct EMG signal if a P-wave is determined to be present. If not, the position may be corrected. The method may be performed by a control unit in a ventilator or a monitoring device.