Camera-based Prospective Motion Correction in Paediatric Epilepsy Patients Enables EEG-fMRI Localization Even in High-motion States

Background: EEG-fMRI is a useful additional test to localize the epileptogenic zone (EZ) particularly in MRI negative cases. However subject motion presents a particular challenge owing to its large effects on both MRI and EEG signal. Traditionally it is assumed that prospective motion correction (PMC) of fMRI precludes EEG artifact correction. Methods: Children undergoing presurgical assessment at Great Ormond Street Hospital were included into the study. PMC of fMRI was done using a commercial system with a Moiré Phase Tracking marker and MR-compatible camera. For retrospective EEG correction both a standard and a motion educated EEG artefact correction (REEGMAS) were compared to each other. Results: Ten children underwent simultaneous EEG-fMRI. Overall head movement was high (mean RMS velocity < 1.5 mm/s) and showed high inter- and intra-individual variability. Comparing motion measured by the PMC camera and the (uncorrected residual) motion detected by realignment of fMRI images, there was a five-fold reduction in motion from its prospective correction. Retrospective EEG correction using both standard approaches and REEGMAS allowed the visualization and identification of physiological noise and epileptiform discharges. Seven of 10 children had significant maps, which were concordant with the clinical EZ hypothesis in 6 of these 7. Conclusion: To our knowledge this is the first application of camera-based PMC for MRI in a pediatric clinical setting. Despite large amount of movement PMC in combination with retrospective EEG correction recovered data and obtained clinically meaningful results during high levels of subject motion. Practical limitations may currently limit the widespread use of this technology. Supplementary Information The online version contains supplementary material available at 10.1007/s10548-023-00945-0.


Introduction
way to approach this problem is to correct for motion in fMRI retrospectively, though in several approaches like scan nulling or scrubbing there can be a relevant data loss (Lemieux et al. 2007;Power et al. 2014). FIACH (Functional Image Artefact Correction Heuristic) is a tool which has been shown to effectively remove non-physiological signal changes in a two-step procedure by identifying and correcting large amplitude signal changes and modelling the effects of regions of high temporal instability (Tierney et al. 2016b). While a variety of other post-processing methods can be used to reduce the impact of motion, data during unique clinical events cannot be discarded and residual errors can make results hard to interpret (Power et al. 2015) or even lead to false activations (Hajnal et al. 1994).

EEG Data Quality Corruption
There are two major contributors to head motion-related degradation of EEG quality acquired with simultaneous fMRI. The first is related to the Faraday's law of induction, where the temporal derivative of the magnetic flux through an area composed by electrode, wire and head may induce voltages that will be added to electrical signals measured by the electrode. The second motion-related artefact is associated with the disruption of the gradient artefact's temporal stability. Typically, the gradient artefact (GA) correction is performed by averaging consecutive EEG epochs to create a template and further subtracting it from the total signal measured. This operation considers that the voltages generated by the applied time varying magnetic fields to acquire fMRI data are similar for successive fMRI slices or volumes (Allen et al. 2000). Therefore, GA correction becomes more challenging when motion decreases its stationarity. However, recent work (Maziero et al. 2016) suggests that though the temporal stability of the GA is reduced by motion, it is not further reduced by applying effective prospective motion correction (PMC) during fMRI data acquisition. In fact, applying PMC to fMRI data seeks to maintain the spatial relationship between the EEG equipment (moving with the head) and the switched magnetic fields used for imaging in terms of their relative angle. The motion information can be used to model and remove GA temporal changes (Maziero et al. 2021) and vice-versa (Laustsen et al. 2021).

Applications of PMC
Previous work in analyzing the use of PMC has mainly focused on an experimental setting with healthy subjects and a motion, no-motion condition Todd et al. 2015;Zaitsev et al. 2006;Maziero et al. 2020). Here, for the first time we use prospective motion correction in a pediatric clinical population undergoing EEG-fMRI using a commercially available motion correction system.
The application of PMC in a pediatric clinical cohort has the possible advantage of bypassing the need for sedation, which reduces motion, but potentially suppresses epileptic activity and thereby lessens the diagnostic yield (Siniatchkin et al. 2018). Image realignment is an effective strategy to reduce motion effects (Friston et al. 1996) however it can only correct motion occurring on a timescale substantially less than the rate of image acquisition (typically several seconds). This leaves residual motion that can cause large amplitude residual signal changes (Tierney et al. 2016b;Beall and Lowe 2014). One option is to effectively remove affected volumes using additional regressors within the general linear model (Lemieux et al. 2007), however, this affects detection power particularly when many volumes are affected. Prospective motion correction can mitigate these effects by updating the acquisition of each slice (at a timescale of 50-100ms) to remain consistent with the subject's anatomy by updating imaging gradients. However, it relies on accurate knowledge of subject's position to correctly move the imaging slice, otherwise it can potentially introduce unwanted variability in slice location (for example when the subject is still) leading to greater fMRI signal instability. EEG artefact correction relies on the temporal repetition of the artefact created by switching magnetic field gradients for imaging. In previous work, we have shown that provided the motion information is accurate then the EEG gradient artefact is sufficiently stable, although this is reliant on maintaining the same relative orientation between the imaging gradients and EEG circuitry (Maziero et al. 2020). Therefore, reliable prospective motion correction has the potential to reduce motion-related noise in fMRI while maintaining EEG quality. However, inaccurate motion information will lead to corruption of both EEG and fMRI during prospective motion correction.
The goal of the current study was to perform EEG-fMRI with prospective fMRI correction and retrospective EEG correction and evaluate the feasibility and effectiveness of this approach. In particular we wanted to: 1) Assess EEG quality during prospective fMRI correction using standard and motion model EEG correction approaches. 2) Assess if effective suppression of head motion in fMRI could be achieved in a clinical pediatric population. 3) Use these to evaluate the motion tracking performance. 4) Provide face validity of the epilepsy localization achieved using motion correction.

Subjects
Children (4 Female, mean age: 14 Years), with drug Resistant Focal Epilepsy Underwent Simultaneous EEG-fMRI. Recruited patients were undergoing evaluation for epilepsy surgery at Great Ormond Street Hospital (London, UK). Inclusion criteria for the study were: participant ages between 8 and 18, diagnosis of drug-resistant focal epilepsy and frequent epileptiform discharges in their video-EEG telemetry.

Motion Measurement and fMRI-prospective Motion Correction
Motion parameters were continuously recorded throughout the whole scan as has been described in previous work coming from our group (Maziero et al. 2021): In summary a MR-compatible camera (Metria Innovation Inc., Milwaukee, USA) was used for tracking a Moiré-Phase-Tracker (MPT) marker (Maclaren et al. 2013) attached to a 'bite bar' that was specifically produced for each subject based on a dental retainer. The camera-tracker system was used to record head motion with six degrees of freedom, three translations (x, y and z axis, defined as right-left, posterioranterior and feet-head, respectively) and three rotations (about x, y and z axis, respectively) with a sampling rate of 80 Hz. The motion parameters were logged on a computer located outside the scanner room. The motion parameters were used to update the Radio Frequency (frequency offset encoding slice position) and Magnetic Field Gradient orientation before the acquisition of every fMRI slice (Maclaren et al. 2013;Todd et al. 2015) to achieve prospective motion correction of fMRI data.

EEG-fMRI Acquisition
Patients were prepared with a 64-electrode MRI-compatible EEG cap (Easy Cap; Brain Products, Gilching, Germany). EEG data was acquired using a sampling rate of 5 kHz, band-pass filtered at 0.016 Hz-1 kHz with 16-bit digitalization (0.5µV resolution). Prior to starting the simultaneous EEG-fMRI, a ten-minute duration baseline EEG recording was acquired.
All images were acquired at Great Ormond Street Hospital, London, United Kingdom, using a 3T MRI System (Siemens Prisma, Erlangen, Germany) with a 64-channel head-neck RF coil.

EEG Post-processing
We used two different approaches to correct artefacts present on the in-scanner EEG data. Firstly, Average Artefact Subtraction (AAS), as implemented within BrainVision Analyzer2 (Brain Products, Germany) was used to remove MR gradient (Allen et al. 2000) and pulse-related artefacts from the EEG (Allen et al. 2000). The EEG was then down sampled to 250 Hz and filtered between 0.5 and 70 Hz for visual review.
Secondly, we applied REEGMAS (Maziero et al. 2016), an in-house code developed in Matlab 2015a (www.mathsworks.com). REEGMAS consists of a linear regression of a model derived from the motion parameters that is applied to the EEG data before proceeding with standard gradient artifact (GA) and cardiobalistic artifact (BCG) correction by AAS (Maziero et al. 2021). We averaged 15 slices, each with a slice TR = 60ms, to generate a gradient artefact template for both BrainVision and REEGMAS. To apply REEGMAS, a model of motion induced voltages is formed from the 6 motion parameters (3 translation and 3 rotations) recorded by the MPT-camera system, their temporal derivatives (6 velocity parameters), and the derivatives squared. The motion data for EEG correction was filtered at 11 Hz. While the camera parameters are sampled at 80 Hz, the EEG data is sampled at 5 kHz. Motion and EEG datasets were synchronized to a frequency of 500 Hz; therefore, the camera data was up-sampled (from 80 Hz) and the EEG data down-sampled (from 5 kHz).
Review of EEG data to identify interictal epileptic discharges (IED) and ictal events was made by MS, MC and FM. In cases where no clear IEDs could be identified focal slowing with sharpened transients were marked. The events were marked within Brain Vision Analyzer2 and then exported to be later included in further analysis steps.

Analysis of Motion Parameters fMRI
Perfect motion correction would result in entirely flat motion realignment parameters and high tSNR. To determine the degree to which the PMC system had removed motion variability in image position we compared the six realignment parameters (exported from SPM) and FIACH noise regressors (representing residual noise components) to PMC. Additionally, we compared FIACH tSNR and number of voxels replaced between subjects and sessions. 1. Visual assessment of different approaches of post-processed EEG (BrainVision Analyzer 2, REEGMAS): We visually compared patients' differently corrected EEGs for each of their EPI sessions, particularly focusing on the parts with heavy motion as well as those where epileptiform activity could be identified. 2. The variance of each EEG run acquired simultaneously to the fMRI data was evaluated. In this study each fMRI slice was acquired in 60 ms and the EEG date were down-sampled to a rate of 500 Hz, which resulted in 30 sampling points for each epoch. We estimated the variance of each sample point across the entire fMRI acquisition for data resulting from the templates used for standard EEG GA correction (EEG GA ) done with Bra-inVision Analyzer 2 and REEGMAS (EEG REEGMAS ). Additionally, we evaluated the variance of each one of the 30 sampling points on the EEG before applying any correction (Raw EEG). The average variance was calculated considering the variances of all electrodes except the ECG channel. The averaged variances were compared among each other using ANOVA with correction for multi-comparisons (p < 0.05). 3. EEG power spectral density (PSD) was calculated by applying the Welch method (pwelch.m function). The spectra were obtained by considering a Hamming window of 3s with 1.5s of overlap. The PSD was normalized at each frequency by sampling rate and the number of samples within each window (dB/Hz). The averaged PSD was calculated considering all the data acquired through a fMRI run. We also calculated two standard deviations above and below the average PSD, we have assumed that points laying outside this range are likely to be related to residual artefacts.

Pre-processing
The fMRI data was analyzed using Statistical Parametric Mapping (SPM) software version 12. As described previously in work coming from our group  after having discarded the first five scans, MRI pre-processing consisted of volume-volume realignment (Friston et al. 1996) as implemented in SPM producing six realignment parameters (RP) followed by retrospective motion correction with FIACH (Tierney et al. 2016b). The FIACH correction produced six noise parameters (values for FIACH tSNR and number of voxels replaced). FIACH detects jumps in signal intensity that are not physiologically plausible whose predominant cause is bulk head movement, this is expressed in the number of voxels that needed to be replaced. The tSNR is the temporal signal to noise ratio, which takes into To measure motion and its residuals, we calculated the root-mean-square (RMS) for each of the six Euclidian displacements derived from motion measurements (PMC and realignment parameters) and determined the minimum and maximum amplitude on the axis with the largest RMS. Since data for the PMC was acquired at 80 Hz and the realignment parameters (RPs) per every 2.4 s, we down sampled the PMC data to match temporal frequency of the RPs (i.e. per TR).
We additionally assessed the severity of head motion by calculating the total speed for each time point as previously described : The directions of the head translations (in mm) are defined for X (left-right), Y (antero-posterior) and Z (foot-to-head) axes, and Rx, Ry and Rz the corresponding rotations (in degrees). To assure equivalence among rotations and translations, we have assumed a rotational radius of 5.7 cm as previously described .
We calculated the averaged speed within a volume (ASV) as previously defined (Maziero et al. 2020) to summarize the motion recorded by the camera during each fMRI TR into one time point as follows: where TC is the number of camera sampling points within each fMRI volume and j is each sample point acquired by the camera during that volume and s is the total speed for each sample acquired by the camera. The ASV is calculated for every fMRI volume and results in a time course of similar length to each fMRI session duration and represents a marker for total motion (Maziero et al. 2020). Finally, we calculated the average of the ASV peaks for each run, therefore we could summarize motion in one measurement for the entire run. The peaks were defined by choosing the motion events that exceeded the mean plus two standard deviations considering the ASV time course of each run. Finally, the maxima of the individual peaks from each fMRI run were averaged. This reflected the average of maximum speeds reached each time patients moved.

EEG
We applied different analyses to evaluate the impact of patient's motion on the quality of the EEG data acquired simultaneously to fMRI.
are implanted directly into the brain before performing epilepsy surgery.
To inform us whether EEG-fMRI maps had adequately localized the epileptogenic zone (EZ) we used the clinical focus hypothesis from notes of the latest epilepsy surgery meeting including information from icEEG where it was available. EEG-fMRI results were considered well localizing if localization and lateralization were concordant with the clinical focus hypothesis, or partly concordant if lateralizing to the same hemisphere.

Results
Ten children with drug-resistant focal epilepsy were recruited and underwent simultaneous EEG-fMRI. Median age of patients was 14 years, median age at onset of epilepsy was 7 years, median duration of epilepsy was 5 years and 40% of patients were female.
All patients received a 10-minute duration EEG recording outside of the scanner and completed 2 of 3 possible EEG-fMRI recording sessions ("runs"). Nine out of ten patients started three EEG-fMRI runs; four runs in three patients were cut short, due to these children not tolerating the scanning process for different reasons.
In nine out of ten patients motion tracking was performed and used for prospective fMRI correction, in one case it was not possible due to technical difficulties. Eight patients had epileptiform activity in their EEG which could be further analyzed; in three of these ten, sufficient well-defined isolated discharges were identified enabling ESI analysis. In the only patient without motion tracking, no epileptiform discharges were identified and therefore they could not be included in either of the analyses. In one further patient with motion tracking, no epileptiform discharges were recorded during the measurements and could be included only in motion evaluations.

Motion Correction for EEG
We sought to determine EEG quality during prospective motion correction with and without the incorporation of motion information into the retrospective EEG correction procedure.

Visual Assessment
In 8 out of 10 EEGs it was possible to visually identify epileptiform activity during prospective motion correction. In most of those cases interictal epileptiform discharges (IEDs) could be equally well identified by visual assessment in both outside and inside scanner EEG (online resource 2). The account the signal changes over time in an fMRI time series (Welvaert and Rosseel 2013). For the fMRI data to conform to the assumptions in gaussian random field theory smoothing should be 3-4 times the voxel size as a minimum (Worsley 2004;Tierney et al. 2016a). In a next step slice timing correction and smoothing with a 12 mm kernel was applied to the FIACH-processed images. Images were analyzed in the subject's space.

EEG fMRI Maps
For creating epileptiform-activity related maps, pre-processed data from fMRI and simultaneous acquired EEG (exported IEDs/sharpened transients) were analyzed in a general linear model (GLM) in SPM. Additionally, we entered the six realignment parameters and six FIACH noise regressors into the GLM as effects of no interest.
Significant epileptiform activity-related BOLD signal changes were tested with an F-test across the three included regressors (canonical hemodynamic response function (HRF) and its two temporal derivatives). Changes in BOLD signal were considered significant above a threshold with p < 0.001 (uncorrected) and a cluster size voxel with a minimum of 5 contiguous voxels (Centeno et al. , 2017.

Electrical Source Imaging
Only patients with clear-defined spikes captured during their EEG-fMRI sessions had electrical source imaging (ESI) analysis. Spikes were marked manually after removal of scanner artefacts and motion correction. In BrainVision Analyzer 2 marked events were used to calculate the electrical source image using Cartool (Version 3.70, Creative Commons, https://sites.google.com/site/cartoolcommunity/) and followed the procedure described by Vulliemoz et al. (Vulliemoz et al. 2009).

Comparison of Results to Clinical Localization
In clinical standard practice all patients in presurgical assessment receive a video-EEG-telemetry with surface electrodes, a 3T MRI with epilepsy protocol and neuropsychological testing. The results are then discussed in a multidisciplinary epilepsy surgery meeting and a consensus reached whether the epileptogenic zone had been adequately localized (clinical focus hypothesis) to make an informed decision regarding surgery. In case of discordance of results, non-lesional MRI or suspected bilateral epilepsy further diagnostics can be added, e.g. FDG-PET or ictal-SPECT. If further information about surrounding eloquent areas or more exact localization is needed an intracranial EEG (icEEG) would be acquired, where several electrodes than standard AAS correction, though significant motionrelated artefacts remain.

Variance of EEG data
The variance on the data following the correction with REEGMAS was significantly smaller (p < 0.05, corrected for multi-comparison) than the variance on the raw EEG for 25/26 runs (all but patient 9, run 1) (Fig. 4).
The variance on the data following standard AAS template for GA correction was significantly smaller (p < 0.05, corrected for multi-comparison) than the variance on the raw EEG for 23/26 runs (all runs of all patients with the exception of patient 8, runs 1 and 2 and patient 9, run 1) (Fig. 4). The variance on the data following correction by REEGMAS was significantly smaller (p < 0.05, corrected for multi-comparison) than the variance present on the data corrected by standard AAS in 24/26 runs (for all runs of all patients but patient 8, run 1 and patient 9, run 3) (Fig. 4).

EEG Power Spectral Density (PSD)
The EEG data correction using REEGMAS exhibited lower spectral power at low frequencies (< 10 Hz) in comparison to the data corrected by standard AAS in 24/26 runs (all results of template artifact corrected EEG and REEGMAS were visually similar during periods of low or high motion (see examples in Figs. 1 and 2). During low motion both retrospective EEG correction methods allowed the visualization and identification of physiological noise and epileptiform discharges if present (Fig. 1).
During periods of high motion, both methods showed significant limitations with periods of EEG data corruption that precluded event detection (Fig. 2). An estimate of the ability of the camera system to track and therefore prospectively correct the subject motion can be obtained by comparing the motion measured by the camera and the (uncorrected residual) motion detected by realignment of fMRI images.
Comparing these, there is a five-fold reduction in motion from the prospective motion during low and high motion in the given examples ( Figs. 1 and 2). In Fig. 2 it seems that due to the large extent of motion (± 7 mm in PMC data) there was significant residual motion visible in the realignment motion data. Translations are likely to result in GA artefact changes, while residual uncorrected rotations of this magnitude could not recover the EEG data.
In a further example with high movement detected by the PMC camera, but corresponding flat RP parameters (Fig. 3), REEGMAS has recovered the data slightly better Fig. 1 Example of EEG correction from (patient 2, run 2; Brain Vision Analyzer 2 and REEGMAS), 50 s duration, during a period of low motion as indicated by PMC (± 2.5 mm) and RP data (± 0.5 mm) low movement. The other seven patients moved in varying degrees over their sessions, which is also expressed by their average ASV peak (Table 1). In some patients (e.g. patient 5, Fig. 6) there seem to have been a number of sudden, short fast movements during the scan (in the example shown in Fig. 6 mostly in the z-axis). The mean velocity of these events would indicate a high motion rate (Fig. 4).
The effect of fMRI prospective motion correction should be to minimize the spatial displacement of images through time. To determine the effectiveness of the prospective correction we compared the measured motion from the PMC system to both residual fMRI motion realignment and residual temporal signal discontinuities larger than typical BOLD signal changes. To analyze the impact of the different motion correction steps further we looked at the relationship between PMC, RP, FIACH tSNR and number of voxels replaced by FIACH. Since we wanted to assess the amount of movement without being influenced by extreme values, we decided to look at median values for this analysis. Linear regression of the root mean squares (RMS) of the median Euclidian displacement of the PMC data and of the patients except patient 4, run 2 and patient 6, run 3) (Fig. 5). The spectral power between 10 and 25 Hz frequencies was increased by REEGMAS correction compared to template correction for patient 3 (all runs), 5 (run 3), 6 (run 3) and 8 (run 2). An increase on power on the frequencies 16.3 and 33.2 Hz (harmonic) was observed for patient 8, run 2 (Fig. 5).
The power for EEG data corrected for standard AAS and REEGMAS was above or below the two-standard deviation of the baseline EEG for patients 2 (run 1 and 2), 4 (run 2), 7 (all runs) for a range of frequencies between 10 and 20 Hz (patients 2, 4 and 7) and for frequencies above 25 Hz (patient 7).

Motion-statistics for fMRI Metrics
Movement during EEG-fMRI sessions did not only differ between subjects but also within subjects across sessions. Three of ten patients moved less than the average of the group over all their sessions (mean RMS velocity < 1.5 mm/s), which in this context could be regarded as Fig. 2 Example of EEG correction (patient 2, run 2; Brain Vision Analyzer 2 and REEGMAS), 50s duration, during a period of high motion as indicated by PMC (± 7 mm) and RP data (± 1.4 mm) the correction. In the same session there is large motion towards the end in the PMC data and flat corresponding RP parameters, indicating effective motion correction by PMC system during this period.

Localization of the Epileptogenic Zone Through EEG-fMRI
Seven patients showed significant epileptic activity-related BOLD activation on EEG-fMRI maps, in five of them EEG-fMRI results were concordant with the clinical hypothesis. RP from SPM (Fig. 7) showed an F-ratio of 8.0 (F significance = 0.009), meaning that the variability of the data can be well explained by the model. The gradient of the model is 0.06, R 2 = 2.5 and adjusted R 2 = 2.2 (p = 0.009). This indicates that residual motion effects from the prospectively corrected data are related to subject head motion. The difference in magnitude of motion lies between 1.5 and 4.5 mm for the PMC and 0.04 to 0.35 mm for the RP. This means that after prospective motion correction less than 10% residual motion remains. Though when motion was high (> 4.3 mm) residual motion was high as well. Figure 3 shows the temporal course of motion parameters of fMRI run 2 of patient 4, that corresponds to the outlier outside the confidence interval (2.15, 0.32) in Fig. 7. There are three large peaks of residual motion in the RP data, in the corresponding camera data of actual motion no peaks are visible. Prior to each peak there is continuous motion in the PMC data ending just before the peak in the RP data, which could indicate overcorrection or delay in the end of

Discussion
Simultaneous EEG-fMRI can add valuable information on the localization of the epileptogenic focus in patients with drug-resistant focal epilepsy undergoing presurgical assessment (Markoula et al. 2018). This has been shown repeatedly in epilepsy patients using both scalp (Salek-Haddadi et al. 2006;Chaudhary et al. 2012;Centeno et al. 2017;Kowalczyk et al. 2020;Koupparis et al. 2021) and intracranial EEG (Chaudhary et al. 2016) simultaneously recorded to fMRI.
Head motion artefacts remain the most important confounder when trying to reliably detect IED related BOLD responses. Retrospective metrics to remove motion artefacts from fMRI often remove a large percentage -in some cases all -of the relevant data (Power et al. 2014). Therefore, removing motion effects from fMRI and EEG data while still retaining the relevant clinical information remains an ongoing challenge (Zaitsev et al. 2017;Power et al. 2014;Maziero et al. 2016).
In all three patients in whom ESI was feasible, ESI localization was concordant or partly concordant with EEG-fMRI results. An overview of EEG-fMRI and ESI results in comparison to the clinical hypothesis made after telemetry, structural MRI and FDG-PET can be seen in Table 2 and a visual example of fMRI and ESI results in Fig. 10 (further ESI results are presented in Online Resource 1).
Finally, five (patients 3, 4, 5, 6 and 9) out of 10 patients were offered invasive EEG-recordings to localize the seizure onset zone using SEEG. Four patients (patients 3, 4, 5 and 6) went through with the procedure. In one patient (patient 5) this resulted in epilepsy surgery using laser interstitial thermal therapy (LiTT). The patient showed a significant improvement of the seizures (ILAE 3) (Durnford et al. 2011) one year after surgery. In the other three patients no clear surgical target could be identified through SEEG. The remaining five patients were not considered suitable candidates for SEEG or surgery. Fig. 4 Averaged variances of raw EEG data and EEG data post correction using the different correction methods for data acquired simultaneously to prospective motion corrected fMRI. For each patient and fMRI run the variance was calculated for each slice TR and from these the average variance was calculated for the raw EEG (blue), EEG corrected for GA using standard AAS (red) and REEGMAS (yellow) considering all electrodes but excluding ECG. The standard error on the mean variance is presented by the error bars. The blue * highlights templates with averaged variance significantly smaller than the variance of the Raw EEG and the red * highlight runs where the average variance for the data corrected by REEGMAS are significantly smaller than the variance of the data resulting from standard AAS GA correction

Quality of EEG Correction
Despite the traditional assumption that prospective motion correction of fMRI precludes EEG artifact correction, we have shown that EEG can be recovered and motion information incorporated into the correction. The impact of this is contingent on the quality of the tracking information and level of motion.
Visually we did not detect relevant differences in the quality of corrected EEG comparing AAS vs. REEGMAS, though previously reported results for REEGMAS had been better (Maziero et al. 2016(Maziero et al. , 2021. We used the same parameters for both EEG correction approaches. However, it is Motion artefacts in MRI are particularly challenging in pediatric populations (Poldrack et al. 2002;Brown et al. 2010), though it has been shown that EEG-fMRI can be applied successfully in that group Moeller et al. 2013).
In this study we demonstrate the effect of combined prospective and retrospective motion correction on the results of simultaneous EEG-fMRI obtained from 10 unsedated children with drug-resistant focal epilepsy. Even though the general amount of head movement in the scanner was high, relevant clinical information was still recovered from the motion-corrected EEG-fMRI.

Fig. 5
The mean power spectral density (PSD) at electrode Fp1 for each patient. The mean PSD for each patient is presented for the EEG run with the highest averaged variance for the Raw EEG data (Fig. 5). The shaded grey area represents two standard deviations from the mean baseline spectra obtained from EEG data from outside the MRI scanner. The blue curve refers to the mean power spectra of the EEG acquired in-scanner but not corrected by REEGMAS and the red dashed line to the same data corrected by REEGMAS. Electrode Fp1 is shown due to its clinical relevance for this patient population baseline data and therefore a better metric to compare AAS vs. REEGMAS EEG corrections. This demonstrated that the EEG variance following correction by REEGMAS was significantly smaller than when corrected by standard AAS. We note that REEGMAS has a greater reduction in EEG spectral power in the ~ 0-10 Hz range owing to the choice of a filter on the motion data (11 Hz). Although a greater range of frequencies could be used in general head motion is predominantly within this range.
The activity of interest (epileptiform activity) could equally been identified using both methods of EEG correction, meaning that the REEGMAS method does preserve this EEG feature for visual identification and it is reasonable to use in patients with epilepsy.

Quality of fMRI Correction
Prospective motion correction of fMRI can be utilized for EEG-fMRI. We demonstrated a substantial improvement in fMRI data quality after prospective motion correction in the context of subject motion. possible that some minor differences between implementations remain.
It should be noted that the baseline EEGs for comparing Power Spectral Density obtained out-of-scanner have strong signals related to motor activity and muscle-related artefacts which contrasts with previously published data (Maziero et al. 2016), where very clean EEG data with a well-defined alpha rhythm and without any strong physiological-related artefact in healthy adults were obtained and analyzed. This potentially biases assessment based on Root Mean Square Error (RMSE) as has been used and published previously (Maziero et al. 2016). When computing RMSE on the current data we noticed that there were many runs where the RMSE was reduced at low frequencies for REEGMAS compared to AAS, making AAS appear more similar to baseline levels (Fig. 5). This may give the false impression that AAS is providing better correction than REEGMAS whereas this is at least in-part related to noise sources in the physiological baseline recordings. Instead of an RMSE analysis we looked at the variance of the gradient artefacts across all epochs of each slice, because it is not affected by 23.26 0.62 9 SD: standard deviation; Max: maximum; ASV Peaks: averaged speed and number of peaks within a volume. *sessions with very high velocities marked here are most likely due to the PMC camera losing the tracker rather than actual movement happening Fig. 7 Linear Regression of median root mean square (RMS) of realignment parameters (RP) and RMS of Euclidian displacement of measured motion from the prospective motion correction (PMC); 95% CI: 95% confidence interval Fig. 6 PMC velocity in mm per second and Euclidian displacement as detected by the PMC-camera system and realignment parameters (RP) of the first fMRI run of patient 5. At approx. 480 s a very large peak can be seen. Occurring mostly in the z-axis to give an estimate of the ability and quality of prospective motion correction. In theory, perfect correction by PMC Measures like realignment parameters of fMRI images, as well as FIACH tSNR and replaced voxels can be used Fig. 9 Median RMS of Euclidian displacement of prospective motion correction (PMC) over FIACH voxels replaced; y = slope x intercept; 95% CI: 95% confidence interval Fig. 8 Linear Regression of FIACH tSNR and median RMS of Euclidian displacement of prospective motion correction (PMC); 95% CI: 95% confidence interval Currently two types of PMC can be distinguished: Head motion is tracked by either a MR navigator (working in image space or k-space) or alternatively through a MR compatible external tracking device (stereo camera systems, miniature RF probes, in-bore camera systems or ultrasound systems) potentially with an added device mounted on the subject  as we have used in this study. The general advantages of using PMC are that it reduces spin-history effects and simplifies the approach by not requiring sequence-specific modifications needed for MR navigators . Once setup it is flexible in its application since it is valid for all current field strengths on most clinical scanners (Maclaren et al. 2013) and for fMRI in particular it has been shown to reduce motion induced false positive activations (Schulz et al. 2014).
Limiting factors of PMC are among other things the accuracy and precision of the tracking system, besides gradient imperfections and B0 inhomogeneities, this is strongly influenced by a secure attachment of the marker, which in turn is contingent on a reasonable comfortability for the subject/patient (Maclaren et al. 2013). The marker was one of the major practical difficulties for this study. Firstly, children had to make two visits for the individual dental retainer to be fitted before the actual scanning session. Second, several children were observed to start to play with the dental retainer in their mouths leading to the decoupling of detected and actual motion. would lead to flat RP, high FIACH tSNR and zero replaced Voxels. However, the PMC camera cannot correct for the motion-related changes in B0 field homogeneity -for that dynamic shimming would be needed -meaning that even under perfect conditions some voxels would still be replaced because of susceptibility artefacts (Boegle et al. 2010).
We have shown that residual motion effects from the prospectively corrected data are related to subject head motion: After PMC less than 10% residual motion remained, the degree of residual motion in the images was related to the amount of motion measured from tracking. In general, this suggests that RPs should be included into the fMRI model as confounds.
The very high velocities detected in only one axis as for example displayed in Fig. 6 could be the result of the PMC camera losing the tracking signal, which led to a short peak in motion metrics, rather than actual movement. Alternatively, it is possible that the patients played with the bite bar in their mouths and created these events.
There are a number of retrospective motion correction approaches for fMRI where a set number of regressors (Power et al. 2014) or one regressors for each motion event (Lemieux et al. 2007) is added to the general linear model and through exclusion of motion-contaminated volumes the effect of motion in the overall dataset reduced. The strength of these approaches lies with the robustness of the results, though data cannot be recovered and particularly in subjects that move more the degrees of freedom in those datasets can be greatly reduced . showing them a cartoon, which led to reduced in-scanner movement . Though the latter might not always work, particularly in smaller children or those with additional mental disability. Sedation during EEG-fMRI is not practical if the aim is to use it to localize the epileptogenic zone (EZ) due to reduced epileptiform activity under sedation. Being able to use prospective motion in restive patients could greatly improve diagnostic yield and quality.
Most studies so far used retrospective motion correction to be able to receive high image quality in MRI in unsedated children, both for structural (Vecchiato et al. 2021;Kecskemeti et al. 2018) and functional MRI (Centeno et al. 2017).
In previous studies, the test yield (percentage of patients with significant BOLD activations) was reported as 29-89% and the localizing value of EEG-fMRI as 44-74% (Centeno et al. 2017;Salek-Haddadi et al. 2006;Grouiller et al. 2011). In our study seven out of 10 patients had a significant cluster on EEG-fMRI maps and those results were concordant with the clinical hypothesis regarding region and hemisphere in Previous studies investigating prospective motion correction during fMRI or simultaneous EEG-fMRI did so in young healthy adults with motion and no-motion conditions Maziero et al. 2016Maziero et al. , 2020, which is good for a proof of concept but far removed from the clinical reality. Here, it was established for the first time that significant clinically relevant data recovery is possible utilizing prospective motion correction techniques for EEG-fMRI data. Therefore, as motion tracking technology advances and reduces the practical limitations related to marker fixation prospective motion correction can play a significant role.

Validity of Localization of Epileptogenic Focus Through EEG-fMRI After Prospective Motion Correction
To be able to reliable obtain good image quality in children they often need to be sedated throughout the procedure (Siniatchkin et al. 2018). It has been shown to work in unsedated children by enhancing tolerability for children e.g. through The lower two panels show the amount of movement in the concordant fMRI run as recorded by the camera before (PMC) and after (RP) prospective motion correction to equally good results. Our data shows, that the combination of both prospective and retrospective motion correction enables recovery of otherwise lost data and leads to clinically relevant results through its added information on the localization of the epileptogenic zone.

Data Availability
The data that support the findings of this study are available from the corresponding author upon reasonable request due to privacy issues of clinical data. A formal data sharing agreement is needed.

Disclosure of Potential Conflicts of Interest
The authors declare that they have no known conflict of interest either financially or personally that could have appeared to influence the work reported in this paper.

Ethics Approval and Informed Consent statement
The study was approved by NRES Committee London -West London & GTAC Research Ethics Committee (REC). REC reference: 4/LO/2232. Written informed consent to participate in this study as wells as anonymized publishing of the results was obtained from all the participants' guardians and assent from the patients wherever possible.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons. org/licenses/by/4.0/. five cases (71%) and in one other case concordant with the hemisphere only (14%). Five patients received a recommendation for SEEG, four of which did undergo the procedure. Finally, one child underwent epilepsy surgery, with a good postoperative seizure outcome (ILAE 2) 2 years after surgery. In these previous studies a number of patients are excluded based on data corrupted by movement artifact. Overall, PMC was effective because despite large in-scanner movement in some of the children, we achieved concordant EEG-fMRI localization results in 6/7 of patients. To be able to make a definitive statement about concordance of EEG-fMRI results, relevant overlap of the EEG-fMRI results with the resected area and seizure freedom after surgery is the gold standard. This issue has been discussed in the past as surgical outcome is often not available (Salek-Haddadi et al. 2003). Nonetheless, it is a limitation of our study that only one patient underwent surgery and we had to rely on the clinical focus hypothesis as reference point in all other patients to judge concordance. Three out of four patients that underwent SEEG did not get a recommendation for surgery. EEG-fMRI results were concordant with the clinical focus hypothesis and had a spatial overlap with SEEG coverage in 2/3, but SEEG was inconclusive. Inconclusive SEEG results may put into question the validity of the prior clinical focus hypothesis, but one cannot falsify this hypothesis with certainty due to limitations in spatial coverage of SEEG. It is possible that within a large irritative zone (IZ) the seizure onset zone (SOZ) was missed, which can happen if SEEG electrodes are only a few millimetres off target (Zijlmans et al. 2019). Having these limitations in mind ESI was performed as an additional independent test where possible, to verify our EEG-fMRI results. Here we could show concordance of ESI with EEG-fMRI in 2/3 and partly concordance in 1/3. Concordance between EEG-fMRI and ESI means that we have two independent tests giving a localisation of the same interictal events. This meets our objectives of showing that the test has worked in that it has localised those events captured during the recording even during high motion levels. However, there remain potential limitations related to the possible discrepancies between the IZ identified at the time of recording and the SOZ defined by SEEG.

Conclusion
We present for the first-time feasibility of combined prospective and retrospective correction used on EEG-fMRI data in a pediatric cohort with drug-resistant focal epilepsy as a tool to localize the epileptic focus. We succeeded in doing so despite the traditional assumption that PMC precludes EEG artifact correction. Furthermore, a comparison of two retrospective EEG approaches (AAS and REEGMAS) led