A system for predicting atrial fibrillation or stroke includes processing circuitry configured to receive ECG data from an ECG monitoring device, detect a first candidate P-wave represented in the ECG data, calculate a quality score of the first candidate P-wave by calculating a quality score of ECG data between the onset and the offset of the first candidate P-wave, detect a second candidate P-wave represented in the ECG data, calculate a quality score of the second candidate P-wave, compare the quality score of the first candidate P-wave with the quality score of the second candidate P-wave, store the candidate P-wave having the higher quality score, and calculate a characteristic of the stored P-wave, wherein the characteristic is at least one of a rate of rise of the stored P-wave, an area under the curve of the stored P-wave, and a duration of the stored P-wave.