INTRODUCTION: Diagnosis of occult atrial fibrillation (AF) is difficult as it is often asymptomatic, leading to under-detection. Current diagnostic tests have variable limitations in feasibility and accuracy. Machine learning is gaining greater traction for clinical decision-making and may help facilitate the detection of undiagnosed AF when applied to magnetic resonance imaging (MRI). We hypothesize that a machine learning algorithm increases the accurate classification of MRIs of stroke patients into those due to AF versus large artery atherosclerosis. METHODS: Stroke aetiology for each patient was determined by a review of medical records and investigations. Patients with either AF or large artery atherosclerosis were included. Patients were randomly divided into the training and validation groups (4:1). A 3D convolutional neural network (ConvNeXt) was developed to train and validate the algorithm. After training, the models were evaluated using common metrics for binary classification. RESULTS: A total of 235 patients were analysed (97 with AF, 138 without AF). The mean age of the sample was 71.1 (SD 14.2), and 35% were female. The best discriminative performance was obtained in the 5th fold of cross-validation (AUC-ROC 0.88), and the overall model performance was 0.81 ± 0.05. The best performing metrics were precision (0.84 ± 0.08) and the F1-score (0.77 ± 0.06). CONCLUSION: Our machine learning algorithm has reasonable classification power in categorizing stroke patients into those with and without underlying AF. Testing in external validation datasets is critical to confirm these results.