A device (1) for detecting the heartbeat (2a) of a patient (2), comprising a transmitter (4) for ultrasonic waves (4a), a receiver (5) for Doppler-shifted ultrasonic waves (5a), and evaluating means configured to extract at least one time-varying frequency component and to evaluate moments t1, t2, t3, t4 of the heartbeat from the variation of at least one of the frequency components in time. The moments are determined either as the moments where the at least one time-varying frequency component assumes a maximum, or as the moments where the original time dependent signal assumes a maximum within a window of interest that is generated based on the time-varying frequency component. The heartbeat may be used to trigger image acquistion, in particular in a MRI apparatus. Tracking means may be provided to determine which transmitters and/or receivers cover the heart, in particular for imaging of a fetus.