Co-registered EEG and functional MRI (EEG/fMRI) is a potential clinical tool for planning invasive EEG in patients with epilepsy. In addition, the analysis of EEG/fMRI data provides a fundamental insight into the precise physiological meaning of both fMRI and EEG data. Routine application of EEG/fMRI for localization of epileptic sources is hampered by large artefacts in the EEG, caused by switching of scanner gradients and heartbeat effects. Residuals of the ballistocardiogram (BCG) artefacts are similarly shaped as epileptic spikes, and may therefore cause false identification of spikes. In this study, new ideas and methods are presented to remove gradient artefacts and to reduce BCG artefacts of different shapes that mutually overlap in time.Gradient artefacts can be removed efficiently by subtracting an average artefact template when the EEG sampling frequency and EEG low-pass filtering are sufficient in relation to MR gradient switching (Gonçalves et al., 2007). When this is not the case, the gradient artefacts repeat themselves at time intervals that depend on the remainder between the fMRI repetition time and the closest multiple of the EEG acquisition time. These repetitions are deterministic, but difficult to predict due to the limited precision by which these timings are known. Therefore, we propose to estimate gradient artefact repetitions using a clustering algorithm, combined with selective averaging. Clustering of the gradient artefacts yields cleaner EEG for data recorded during scanning of a 3. T scanner when using a sampling frequency of 2048. Hz. It even gives clean EEG when the EEG is sampled with only 256. Hz.Current BCG artefacts-reduction algorithms based on average template subtraction have the intrinsic limitation that they fail to deal properly with artefacts that overlap in time. To eliminate this constraint, the precise timings of artefact overlaps were modelled and represented in a sparse matrix. Next, the artefacts were disentangled with a least squares procedure. The relevance of this approach is illustrated by determining the BCG artefacts in a data set consisting of 29 healthy subjects recorded in a 1.5. T scanner and 15 patients with epilepsy recorded in a 3. T scanner. Analysis of the relationship between artefact amplitude, duration and heartbeat interval shows that in 22% (1.5. T data) to 30% (3. T data) of the cases BCG artefacts show an overlap. The BCG artefacts of the EEG/fMRI data recorded on the 1.5. T scanner show a small negative correlation between HBI and BCG amplitude.In conclusion, the proposed methodology provides a substantial improvement of the quality of the EEG signal without excessive computer power or additional hardware than standard EEG-compatible equipment. © 2012 Elsevier Inc.