The simultaneous recording of electroencephalogram (EEG) and functional magnetic resonance image (fMRI) has been used to provide high spatiotemporal information related to the brain mapping. However, artifacts induced during the simultaneous recording of EEG and fMRI interrupt the analysis of signals in the EEG channels. Especially, ballistocardiogram (BCG) induced by the heart beat of the subjects causes artifacts in all EEG channels and makes it difficult to measure and interpret the EEG signals. We propose an artifact removal algorithm using adaptive window size and individual delay. Once the adaptive window size for the averaged ballistocardiac artifacts (BA) and the individual delay between the peak in QRS complex of the electrocardiogram (EKG) signal and the BA in the EEG signal are determined, the averaged BA is subtracted according to the classification result of the BAs. The performance of the algorithm has been evaluated using the simulation data and the actual epilepsy experimental data.