Artifacts generated by motion (e.g., ballistocardiac) of the head inside a high magnetic field corrupt recordings of EEG and EPs. This paper introduces a method for motion artifact cancellation. This method is based on adaptive filtering and takes advantage of piezoelectric motion sensor information to estimate the motion artifact noise. This filter estimates the mapping between motion sensor and EEG space, subtracting the motion-related noise from the raw EEG signal. Due to possible subject motion and changes in electrode impedance, a time-varying mapping of the motion versus EEG is required. We show that this filter is capable of removing both ballistocardiogram and gross motion artifacts, restoring EEG alpha waves (8-13 Hz), and visual evoked potentials (VEPs). This adaptive filter outperforms the simple band-pass filter for alpha detection because it is also capable of reducing noise within the frequency band of interest. In addition, this filter also removes the transient responses normally visible in the EEG window after echo planar image acquisition, observed during interleaved EEG/fMRI recordings. Our adaptive filter approach can be implemented in real-time to allow for continuous monitoring of EEG and fMRI during clinical and cognitive studies.