An ECG measuring device and a magnetic resonance scanner to permit reliable detection of R-waves in ECG signals. The R-waves are identified by: measuring at least one reference ECG signal by an ECG measuring device, identifying an R-wave in the reference ECG signal, determining from the reference ECG signal at least one reference quantity which the reference ECG signal assumes in a time interval that starts before the R-wave of the ECG signal and lasts at a maximum up to the occurrence of the R-wave, generating at least one comparison rule on the basis of the at least one reference quantity, measuring ECG signals in which R-waves are to be identified, comparing the measured ECG signals with at least one reference quantity on the basis of the at least one comparison rule and outputting a trigger signal on the basis of at least one positive result of the comparison.