integration of functional magnetic resonance imaging ( fmri ) with electroencephalography ( eeg ) has offered the possibility of understanding new insights into neuroscientific studies because of the higher temporal and spatial measurements of brain activity when compared with the use of each technique separately . rather than only an additional tool , coregistered eeg - fmri has been shown to be a promising and powerful technique for the mapping of brain activity and has drawn the attention of several researchers and clinicians in recent years [ 17 ] . meanwhile , consolidation of simultaneous eeg - fmri and enlargement of its range of applications still depend on enhancing the quality of the eeg signal acquired simultaneously with the fmri data . the mr scanner constitutes a quite hostile environment for eeg because of the voltages induced by the magnetic fields used for acquisition of fmri data . such voltages correspond to three different types of artefact and may corrupt and distort the eeg signal , measured by the scalp electrodes . the first type of artefact is the movement artefact associated with motion of the subject head , electrodes , and wires into the static magnetic field ( b0 ) of the mr scanner , which introduces temporary voltage fluctuations in the measured scalp potential [ 8 , 9 ] . a second type of artefact is the pulse or ballistocardiogram artefact , provoked by the pulsatile movement of the blood in scalp arteries within b0 [ 1013 ] . finally , the gradient or imaging acquisition artefact is the voltage induced in the measured scalp potential by the application of rapidly varying magnetic field gradients for spatial encoding of the mr signal and radiofrequency pulses ( rf ) for spin excitation [ 1416 ] . the occurrence of the movement artefact within a scenario of abrupt head motions as well as the pulse artefact is out of the scope of this work , and further details about their characteristics and methods to suppress them can be found in the abovementioned references . regarding the gradient artefact , its amplitudes can be several orders ( up to 10  v ) higher than the neuronal eeg signal . the gradient fields and rf pulses used in the mr pulse sequences induce a characteristic and repetitive artefact waveform in the electrical potential picked up by the scalp eeg electrodes ( scalp potential ) , which is approximately the differential waveform of the corresponding gradient pulse . the onset of the artefact waveform corresponds to the occurrence of a rf pulse in the mr sequence , such that the time in - between consecutive rf pulses ( termed repetition time , tr ) matches the period of the artefact waveform . the stack of repetitive individual mr slices within a single tr occurs in the recorded scalp potential as signal peaks , and the time corresponding to the acquisition of one slice or slice - time ( tr - slice ) lies in the range of 50150  ms . in the frequency - domain , the repetitive feature of the gradient artefact can be observed as discrete harmonic artefact frequency intervals or the fundamental of each respective frequency bin corresponds to multiples of the inverse of the slice repetition time ( 1/tr - slice ) . for periodic or interleaved fmri acquisition , in which delays are left between mr volumes , harmonics in the frequency range of 1/tr appear convolved with the frequency bins associated with the slice repetition frequency , 1/tr - slice [ 1519 ] . in the literature , a number of solutions have been proposed to attenuate the effects of the gradient artefact at the source . for instance , it is possible to reduce its magnitude by laying out and immobilising the eeg leads , twisting the leads or modifying the lead paths , using a bipolar electrode configuration , and using a head vacuum cushion [ 16 , 20 ] . the use of interleaved fmri acquisition approaches has been shown to be suitable for certain forms of brain activity , such as slowly varying rhythms and evoked responses . however , they are generally less flexible and experimentally efficient than continuous measurements [ 9 , 21 ] . according to mullinger et al . , the amplitudes of the gradient artefact can also be attenuated by adjusting the subject position within the fmri scanner . chowdhury et al .   have proposed the use of an eeg cap that incorporates electrodes embedded in an external layer and can record the gradient artefact separately from the eeg signal . thus , subtraction between the signals recorded by internal and corresponding external electrodes allows the attenuation of the artefact . although these solutions permit achieving a considerable attenuation of the gradient artefact , its effective suppression and satisfactory eeg correction must be performed by using dedicated postprocessing signal approaches . the average artefact subtraction ( aas ) methodology   is the most established postprocessing technique for gradient artefact suppression . such an approach makes use of the assumption of periodic and stationary nature of the artefact to calculate an average template from occurrences of the artefact waveform , which is then subtracted from the scalp potential . it also assumes the artefact and the eeg signal are not correlated , so that the subtraction of the averaged template permits an estimation of the corrected eeg . the performance of the aas method highly depends on the reproducibility of the artefact waveform from epoch to epoch , which can be facilitated by utilising a setup that yields more accurate sampling of the gradient artefact waveform over time . have demonstrated that the use of synchronisation between the fmri clock and the eeg sampling frequency allows more precise sampling of the artefact and construction of a more accurate artefact template , in consequence . thus , a cleaner eeg can be obtained after application of aas in the recorded scalp potential . head motions of the subject provoke alterations in the morphology of the artefact waveform over the artefact period , in such a way that the average artefact template can not characterise individual occurrences of the artefact waveform . to address this problem , allen et al .   and becker et al . proposed the use of a sliding average window implementation whereby the artefact template may be individually calculated for a particular occurrence of the artefact waveform . however , the correct choice of the number of averaging epochs poses difficulties to implementation of this approach , since few windows can result in removal of the neuronal eeg , whereas the use of many windows can lead to remaining residual artefacts after aas . hence , to effectively suppress the gradient artefact with a satisfactory preservation of the neuronal eeg , additional approaches like low - pass filtering with a cut - off frequency around 5080  hz and adaptive noise cancelling must be employed to attenuate residual artefacts [ 14 , 15 , 20 , 21 , 2629 ] . some variants of aas have been devised in attempt to improve the accuracy of template calculation by using principal component analysis , independent component analysis , and spatial filtering . to correct the jitter between eeg sampling frequency and fmri clock , more precise computing of the timing error has been addressed by negishi et al . , and huang et al . . nevertheless , estimation of an optimal artefact template is still the object of study . in addition , the study of ultra - high - frequency neuronal activity as currently performed   requires the use of interleaved approaches as well as customised fmri sequences that are generally not available to all investigators . thus , further improvements of aas and development of novel correction methods are still required and highly desirable to enhance the quality of the eeg signal , mainly regarding eeg signals with low amplitude and with frequency activity in the gamma band ( 30100  hz ) and high - frequencies oscillations between 100 and 500  hz [ 20 , 34 ] . because of the risk of simultaneous removal of neuronal eeg activity during application of the gradient artefact correction approach , assessment of the preservation of the eeg signal should be carried out together with the efficacy of the artefact suppression . this , however , has seldom been made systematically or in a consistent way [ 3437 ] . in many eeg - fmri studies , a single algorithm is chosen without proper justification , and often the quality of gradient artefact correction and eeg preservation is assessed by visual inspection only . the classical ( gold standard ) way of analyzing eeg signals relies on visual judgement and recognition of sometimes very subtle or short duration phenomena such as spike - wave patterns in epilepsy studies or k - complexes in sleep research . nonetheless , those patterns may easily be distorted or obscured after application of the artefact correction approach . a difficulty that arises with regard to the analysis of spontaneous eeg excerpts is the stochastic and nonstationary nature of the neuronal eeg . on the other hand , identification of single events in the corrected eeg is not suitable for a scenario in which the signal of interest is the spontaneous eeg and , thus , larger eeg excerpts over time should be analyzed . in addition , the lack of knowledge of the true eeg signal makes it difficult to compare the power spectra of artefact - corrected eeg excerpts with the spectra of the eeg recorded inside or outside the scanner . thereby , a more systematic approach to assess and compare the performance of the gradient artefact correction methods is advised in some applications , rather than only relying on the analysis of single events or the quantification of eeg power in certain spectral bands . moreover , to date , generalisation of the correction results for different types of eeg data has been poorly made as well [ 16 , 3537 ] . this paper presents a novel methodology for gradient artefact correction based upon optimised moving - averaging ( oma ) filtering . oma filtering constitutes a modality of iterative filtering decomposition [ 39 , 40 ] and has been exploited in a research project that our group has undertaken to investigate characteristics and features of the gradient artefact that might be used to attenuate , correct , and improve the quality of the corrected eeg signal [ 38 , 4143 ] . optimised moving - average makes use of forward - backward application of a moving - average ( ma ) filter as an integration procedure to suppress the artefact and estimate partial components of the corrected eeg at the same time . recursive application of such a procedure allows estimation of the corrected eeg as a sum of the calculated partial components . rather than estimation of an average template , as performed by the aas implementation , the artefact is calculated not for epochs , but sample - by - sample , as described in section 2 . to assess the degree of eeg preservation , we have devised a novel and simple evaluation approach that allows accounting for the stochastic nature of the neuronal eeg and was used to perform a comparative analysis of oma with aas . comparison between the performances of oma and aas reveals that our method can provide an improved balance for the suppression of the artefact together with a satisfactory preservation of the neuronal eeg signal , as shown in section 4 . in parallel , the use of low - pass filtering or another correction approach to suppress residual artefacts after application of oma can be avoided , and thus our method potentially better preserves highly relevant high - frequency eeg features . furthermore , the results indicate that our approach is capable of satisfactorily correcting the eeg data even within a scenario of misalignment between eeg sampling interval and the mr slice - time and without accurate information about mri triggers . analysis of the application of the gradient artefact correction in eeg data sets recorded by using mr scanners from two different vendors is also provided in section 4 . our devised methodology was tested in two types of eeg data simultaneously acquired with fmri data . the eeg data sets were kindly provided by brain products gmbh , gilching , germany , which gave consent for their publication . data acquisition was conducted in accordance with the declaration of helsinki , approved by the responsible ethics committee , and the subjects gave their informed written consent before participating in the study . one of the eeg data sets was recorded within a philips scanner ( hereafter referred to as philips data ) , whereas the other eeg data set was recorded within a ge scanner ( hereafter referred to as ge data ) . the eeg data in both the philips and ge scanner were recorded in two volunteers by using an mri - compatible 64-channel eeg system ( brainamp mr , brain products gmbh , gilching , germany ) . an mr - compatible eeg cap ( braincap mr , easycap gmbh , herrsching , germany ) containing sintered ag / agcl electrodes the eeg cap was arranged in accordance with the standard 10 - 5 electrodes ' positioning , with the fcz position used as reference and the ground electrode located at the afz position . the impedance of all electrodes was set below 30  k , and one additional electrode was placed on the subject back to record the ecg signal . the eeg amplifiers were positioned inside the scanner bore near the middle axis and connected via fiber optic to a pc interface located outside the scanner room . syncbox ( brain products gmbh , gilching , germany ) was used to synchronise the internal sampling clock of the eeg amplifier and the mri scanner 10  mhz master clock . the signal acquisition was performed using a sampling rate at 5000  hz and measurement resolution at 0.5  v . hardware - filtering in the frequency band between 0.016  hz and 250  hz was applied before data digitalisation in order to prevent saturation and reduce the gradient artefact amplitude . during acquisition , the volunteers were instructed to perform a simple opening / closing eyes manoeuvre at regular time intervals . regarding acquisition of fmri data , acquisition of the philips data set was carried out using a 3  t achieva scanner ( philips , eindhoven , the netherlands ) . one volunteer was scanned using a functional echo - planar imaging ( epi ) sequence with 40 transversal slices and volume repetition time ( tr ) equal to 2000  ms . the fmri clock and the eeg sampling frequency have been synchronised , so that tr was set as a multiple of the eeg sampling interval . fmri data acquisition was continuously performed , and tr was adjusted as a multiple of the slice - time ( tr - slice ) . hence , tr - slice was equal to 2000  ms/40 slices = 50  ms . acquisition of the ge data set was carried out using a 3  t discovery mr750 scanner ( ge , waukesha , usa ) . a second volunteer was scanned using an epi sequence with 28 transversal slices and volume repetition time ( tr ) equal to 2000  ms . fmri data acquisition was continuously performed , and the fmri clock and the eeg sampling frequency have been synchronised for a period equal to 500  ms , corresponding to seven times of tr - slice . thereby , although tr was approximately adjusted as a multiple of the slice - time ( tr - slice ) , tr - slice was not aligned and did not match a multiple of the eeg sampling interval . our proposed methodology for gradient artefact correction was implemented in two steps : ( i ) peak detection and tr - slice estimation and ( ii ) optimised moving - average filtering . the recorded scalp potential , sn , in one specific eeg channel was mathematically modelled as a linear superposition of the neuronal eeg , etrue , n , and the induced voltage associated with the gradient artefact interference , gartf , n:(1)sn = etrue , n+gartf , n , where n is the time sample . an initial detection of the peaks corresponding to the onset of the mr slices observed in the recorded scalp potential must be performed according to our proposed methodology . such detection permits estimation of the slice - time ( tr - slice ) according to the time basis of the eeg sampling system , which is utilised during implementation of the optimised moving - average filtering . within a scenario of alignment between the mr slice - time and the eeg system sampling interval , the estimated tr - slice precisely corresponds to a multiple of the eeg sampling interval [ 25 , 28 , 29 ] . however , when there is misalignment between the mr slice - time and the eeg sampling interval , the value estimated for tr - slice may not match a multiple of the sampling interval and , thereby , vary . this variation can be accounted for by application of optimised moving - average filtering , as described in section 2.4 . figure 1 shows an excerpt of the scalp potential picked up from the philips data , in which tr is a multiple of tr - slice . the time measured between two consecutive peaks in the signal matches the slice - time or tr - slice . assuming that the artefact waveform is stationary , any moving - average window m with length equal to tr - slice along the signal contains the artefact waveform period , but with a different onset of those samples localised in the signal peaks . thereby , assuming that the gradient artefact waveform is stationary and has zero mean , integration of ( 1 ) over the period m results in cancellation of the artefact waveform . also assuming that the terms of ( 1 ) are uncorrelated , the resulting value of the integral along the scalp potential , s , corresponds to a mean estimate of the neuronal eeg , e^n. this integral can be described as a moving - average filter with order m:(2)1mk=0m1snk1mk=0m1etrue , nk+gartf , nk(3)1mk=0m1etrue , nk+1mk=0m1gartf , nk = e^n.because of the phase distortion provoked by the moving - average filter [ 4446 ] , the mean value e^n is not in phase with the neuronal eeg , etrue , nk . in order to make them in phase , the moving - average must be backward applied in ( 3):(4)1mk = m10e^n+k=1mk = m101mk=0m1snkn+k=1m2snm+1 + 2snm+2++m1sn1+msn+m1sn+1++2sn+m2+sn+m1(5)=1m2k=m+1m1mksn+k = ecomp,1,n.thereby , according to ( 4 ) and ( 5 ) , forward - backward application of the moving - average filter in the recorded scalp potential results in the signal ecomp,1 that is in phase and constitutes a mean approximation of the neuronal eeg : ( 6)ecomp,1e^true.equation ( 5 ) acts as a smoothing filter , in such a way that the signal ecomp,1 contains low - frequency activity associated with e^true . in turn , the frequency activity associated with the gradient artefact is contained in the signal , ehigh,1 , resulting from the subtraction of ecomp,1 from s:(7)ehigh,1=secomp,1.since high - frequency components associated with e^true remain in ehigh,1 , it is possible to obtain an estimate of such components by the iterative application of ( 5 ) in ehigh,1 . the second component , ecomp,2,n , results from the application of ( 5 ) in ehigh,1:(8)ecomp,2,n=1m2k=m+1m1mkehigh,1,n+k , and the signal ehigh,2 can be obtained afterwards:(9)ehigh,2=ehigh,1ecomp,2.this procedure was repeated so forth , for a number j of iterations , allowing estimation of the component ecomp , j:(10)ecomp , j , n=1m2k=m+1m1mkehigh , j1,n+k.this procedure also constitutes a modality of iterative filtering decomposition ( ifd ) in which ( 5 ) is termed double average filter [ 39 , 40 ] . the convergence of ifd has been demonstrated in lin et al .   and is ensured by the coefficients ( masks ) of the double average filter having value between 0 and 1 . finally , the estimate e^true of the corrected eeg can be calculated by the sum of j estimated components : ( 11)e^true=j=1jecomp , j.implementation of ( 11 ) can be visualised in the scheme of figure 2 . application of the z - transform in the oma filter , homa , described in ( 10 ) , permits finding its transfer function:(12)homaz=1m21zm1zm1z11z.making use of ( 12 ) , the frequency response of homa can be calculated by setting z = e.   figure 3 shows such a frequency response for some values of m. the magnitude response reveals the presence of spaced zeros at the frequency 2/m . for a hypothetical value m = 1 , the oma filter represents an all - pass band filter , as expected for a moving - average filter . the phase response confirms the zero - phase characteristic of the oma filter . from ( 7 ) , we can find the transfer function between ehigh,1 and s:(13)h111m21zm1zm1z11z=1homaz.hence , ehigh , j corresponds to(14)ehigh , jz=1homazjsz.therefore , ( 12 ) , ( 13 ) , and ( 14 ) allow removing j cascade components shown in figure 2 and establishing the transfer function between e^true and s:(15)e^truezsz=11homazj = hcz.in figure 4 , the magnitude response of hc(z ) in ( 15 ) is depicted , taking into account m = 16 and m = 250 and some values of j. it can be observed that increasing of j is followed by substantial droop reduction ( increasing gain ) in the filter pass - bands . on the other hand , increasing of j is also followed by reduction in the attenuation in the filter stop - bands . in order to improve the attenuation in the stop - bands , hc(z ) might be applied within a cascade implementation as indicated in(16)hlz = hczl , where l is the number of cascades . figure 5 depicts the magnitude response of hl(z ) , for l = 2 and l = 5 , taking into account m = 250 and some values of j. as noticed , ( 16 ) can be used to provide reduced droop in the pass - bands together with higher attenuation in the stop - bands according to the values of j and l. in addition , ( 15 ) and ( 16 ) possess a zero - phase characteristic as well , similar to that observed in figure 3(b ) . therefore , ( 15 ) and ( 16 ) can be used to estimate the artefact - corrected eeg in z - domain . on the other hand , in time - domain , the corrected eeg , e^true , can be calculated by using either ( 11 ) or ( 17):(17)e^true = sehigh , j.as indicated in ( 10 ) and ( 12 ) , the estimate ecomp , j is calculated sample - by - sample , rather than calculation and subtraction of an average artefact template . thus , the optimised moving - average filtering implementation depicted in figure 2 permits an individual calculation and subtraction of the artefact for each signal sample rather than epochs averaging , as performed by aas . hence , the inherent uncertainty associated with averaged samples and the influence of alterations of the artefact waveform provoked by subject head motions might be minimised by using our proposed approach . to assess the performance of the proposed approach in a scenario of misalignment between the eeg sampling interval and the slice - length , oma has been applied by using ( 16 ) , taking into consideration some values of l , as shown in section 4 . according to ritter et al . , two measures must be complimentarily used to evaluate the performance of the gradient artefact correction approach : ( i ) the effectiveness of gradient artefact attenuation and ( ii ) the degree of preservation of the neuronal eeg after artefact correction . to assess the gradient artefact attenuation , the rms and amplitude of the artefact voltage over time were calculated taking into account the subtraction between s and the estimation of the corrected eeg , e^true . also we performed calculation of the spectral power attenuation around the fundamental of the frequency bins associated with the slice repetition frequency ( 1/tr - slice ) . to this end , we have estimated and took into consideration a bandwidth of 1  hz around the fundamental of each frequency bin . calculation of the spectral power attenuation was carried out for the frequency bins below 500  hz . although a band limiter set at 250  hz was employed during data acquisition , we would rather evaluate the attenuation in frequency bins up to 500  hz because of the artefactual energy that may remain above the band limiter edge frequency . equation ( 18 ) was used to compute the spectral power attenuation in decibel:(18)attenuation=20logpapb  db , where pb and pa correspond to the spectral power within the harmonic artefact bins , before and after application of the gradient artefact correction , respectively . the scheme depicted in figure 6 was used to perform the quantitative evaluation of the eeg preservation . as indicated in figure 6 , a reference eeg signal , eref , n , has been linearly added to the measured scalp potential , sn , thus generating the modified signal smod , n . as eref , n , we used eeg excerpts recorded inside the mr scanner during nonscan periods . thereby , the letters  and t indicate that the reference eeg excerpt has been recorded at a different time than sn . the gradient artefact correction was then applied to smod , n and sn , resulting in the estimates e^true,1,n + e^ref , n and e^true,2,n , respectively . thereby , the subtraction between these estimates allows obtaining an estimate of the reference signal , e^ref , n , which was finally compared with eref , n . equations ( 19 ) and ( 20 ) were used to calculate the signal - to - noise ratio ( snr ) and the mean squared error ( mse ) as complimentary measures of temporal and frequency contents of e^ref , n in comparison with eref , n:(19)snr = coveref , e^referefe^ref,(20)mse=1nn=1neref , ne^ref , n2.the snr calculated by ( 19 ) corresponds to a measure of cross - correlation and allows an evaluation and comparison of frequency characteristics between eref , n and e^ref , n . values of snr closer to unity mean higher similarity between eref , n and e^ref , n . in turn , smaller values of mse computed according to ( 20 ) indicate higher correspondence between eref , n and e^ref , n over time . in addition to being of simple implementation , the evaluation scheme of figure 6 has the advantage of allowing the assessment of longer eeg excerpts by accounting for the stochastic nature of the neuronal eeg signal and not single events only . the results obtained by application of oma were compared with those obtained by subtraction of a mean template , according to the average artefact subtraction ( aas ) methodology [ 14 , 21 ] . both oma and aas , we developed and applied our proposed methodology to the eeg recordings in matlab ( the mathworks inc . , natick , usa ) environment . in turn , the average artefact subtraction was carried out by utilising the software brain vision analyzer 2 ( version 2.1.0.327 ; brain products gmbh , gilching , germany ) . as benchmark , a sliding moving - average window implementation of 21 epochs was used for construction of the average artefact template . the reason for using 21 epochs was based upon the default settings of the brain vision analyzer . the epoch length to be averaged and construct the artefact template was set at 50 ms ( tr - slice ) for the philips data and 500 ms for the ge data . such values were chosen to match the minimum period in which the fmri data were synchronised as a multiple of the eeg sampling interval , so that the influence of head motions in longer sliding average windows might be prevented . after application of oma and aas , assessment of artefact attenuation and evaluation of the eeg preservation , as described above , were carried out using matlab . all 63 eeg channels were used to perform the analysis of the ge data . for the philips data , the channel tp8 was excluded from the analysis because the entire recordings were corrupted by artefacts , which made it impossible to pick up a signal excerpt representative of eref , n . figure 7(a ) depicts an exemplary scalp potential excerpt , picked up from the philips data , electrode position fz . in figure 7(b ) , the power spectrum of the signal of figure 7(a ) is shown , and the harmonic activity associated with the gradient artefact can be visualised as spectral peaks at multiples of the fundamental frequency equal to 20  hz , corresponding to the frequency bins associated with 1/tr - slice . by performing the peak detection associated with the gradient artefact in the signal of figure 7(a ) , tr - slice was estimated in even lengths of 250 samples , thus confirming the alignment between tr - slice and the eeg sampling interval for the philips data . hence , for application of the optimised moving - average ( oma ) , we set m = 250 . figure 8(a ) depicts the artefact - corrected eeg by using ( 15 ) , for j = 200 , j = 2000 , and j = 200000 . it can be seen in figure 8(b ) that the harmonic activity associated with the gradient artefact has been attenuated for the used values of j. increasing the value of j is shown to provoke better preservation of the power activity along the spectrum of the corrected eeg signal , mainly in high - frequencies . smaller attenuation in the frequency bins associated with 1/tr - slice is also noticed when the value of j is increased , which agrees with the comb - filtering response depicted in figure 4 as well . therefore , the choice of the value of j should be made in such a way as to provide adequate attenuation of the artefact activity in the frequency bins and satisfactory preservation of the eeg signal . however , ( 15 ) might not provide enough attenuation of the artefact , and ( 16 ) can be used instead , as shown in the next example . an illustrative scalp potential excerpt picked up from the ge data , eeg electrode position fp1 , is depicted in figure 9(a ) , and its corresponding power spectrum is shown in figure 9(b ) . for these data , the slice - length has not been aligned with the eeg sampling interval , in such a way that the value of tr - slice was estimated at 357  1 samples . to demonstrate the performance of the proposed method to suppress the gradient artefact in this scenario , we used ( 16 ) , taking into account m = 357 and j = 200000 , for l = 1 ( see ( 15 ) ) , l = 30 , and l = 100 . figure 10(a ) depicts the corresponding power spectra of the corrected eeg . for l = 1 , oma was unable to satisfactorily attenuate the gradient artefact , so that residual spectral power artefact remained in most of artefact frequency bins ( dark trace ) . figure 10(b ) shows a detail of the time - course corrected eeg signals around 408  s in which the presence of such residuals can also be noticed ( thin dark traces ) . nevertheless , higher values of l allow increased attenuation of the harmonic artefact activity ( figures 10(a ) and 10(b ) ) . for l = 5 ( pink trace ) , residual spectral power associated with the artefact was substantially attenuated in the bandwidth up to 300  hz . in turn , when l = 100 ( green trace ) , such attenuation was even higher , and artefact harmonic activity in the frequency bins could be strongly reduced in the bandwidth below 500  hz . as observed in the spectrum details around 56 and 336  hz ( figure 10(a ) ) , by increasing l , it provokes larger attenuation around the frequency bins . thereby , ( 16 ) can be used to account for the enlargement of the spectral artefact harmonic lines provoked by the alignment error between the eeg sampling interval and tr - slice , thus being able to correct the scalp potential within this scenario . figure 10(c ) depicts the power spectra of the corrected eeg after application of oma ( blue trace , j = 200000 and l = 100 ) and the mean template subtraction by aas ( red trace ) in the signal of figure 9(a ) . as can be noticed for the signal corrected by the aas method , residual power associated with the artefact activity arose in higher - frequencies bins , above around 200  hz . in figure 10(d ) , a detail around 408  s of the time - course of the corrected eeg by oma and aas is also depicted . some small amount of residual artefacts corresponding to the artefact residual power can be noticed in the time - course signal corrected by aas . both oma and aas play a role of comb - filtering approaches [ 24 , 38 ] whereby harmonic frequency components associated with the slice repetitive frequency ( 1/tr - slice ) can be attenuated . on the one hand , aas implementation consists of a coherent detection - based comb - filtering process [ 24 , 48 ] that is carried out by subtraction of the template with period tr - slice . as such , the aas method is highly dependent on precise sampling of the scalp potential as well as accurate alignment amongst the averaging epochs to construct the average template . moreover , small drifts and subject head motions can provoke broadening of the high - frequency artefact spectral lines , in such a way that aas may fail to attenuate them , and residual artefacts arise in the corrected eeg as a consequence . this helps to explain why aas is not effective in eliminating the high - frequency artefact activity shown in figures 10(c ) and 10(d ) , whose attenuation is more affected by imprecise sampling than low - frequency artefact activity as well [ 25 , 29 ] . on the other hand , oma performs comb - filtering making use of the filtering implementation described in section 2.4 . by using proper values of m , j , and l in ( 16 ) , thereby , it allows oma to effectively account for the attenuation of high - frequency artefact activity , as depicted in figure 10 . the results presented in tables 15 for the oma correction ( 16 ) refer to j = 200000 and l = 1 ( philips data ) and j = 200000 and l = 100 ( ge data ) . as observed in table 1 , the median rms and amplitude calculated for the artefact voltages estimated by both approaches are quite similar . however , when the power spectra of the corrected signals are compared , the attenuation of the artefact activity in the frequency bins provoked by the aas and oma is different ( table 2 ) . although both approaches are shown to provoke attenuation approximately similar in some artefact frequency bins , oma provided more attenuation than aas in higher - frequency bins . to perform the quantitative evaluation of eeg preservation , we used the scheme depicted in figure 6 and calculated the median values of snr ( 19 ) and mse ( 20 ) between eref , n and e^ref , n . the results of such measures are shown in tables 3 , 4 , and 5 . in tables 4 and 5 , we show the individual results for some exemplary channels , fp1 , f3 , oz , cpz , fz , fc5 , and af3 . in these tables , we also included the values of snr and mse , considering application of low - pass ( lp ) filtering in eref , n and e^ref , n . the lp filter cut - off frequencies are indicated and were used to assess the eeg preservation in different eeg bandwidths for both oma and the aas method . calculation of the median global values shown in table 3 also took into account the results considering lp filtering . it can be observed that the overall values of snr and mse for the oma method are better than those for aas . it is also noteworthy that low - pass filtering of eref , n and e^ref , n substantially increased the snr and decreased the mse considering the oma approach , unlike the aas method . therefore , by using oma , the signals eref , n and e^ref , n have become more similar after lp filtering , attesting even better preservation of the neuronal eeg in low - frequencies . we also noticed that the mean subtraction by aas produced signals eref , n and e^ref , n less similar because of the higher influence of small drifts and subject head motions . this led to the small differences of the values of snr and the mse for the considered lp cut - off frequencies , as observed in tables 4 and 5 ( aas ) . figure 11 shows a comparison of the typical attenuation in the frequency bins provoked by oma ( 15 ) and aas , taking into account different values of j and different number of averaging epochs , as well as similar eeg preservation ( same snr and mse ) . the results shown in figure 11 were obtained from an eeg excerpt picked up from the channel cpz of the philips data . as observed , even though oma and aas can provide similar eeg preservation according to the values of j and the number of averaging epochs , respectively , oma provokes larger attenuation than aas in the overall frequency bins , mainly in frequencies higher than 100  hz . in addition , the larger the values of j , the higher the difference of attenuation by oma in a certain frequency bin . in turn , the attenuation by aas is more uniform among different numbers of averaging epochs taking into consideration a certain frequency bin . the attenuation provided by aas is shown to be slightly higher and less uniform than oma only for the frequency bins 20 and 40  hz . therefore , figure 11 demonstrates that our proposed comb - filtering approach can be more effective in attenuating the artefact activity and simultaneously in achieving eeg preservation similar to that provided by the aas method . as the repetitive gradient artefact waveform recorded in the scalp potential during continuous acquisition of eeg - fmri is approximately the differential waveform generated within the mr sequence , a proper integration over the artefact period might be used to cancel out the artefact , as indicated in figure 1 and ( 3 ) . to implement such integration , we have investigated and proposed the forward - backward application of a moving - average filter in the scalp potential , described in ( 5 ) . when this procedure is recursively carried out , as depicted in the scheme of figure 2 , it permits suppressing the gradient artefact from the scalp potential and obtaining an estimation of the neuronal eeg . such kind of moving - average procedure is referred to as iterative filtering decomposition , which has been investigated as an alternative implementation for empirical mode decomposition [ 39 , 40 ] . it also constitutes a comb - filtering approach whereby harmonic signal components can be filtered out ( figures 3 , 4 , and 5 ) . as observed in figures 4 and 5 , the oma comb - filtering approach described in ( 15 ) and ( 16 ) can provide increased gain in the filter pass - bands together with effective attenuation in the stop - bands , in addition to possessing a zero - phase characteristic ( figure 3 ) . thus , it is able to effectively suppress the harmonic artefact activity associated with the repetitive artefact waveform that occurs in the slice repetition time ( tr - slice ) and satisfactorily preserve the neuronal eeg signal at the same time , as observed in figures 711 and tables 15 . when compared with subtraction of an average artefact template , according to the aas method implementation [ 14 , 21 ] , both oma and aas show a quite similar rms and amplitude attenuation associated with the gradient artefact over time ( table 1 ) . meanwhile , oma is shown to provoke different attenuation in the artefact frequency bins in comparison with aas , as can be observed in table 2 and figure 11 . as a consequence , our proposed method can lead to different preservation of the eeg signal than aas , as indicated by the snr and mse ( tables 3 , 4 , and 5 ) . in addition , taking into account similar eeg preservation ( same snr and mse ) , oma is shown to be more effective in attenuating the artefact in the overall frequency bins ( figure 11 ) , especially in higher - frequencies ( above 100  hz ) . thus , this characteristic can avoid the use of further processing methods such as adaptive noise cancelling ( anc ) and low - pass ( lp ) filtering that may contribute to suppressing high - frequency activity of the neuronal eeg . this is a substantial conceptual advantage compared to aas , in which postprocessing is essential to remove residual artefacts [ 14 , 25 , 26 , 28 ] . therefore , these results indicate that oma can lead to a better balance for the trade - off artefact attenuation and eeg preservation , thus outperforming the slice - average subtraction by aas . better preservation of the corrected eeg in low - frequencies was also achieved by oma , as shown in tables 3 , 4 , and 5 . the snr closer to unity and the smaller values of the mse reflect smaller difference between the reference eeg , eref , n , and its estimate , e^ref , n , after application of oma than aas . thus , it confirms an improved preservation and less distortion of the eeg signal by using oma . yet , baseline correction has not been performed before application of oma , whereas it has been carried out before aas . this evidences that oma is more robust to the alterations of the artefact waveform caused by small drifts and movements of the subject head . the inherent uncertainty ( standard deviation ) associated with averaging epochs provoked by alterations in the artefact waveform because of small drifts as well as subject head motions may lead to an inaccurate estimation of the average artefact template . contrary to aas , gradient artefact estimation by our method does not rely on calculation of an average template . rather , implementation of oma is individually performed sample - by - sample according to application of the oma filter indicated in ( 10 ) , whose uncertainty is influenced by artefact waveform alterations that occur in samples of the scalp potential raging from snm+1 to sn+m1 . in case of aas , it is affected by artefact waveform alterations that occur in those 2 m + 1 sliding average windows considered for average template construction , whose samples range from snmm to sn+mm ( see appendix ) . hence , it explains why oma is less affected by small drifts and subject head movements than aas . as reported by mandelkow et al . , synchronisation between the eeg sampling interval and the fmri acquisition clock leads to increasing of the usable bandwidth in the corrected eeg up to around 150  hz after average template subtraction . since oma is capable of provoking larger attenuation of the artefact activity in higher - frequency bins , this shows that our proposed approach could be used to produce further broadening of the usable bandwidth of the corrected eeg . as shown in figures 10 and 11 , by using oma , satisfactory attenuation in the artefact frequency bins the study of high - frequency neuronal activity between 100 and 500  hz has currently received increased attention and requires the use of customised fmri sequences that are generally not available to all investigators [ 17 , 20 , 34 ] . furthermore , it makes use of an interleaved fmri protocol , which has been shown to be less effective and flexible than continuous fmri measurements . therefore , the usage of oma could be useful in eeg - fmri studies that address those high - frequencies oscillations . as depicted in figure 10 , implementation and application of oma also have no dependency on interpolation or slice - timing correction between the slice - length and the eeg sampling interval [ 14 , 21 , 27 , 33 ] . this characteristic suggests that our approach can produce satisfactory results even when there are jitter errors between fmri clock and eeg sampling rate . albeit reduction of jitter by using hardware synchronisation solutions has become increasingly available and oma is shown to provide better results within a scenario of alignment between tr - slice and the eeg sampling interval ( philips data ) , ( 16 ) reveals representing a general analytical expression that allows satisfactory estimation and suppression of the gradient artefact in scenarios either with or without the occurrence of such timing errors . moreover , our method is data - driven , not requiring accurate information about mri triggers and events to be implemented [ 14 , 25 , 26 , 34 ] . the approach depicted in figure 6 proposed for evaluation of eeg preservation is shown to simplify the implementation of this measurement , so that there is no need to perform comparison of spectral power of excerpts of the reference eeg , eref , n , with corrected eeg excerpts , e^true , n , as is usually performed in the literature [ 14 , 34 , 35 ] . since the power spectrum represents an average measure of the frequencies contained in the time - domain signal , spectral power associated with artefact residuals might be masked in the power spectrum of e^true , n , which can compromise this kind of analysis . application of the artefact correction approach directly in the reference eeg [ 34 , 35 ] also has the disadvantage of not accounting for the influence of the artefact , which might impair the accuracy of the assessment of eeg preservation by using such a procedure . furthermore , the stochastic nature and the lack of knowledge of the neuronal eeg make it imprecise to compare the power spectrum of the artefact - corrected eeg with the spectrum of the reference eeg recorded inside or outside the scanner . therefore , evaluation of eeg preservation by quantification of power in certain spectral bands should always be performed together with evaluation of eeg preservation in time - domain in order to obtain a more precise measurement . on the other hand , the assessment of single events is not suitable to account for the stochastic and nonperiodic nature of the neuronal eeg . all these characteristics can be effectively accounted for by using the time - domain scheme depicted in figure 6 . the selectivity of the oma filtering , that is , the amount of attenuation of the gradient artefact together with the degree of eeg preservation , is influenced by the slice - length ( tr - slice or m ) and the values of j and l. therefore , combination of proper values of those parameters should be taken into account to obtain an optimal balance between artefact attenuation and eeg preservation . in this respect , the assessment indicated in tables 25 and figure 11 could be used to choose the values of j and l according to the value estimated for m , as well as obtaining an optimal selectivity . additionally , the eeg sampling frequency should be taken into account as well , since it can influence the value of m. some preliminary investigations suggested that oma might be used to satisfactorily produce eeg correction for lower eeg sampling frequencies ( around 500  hz ) , provided that the gradient artefact waveforms are well reproduced in the scalp potential . further , oma might be applied when empty gaps occur between volume acquisitions , by setting m as tr - slice followed by tr , without substantial degradation of the eeg quality . these characteristics should be better assessed in future work . as further suggestion for future work , oma should be applied and generalised for other types of eeg data recorded in other types of mr scanners as well as for correction of other types of periodic artefacts , such as the artefact that affects the scalp potential during electrical impedance tomography . because of the computational efficiency of the oma filter ( homa ) , ( 15 ) and ( 16 ) are not computationally demanding either , in addition to possessing quite low complexity of implementation . thus , the time to compute our proposed approach is quite low and comparable with the processing time of the mean template subtraction performed by the brain vision analyzer software . equations ( 15 ) and ( 16 ) also allow using noninteger values of m , according to the estimated value of tr - slice , which can be used to reduce the effect of jitter errors on the comb - filtering performance as well . regarding the use of ( 11 ) , some problems that arise are the substantial ringing effects in the signal ends provoked by the recursive application and subtraction of the components of the corrected eeg as well as the increased computational load . thereby , ( 15 ) and ( 16 ) should preferably be used in order to minimise such problems . such characteristics and the evaluation metrics utilised here constitute the innovative outcomes of this work in comparison with some previous results presented by our group [ 38 , 41 , 42 ] . last , we noticed that the performance of oma might be compromised with the occurrence of eeg amplifier saturation , as also observed for the aas method . thus , band limiters are needed to reduce the eeg system dynamic range and prevent saturation of the eeg amplifier during eeg data acquisition . in this work , we have shown the efficacy of using optimised moving - average filtering ( oma ) for suppression of the gradient artefact from the scalp potential recorded during continuous eeg - fmri . oma constitutes a comb - filtering approach , whose application in the scalp potential allows suppression of the gradient artefact and simultaneous estimation of the neuronal eeg . when compared with the slice - average subtraction as performed according to the established average artefact subtraction ( aas ) methodology , oma is revealed to be capable of obtaining an improved balance compared to aas for the trade - off between effective suppression of the gradient artefact and preservation of the eeg signal . in this respect , oma can provide larger attenuation in higher - frequency artefact bins and be less affected by artefact waveform alterations owing to small drifts and subject head motions . in addition to being data - driven and not requiring accurate information about mri trigger and events , oma also is shown to satisfactorily correct the eeg signal in scenarios either with or without misalignment between the eeg sampling interval and the mr slice - time . finally , besides effectively accounting for the stochastic and nonperiodic nature of the neuronal eeg , our proposed approach for evaluation of eeg signal preservation is shown to simplify the implementation of this measurement . such characteristics indicate that our methodology can help to improve the quality of the eeg signal recorded during fmri as well as the performance evaluation of the gradient artefact correction approaches and thus contribute to the consolidation of coregistered eeg - fmri .
over the past years , coregistered eeg - fmri has emerged as a powerful tool for neurocognitive research and correlated studies , mainly because of the possibility of integrating the high temporal resolution of the eeg with the high spatial resolution of fmri . however 
 , additional work remains to be done in order to improve the quality of the eeg signal recorded simultaneously with fmri data , in particular regarding the occurrence of the gradient artefact . 
 we devised and presented in this paper a novel approach for gradient artefact correction based upon optimised moving - average filtering ( oma ) . 
 oma makes use of the iterative application of a moving - average filter , which allows estimation and cancellation of the gradient artefact by integration . additionally , oma is capable of performing the attenuation of the periodic artefact activity without accurate information about mri triggers . by using our proposed approach , 
 it is possible to achieve a better balance than the slice - average subtraction as performed by the established aas method , regarding eeg signal preservation together with effective suppression of the gradient artefact . 
 since the stochastic nature of the eeg signal complicates the assessment of eeg preservation after application of the gradient artefact correction , we also propose a simple and effective method to account for it .