Patient-independent, MHD-robust R-peak detection for retrospective gating in cardiac MRI imaging

Objective. In cardiovascular magnetic resonance imaging, synchronization of image acquisition with heart motion (called gating) is performed by detecting R-peaks in electrocardiogram (ECG) signals. Effective gating is challenging with 3T and 7T scanners, due to severe distortion of ECG signals caused by magnetohydrodynamic effects associated with intense magnetic fields. This work proposes an efficient retrospective gating strategy that requires no prior training outside the scanner and investigates the optimal number of leads in the ECG acquisition set. Approach. The proposed method was developed on a data set of 12-lead ECG signals acquired within 3T and 7T scanners. Independent component analysis is employed to effectively separate components related with cardiac activity from those associated to noise. Subsequently, an automatic selection process identifies the components best suited for accurate R-peak detection, based on heart rate estimation metrics and frequency content quality indexes. Main results. The proposed method is robust to different B0 field strengths, as evidenced by R-peak detection errors of 2.4 ± 3.1 ms and 10.6 ± 15.4 ms for data acquired with 3T and 7T scanners, respectively. Its effectiveness was verified with various subject orientations, showcasing applicability in diverse clinical scenarios. The work reveals that ECG leads can be limited in number to three, or at most five for 7T field strengths, without significant degradation in R-peak detection accuracy. Significance. The approach requires no preliminary ECG acquisition for R-peak detector training, reducing overall examination time. The gating process is designed to be adaptable, completely blind and independent of patient characteristics, allowing wide and rapid deployment in clinical practice. The potential to employ a significantly limited set of leads enhances patient comfort.


Introduction
Cardiac magnetic resonance imaging (CMRI or cardiac MRI) is a non-invasive medical imaging technique that provides three-dimensional detailed images allowing the assessment of the cardiovascular system function and structure.It is extensively employed in hospitals and clinical settings for the detection and diagnosis of heart disease (e.g.myocardial ischemia and viability, cardiomyopathies, myocarditis, iron overload, vascular diseases, etc), as well as for treatment monitoring (Smith-Bindman et al 2012).Cardiac MRI is also valuable in diagnosis and surgical planning for complex congenital heart diseases.
MRI scanners use strong static magnetic fields (B0), time-varying magnetic fields (gradients), and radio waves to obtain images of body organs and soft tissues.A static magnetic field of 1.5 Tesla is commonly used in clinical practice, but in recent years high-field (3 Tesla) and ultra-high-field (7 Tesla) imaging have also been developed to allow the visualization of smaller anatomical details, thanks to increased signal contrast, improved spatial resolution, and better signal-to-noise ratio (SNR) (Kraff et al 2015).However, MRI is a slow process that can require up to a few minutes to collect enough data for a single scan.With a moving organ like the heart, this results in several image artifacts, such as blurring or ghosting caused by cardiac and respiratory motions, that reduce image quality (Zaitsev et al 2015).The approaches most commonly adopted to prevent them are cardiac gating and respiratory gating.Both of them involve synchronizing the acquisition of imaging information to a common time point within each cardiac or respiratory cycle, respectively (Lanzer et al 1984, McNamara and Higgins 1984, Osbakken and Yuschok 1986, Amoore and Ridgway 1989).Without cardiac gating the separation of internal cardiac anatomy, accurate quantitative CMRI imaging, and the evaluation of cardiac function would be unfeasible.Respiratory gating, on the other hand, is essential for images involving lungs, diaphragm, and liver, whereas for cardiac images it is applied only in cases where breathing is deep and thus the motions induced by breathing are significant.To achieve gating, an electrocardiographic (ECG) recording must be taken simultaneously with MR scans, providing a reference for synchronization by the estimated cardiac phase (Dimick et al 1987, Dinsmore 1987, Laudon et al 1998, Park et al 2009).This is achieved by referring to R-peaks, which are the largest and steepest components within each cardiac cycle in the ECG signal and, therefore, easier to detect.While respiratory gating can be implemented using the ECG signal, the utilization of specialized instrumentation such as spirometry enables more precise synchronization.This study exclusively concentrates on cardiac gating, with plans to explore respiratory gating in future investigations.
Cardiac gating can be either prospective, by triggering the acquisition of MR data only after the detection of a physiologic event (usually, R-peak), or retrospective.In the latter case, MR data are acquired continuously and later reordered according to the length of R-R intervals (Nacif et al 2011), with the advantage that all cardiac phases can be imaged.In both cases, the timing accuracy of R peak detection is extremely important, as any large difference between the actual peak of the QRS complex and its detected position would make reconstructed CMRI images very inaccurate and blurred.Whereas estimated R peak position differences are acceptable up to 150 ms from the reference annotation according to AAMI (19941994), synchronization allowance for cardiac MRI imaging is related to inter-frame separation, which means deviation from the actual position should be less than 20 ms (Oster and Clifford 2017).The objective is made challenging by distortion caused by the magnetohydrodynamic (MHD) effect, which affects ECG signals recorded within an MR scanner.The disturbance is time-aligned to the repolarization period, notably affecting ST segments in an ECG trace, and leads to an increase in the amplitude of the T wave that can hinder correct R peak detection (Kinouchi et al 1996, Martin et al 2012).Higher-intensity static magnetic fields in the newer high-resolution 3T and 7T MRI scanners result in stronger MHD effects and more significant ECG distortion, making R peak detection even more challenging (Chakeres et al 2003).
Several methods to reduce MHD distortion in the ECG and accurately estimate R-peaks have been proposed, for instance a Wiener filter is presented in Krug et al (2012).An adaptive finite-impulse response (FIR) filter based on least mean squares (LMS) was proposed in Tse et al (2014), where the authors modeled the unknown patient-dependent MHD voltage by an adaptive filter, and the model was then employed to filter distortions and derive a clean ECG from signals acquired within the MRI scanner.A nonlinear Bayesian filter was considered in Oster et al (2012), where contributions from MHD and the ECG are both modeled as pseudo-periodic signals and separated by a Bayesian filter that recursively estimates the parameters of both models.Other methods exploit the wavelet transform to decompose ECG signals and eliminate noise and artifacts while maintaining only the noise-free signal (Martis et al 2014).
The gating technique most widely used in clinical practice involves a preliminary 3-lead ECG acquisition performed outside the MR scanner, from which a spatial representation of the heart electrical activity (vectocardiogram) is extracted, and used to train a detection algorithm in the recognition of patient-specific QRS complexes even in signals distorted by the MHD effect.It is employed in both low field B0 (1.5T) acquisitions (Fischer et al 1999) and in very high field B0 (7T) acquisitions (Hamilton-Craig et al 2019, 2021).The need for specific R-peak detector training can be a significant limitation in practice, as it means an increase in the already prolonged time involved in an MR acquisition session, which can be inconvenient for vulnerable and unhealthy subjects.In this work we propose a retrospective gating strategy that accurately detects R peaks from a multi-lead ECG acquisition taken during the MR scan, without requiring any preliminary training phase outside the scanner.This purpose is achieved by combining effective component separation with a robust selection of the independent component best suited for R-peak detection.For component separation we rely on blind source separation techniques, specifically, we adopt independent component analysis (ICA) which has shown promise in mitigating the MHD effect in ECG components (Hyvärinen and Oja 2000, Bhatt and Reddy 2009, Sarfraz et al 2011).
The most significant part of our contribution is the design of the component selection process, which is completely automatic and independent of patient-related features.Results confirm that R-peak detection accuracy is satisfactory for retrospective gating, moreover the proposed method is robust to variations in B0 field strengths, enabling accurate estimation of R-peak positions even in the presence of ultra-high fields.
Although the method was developed from a data set of 12-lead ECG acquisitions, multi-lead acquisitions have the disadvantage of being bulkier and more cumbersome compared to the 3-lead setups commonly used in clinical practice (Hamilton-Craig et al 2019).Therefore, we investigated the optimization of the measurement setup to reduce its size, while preserving R-peak detection accuracy.Our results demonstrate that for signals acquired in a 3T scanner, a set of 3 leads is sufficient, whereas for signals acquired in a 7T scanner, 5 leads are necessary to accurately detect R-peaks ensuring effective gating.
The paper is organized as follows: section 2.1 illustrates the data used to design and validate the proposed method.Section 2.2 describes the algorithm developed to automatically and accurately identify the time position of R peaks.Section 2.3 discusses the metrics employed to quantify performances.Section 2.4 illustrates the investigation into the size of the acquisition set-up and the resulting possibilities to reduce the number of leads.Results are reported in section 3 and discussed in section 4.

Data sets
The dataset employed in this work is freely available on Physionet (Krug Passand 2021).It contains ECG recordings from 23 subjects (17 male and 6 female) with an average age of 27.1 ± 3.2 years, an average weight of 73.8 ± 13.1 kg and an average height of 181.7 ± 10.5 cm.Data were acquired by a 12-lead Holter recorder (CardioMem 3000, Getemed AG, Germany), with a sampling rate of 1024 Hz, an analog bandwidth of [0.05, 100] Hz and input voltage range of ±6 mV with 12 bit resolution.
Traces, consisting of the limb leads (I, II, III), the augmented limb leads (aVR, aVL, aVF), and the six precordial leads (V1-V6), were recorded within a Siemens Magnetom Skyra MRI scanner with B0 intensities of 3 T and 7 T, no magnetic gradient fields were applied.
As blood is a conductive fluid, a potential is generated when it flows perpendicularly across the MR static magnetic field (B0).The field affects ions within flowing blood by means of the Lorentz force (  =  ´¾  F qv B0 , where q is the electrical charge of the ions and  v their speed).The MHD effect is a consequence of the resulting movement perpendicular to B0, which accumulates ions on the walls of the blood vessel, generating an additional electrical field in the patient body.
By approximating a section of an artery by a cylinder of diameter d, the voltage V MHD across the artery given by: where θ is the angle between the ion displacement and the magnetic field.The main contribution to the MHD effect comes from the aortic arch, which is the artery with greater diameter, fastest blood flow, and mainly perpendicular to the static magnetic field B0 (Gupta et al 2008).MHD voltage is superposed on the ECG signal, the main distortions affecting the ST segment and the T wave, because that is when blood flow is the most rapid.Its magnitude is comparable to common ECG signal voltages (Underwood 1992, Krug andRose 2011).Examples of ECG signals acquired within the MRI scanner at 3T and 7T magnetic field intensities are shown, respectively, in figures 1 and 2 for all 12 leads.It can be seen from the figures that, at higher B0 field strengths, distortion of ECG recordings is greater.
Records in the data set include different configurations for each B0 strength: Head first (i.e.B0 from head to feet), Feet first (i.e.B0 from feet to head), supine (i.e. the subject position is supine).In total, there are 17 acquisitions at B0 = 3T and 10 acquisitions at B0 = 7T.Reference R peak positions are available thanks to manual annotations performed by two clinicians.ECG acquisitions outside the MRI scanner were not used in algorithm development because the proposed method does not need an undistorted signal free from the MHD effect as a reference.

R peak detector
The R-peak detection algorithm comprises pre-processing and main processing.The accurate determination of the temporal position of R peaks is accomplished in three steps: (i) separation of signals into distinct components by means of ICA; (ii) detection of R peaks in all component sources; (iii) selection of the most reliable estimate among them.Algorithm steps are summarized in figure 3.

Pre-processing
Pre-processing involves preliminary filtering of ECG data to remove undesired low-frequency and highfrequency components (baseline wander, power line interference, motion artifacts, etc) whose frequency content does not overlap that of the ECG signal.Accordingly, we apply band-pass filtering with cutoff frequencies of [3 40] Hz, intending to preserve as much as possible the shape and amplitude of the QRS complex, which is the component of interest for accurate R-peak detection within the ECG signal.A lower cutoff frequency of 1 Hz would be commonly used for signals acquired outside the MR scanner (Kher 2019, Chatterjee   Key morphological characteristics of the ECG signal remain unaltered after filtering, as shown in figure 4 where an ECG signal acquired outside the MRI scanner (blue line) is compared with the pass-band filtered signal (black dotted line).Potential morphological alterations introduced by the filtering step can be evaluated by analyzing the relative reduction in the amplitude of QRS complexes after the application of preliminary filtering.This value falls below 5%, indicating negligible distortions.

Main processing-component separation
For ECG signals acquired within an MR scanner a set of n electrical sources within the body is assumed, namely the heart, RF-induced, muscle, and respiration artifacts, plus MHD effect-related artifacts.All of them contribute to the recorded ECG signal (Krug et al 2012), (Oster and Clifford 2017).ECG signals are pseudostationary and can be considered stationary for short segments of length Q.
Each source, denoted by index k = 1, ..., n, can be associated to a specific data segment: , with f s being the ECG sampling frequency, and segments can be represented in compact matrix form as m, where m is the number of leads, or: Electrodes are sensitive to all electrical sources, therefore observations X can be modelled as linear combinations of the projections of various electrical sources S onto specific points on the body surface where electrodes are placed: ( ) describes how sources combine (Galli et al 2022).ICA is a computational method that separates multivariate signals into statistically independent components.By ICA an approximation of the original signal sources S, indicated as S ˆ, is recovered by , such that:  = S B X.

ˆ• ( )
The 12-lead ECG recordings are obtained from nine electrodes measuring unipolar signals on the body.Since only 8 leads are independent, ICA is limited to those, with limb leads I and II, and precordial leads V1-V6 considered.This reduction in leads maintains effective component separation, lowering ICA computational complexity (Krug et al 2013a).
It should be remembered that bioelectric activity in the heart is associated with a three-dimensional current dipole, consequently, an ECG signal is typically formed by a linear combination of at least three independent components, rather than a single source.The fastICA algorithm was used to perform ICA, with kurtosis adopted as a cost function.fastICA is a deflationary algorithm, which means components are estimated in sequence (Hyvärinen and Oja 2000).For clean ECG signals this results in at least one component containing QRS complexes, a T wave, and a P wave.This is illustrated in figure 5, where the first three independent components in clean ECG signals are presented for three different subjects.Remarkably, a different phase of the cardiac cycle prevails in each component, as if related to a distinct source, which somehow corresponds to actual heart behavior.
As the MHD effect mainly affects the ST segment, the component containing T waves is the most affected by the distortion (Krug et al 2013a, Oster andClifford 2017).On the other hand, the component containing QRS complexes remains almost undistorted.Therefore, although ICA cannot isolate the MHD effect, it can isolate QRS complexes, addressing the challenge of accurate R-peak detection in MR-acquired ECG signals, as demonstrated below.
In practice, independent components from ICA decomposition are not so neatly ordered as in figure 5, that is, the first one does not always correspond to QRS complexes, neither do T waves and P waves follow in order.The challenge is then to automatically identify the independent component containing information of interest while discarding distorted and noise-affected ones.

Main processing-R-peak detection and best estimate selection
Peak detection is carried out on each of the 8 independent components s s s , ,..., n 1 2 ˆˆˆof matrix S ˆ(equation (3)), generating a set of estimates for each of them.The detector adopted in this work is already known, accordingly just a brief description is given in the following.Each component is normalized, and its absolute derivative is calculated, then filtered by a zero-delay forward-backward Butterworth bandpass filter (6.3-16 Hz).This enhances the amplitude of QRS complexes, facilitating their recognition.The derivative of this filtered signal is employed to detect the position of peaks through an adaptive thresholding method (Varanini et al 2014).
As illustrated by figure 6, reference to any particular feature within a cardiac cycle may produce accurate heart rate (HR) estimates, as information about periodicity is still provided.On the other hand, there is no way to tell in advance which estimate agrees with the actual R-peak positions more closely.However, cardiac gating is critically dependent on time position, which is best referred to the R peak.For this purpose, a novel selection procedure was developed.Its objective is to pick the most accurate and reliable estimates so that fully automated gating can be achieved.
To accomplish this we first shortlist independent components of the ECG signal by reference to a suitably defined quality index for accuracy in HR estimation.Then, using a second index related to frequency content, we identify the ICA component most likely to contain QRS complexes.We emphasize the importance of this second step to ensure position accuracy.
As a first step, sequence HR i of instant heart rate values (obtained from reciprocals of peak-to-peak interval lengths) is computed: where i = 1, ..., 8 denotes the individual component, nq i is the total number of detected peaks in the ith component and t i j , ˆwith j = 1, ..., nq i is the time position estimate of the jth R peak in the ith component.Components are discarded at once if the mean value of HR i falls outside the range of 50-180 beats per minute (bpm), typically associated with physiological HR in adult humans (AAMI 1994).In all other cases, the following indexes are derived: • the number of outliers, that is, a count N outliers,i of individual elements in the sequence HR i that lie outside the physiological range 50-180 bpm; • HR variability, defined as the normalized sum of the absolute differences between successive elements of HR i .
It is expected that in any reasonably healthy subject variability between successive beats is limited (Zhang et al 2008).
• the relative discrepancy between the mean HR value of the series and a predefined average physiological value for an adult at rest, taken to be HR=70 bpm.
These detail indications are combined into a general HR quality index Q according to the following formula (Galli et al 2021), where index i is omitted for simplicity:  ECG components exceeding the threshold = th Q 1.1 min i i • ( )are discarded due to their potential to yield poor HR estimates.The adoption of an adaptive threshold proportional to Q min i i ( )allows accounting for inter- subject variability, leading to a more robust and accurate assessment.The acceptance criterion is tailored to specific patients, accommodating possible cases where some pathology is present.For instance, individuals may have average heart rates deviating significantly from the typical 70 bpm range, or beat-to-beat changes spanning 300-500 ms, whereas athletes may have resting heart rates as low as 45 bpm.In such cases, using a fixed threshold based on 'standard' physiological parameters could lead to misleading results.
The behavior of this index is illustrated by figure 7, where values of Q are reported above each plot where HR estimates (blue line) are compared with the reference HR (red line) for the same 8 independent components of figure 6. Reading from top left to bottom right, = Q min 0.33189 i i ( ) is associated to i = 2 and yields th = 0.365.Accordingly, independent components 1, 2, 4, and 6 must all be placed in the shortlist.
The second, frequency-related index is aimed at the identification, within this subset, of the independent component best related to QRS complexes.Based on the hypothesis that the frequency content of the QRS complex is mainly concentrated in the range between 8 and 15 Hz (Elgendi et al 2010), we take the component with the maximum relative power in that range as the best candidate for accurate R-peak position estimation.For this purpose, we consider the power spectra s i ˆ, defined as: where S f i ˆ( ) the discrete Fourier transform of s i ˆand Q is the number of samples.We define the index: whose value is calculated for all components in the subset shortlisted by means of index Q.The best choice for R-peak position estimation is the one having the maximum value of F. The process is illustrated by figure 8, where power spectra of all 8 independent components are presented, those of the selected subset being shown in black, while others are represented in grey.The highest F-index value is associated with component 4, making it the selected component for accurate R-peak positions, as remarked in figure 6.

Evaluation metrics
Evaluation of performances for the proposed algorithm involves two aspects, detection and position accuracy.R peak detection can be assessed using ECG trace annotations validated by clinicians, provided with the data set.Each algorithm-generated peak was classified as true positive (TP) or false negative (F) based on whether the actual R peak was either detected or missed.A false positive (FP) is a falsely identified R peak, whereas a false negative (FN) is a peak that was missed by the algorithm, but is indicated in the ECG trace annotations.Usual metrics were considered (Galli et al 2019), namely: • Positive predictive value (PPV): ratio between the number of correctly detected peaks and the total number of peaks detected by the algorithm: • Sensitivity (Se): ratio between the number of correctly detected peaks and the total number of peaks in the analyzed trace: • F-score: a robust index that evaluates the overall performance of the algorithm in correctly detecting R peaks.
F-score ranges from 0 to 1, where 1 is attained when detection is always correct.
Standard guidelines (AAMI 19941994) were followed for these metrics, allowing for comparison with other R-peak detectors.Accordingly, a peak is considered correctly identified when the estimated position deviates by less than 150 ms from the reference annotation.In addition to the above indices, algorithm time accuracy was also quantified by evaluating R-peak position deviation.This is calculated as the mean absolute time difference between the detected (t i j , ˆ) and annotated (t i,j ) R-peak positions: where nq i is the total number of detected R peaks for the selected (ith) independent component.In the following, ò is reported in ms and the tighter bound of 20 ms, required for CMRI imaging, is referred to.

Lead selection
Database recordings considered in this study were obtained by a full 12-lead ECG setup, which required the use of 9 electrodes, a rather large number that would be rather cumbersome in everyday practice, as it can cause discomfort for the patient and prolong the setup placement process, leading to longer examination times.Therefore, after the R-peak detector was designed and optimized, our focus shifted to reducing the size of the measurement setup.For this purpose, we decided not to select electrodes based on the quality of each signal taken individually, because this procedure could be misleading for the method used in the processing step (i.e.ICA).Indeed, high-quality signals are those in which the ratio of ECG amplitude to noise is greatest.This is the case for electrodes close together, where the projection of the cardiac dipole onto the lead is advanced and noise and artifacts are few.The disadvantage of the selection procedure is reduced independence and variability among the subset of leads selected.This makes it more difficult to separate the components by ICA, compromising the results of the proposed methods.Consequently, the strategy we decided to adopt is based on the broader perspective of identifying the combinations of leads that contain sufficient information for the separation of the various components (such as ECG signals, MHD effect, noise, artifacts, etc) to allow effective identification of R-peaks.Specifically, we identified the leads that contributed less information to denoising and R-peak detection, and progressively removed them as far as the accuracy of R-peak detection was not significantly compromised, aiming at reasonable patient comfort during ECG signal acquisition.
Reduction of leads turns source estimation into an underdetermined problem, wherein the number of observations is smaller than the number of sources (that is, m < n).In practical terms this makes it impossible to separate all different components of the ECG signal, however, our goal is to effectively isolate the QRS complex, rather than a comprehensive separation of all signal components.Therefore, underdetermination is not an impediment in the context of our specific application.
The purpose of lead selection is the identification of the optimal quantity and of specific leads that can be omitted from the set, while still allowing ICA to accurately detect R-peaks and ensure effective gating.Thus, by the reduction process we also sort leads, from the most significant to the least significant for accurate detection of R-peaks.In practice, starting from the full set of leads (i.e.I, II, V1, V2, V3, V4, V5, and V6), the precordial lead that causes the least decrease to the R-peak detection F-score is removed at each iteration.
Statistical tests for the F-score (equation ( 10)) and ò metric (equation ( 11)) were performed to compare results obtained with different numbers of leads and recognize significant differences.Normality of sample distributions was preliminarily assessed using the Kolmogorov-Smirnov test (Stephens 1974), so that either the t-test or Wilcoxon's rank statistical test were selected, respectively, for normal or non-normal distributions.
Iterations were repeated until no more precordial leads were available and the final minimum setup comprised only leads I and II.Results of the test were considered significant, indicating performance degradation if the relevant lead was discarded, for a p-value lower than 0.05.

Results
Reference R-peaks annotations are available for both 3T and 7T data sets, allowing the quantitative performance analysis we present in this section.Table 1 reports the mean value of the metrics described in section 2.3, evaluated on both the 3T and 7T database using the proposed method, along with the related standard deviation, median value, and interquartile (iqr) range.
Performances obtained in terms of PPV, Se, and F-score are comparable for the 3T and 7T databases, while R-peak position deviation ò is significantly lower for the 3T database (ò = 2.4 ± 3.1 ms) compared to the 7T database (ò = 10.6 ± 15.4 ms).
It should be remarked that statistical distributions of performance parameters require some care in the interpretation of table 1. PPV, Se, and F-score all have a bounded range of variation and results are usually close to the upper bound.Likewise, ò is positive-constrained with rather small values.Therefore, the expression mean ± standard deviation may produce values outside the proper range, because of distribution asymmetry.
In figure 9 values of F-score and ò are plotted for each individual subject in the 3T and 7T databases, using the full set of ECG leads and an assumed number of 8 sources for ICA.It can be observed that all subjects but one exceed 99.4% for the F-score metric.Results are slightly more scattered for the ò metric, yet only for two subjects in the 7T database, the average ò exceeds 20 ms.It is important to notice that the accuracy in the detection of R-peaks in the considered scenario is not linked to the sex of the subjects, as expected according to the literature (Koivumäki et al 2022).Indeed, the average F-score for female subjects is F = 99.87% and F = 99.94% for 3T and 7T respectively, which are comparable to the F = 99.97% and F = 99.52%obtained considering only the male subjects.These results sustain the hypothesis that the normal variations observed in ECG readings across different healthy subjects do not impact the outcomes of the proposed algorithm.
Performances obtained with progressively reduced sets of ECG leads are illustrated by table 2 and figure 10.Leads were discarded in the following order: V6; V1; V5; V3; V2; V4.Performance obtained for each subset in terms of F-score and ò were compared with those achieved with the full set of leads (i.e.I, II, and V1-V6) using statistical tests.The resulting p-values are reported in table 2 besides F-score and ò values for both the 3T and 7T databases.When significant performance declines occur (that is, p < 0.05), these are highlighted in bold character for p and correspondingly marked with black asterisks in figure 10.
The first line in table 2 and the leftmost boxplot in figure 10 refer to the full 8-lead configuration (i.e. 8 leads).Subsequent lines and plots were obtained by removing one lead at each iteration, in the sequence described above.
Results indicate that no significant performance degradation occurs, in terms of decreased F-score and increased ò, until the number of leads is reduced, respectively, to less than three (I, II, and V4) for B0 = 3T field strength, and less than five (I, II, V4, V2, V3) at the higher field strength B0 = 7T.In particular, it can be noticed that below these limits synchronization for CMRI becomes critical.

Discussion
In this work we propose a method for retrospective gating that can accurately detect R peaks without requiring a preliminary training phase outside the MRI scanner.This is achieved by combining effective component separation using ICA with a robust selection of the most suitable independent component for detecting R peaks.
The most significant contribution of our work is related to the selection process, which is designed to be completely blind and independent of patient characteristics and scanning features.Accurate timing for R peak detection is crucial for effective gating.However, this is challenging due to the MHD effect, which distorts the shape of the ECG.The distortion of ECG signals increases with the magnetic field strength, making accurate R-peak detection more challenging for signals acquired within the 7T scanner than for those at 3T, as the former are noisier than the latter.As a result, the performance obtained on the 3T database is generally better than that obtained on the 7T database (table 1 and figure 9).
For both the 3T and 7T databases, the PPV, Se, and F-score metrics are high, indicating that the proposed method can accurately recognize QRS complexes without confusing them with T waves.Upon closer analysis, the PPV has a slightly lower value than Se, which is equal to or nearly 100%.Therefore, the number of FN is almost zero (the proposed method misses no R peaks), while some FP are present (i.e.R peaks are identified even when they are not present).However, since the PPV is high (>99%), the number of FPs is negligible, and the possibility of this type of error is limited.
For peaks identified as TP, we also calculated the ò error, which quantifies the deviation of the detected peak from its true value.To ensure effective gating, this value should be less than 20 ms (Oster and Clifford 2017).On  average, this criterion is met for both the 3T and 7T datasets.Specifically, the average ò values are 2.4 ± 3.1 ms and 10.6 ± 15.7 ms for the 3T and 7T databases, respectively (see table 1).However, when considering the acquisitions individually, all those in the 3T dataset guarantee reliable and efficient gating, while two acquisitions in the 7T dataset show an ò greater than 40 ms (see figure 9).It is important to note that this occurrence is infrequent and only happens in a small number of cases, specifically for the ultra-high B0 (7T) acquisitions.
The proposed method produces results comparable to or even better than the approaches presented in the literature.For instance, the ICA-based algorithm presented in Krug et al (2013b) achieved a Sensitivity of 99.2%, a PPV of 99.1%, and an error ò lower than 6 ms, that are comparable to the performance of the proposed method on 7T ECG traces, as shown in table 1.Moreover, the proposed method outperforms the one based on Vectocardiogram ECG presented in Hamilton-Craig et al (2021), for which Sensitivity = 97.6% and PPV = 98.7%.Importantly it should be noted that, unlike the other methods proposed in the literature so far, the proposed method achieves remarkable results without requiring a preliminary learning phase external to the scanner.
Finally, the role and significance of the individual leads were investigated by applying the proposed method to a progressively reduced subset of leads.Results indicate that removal of leads V1, V5, and V6 causes no performance degradation (see table 2), therefore they are not significant for accurate R-peak detection.For the 7T dataset, application of the proposed method to the 5-lead subset (I, II, V2, V3, and V4) yields comparable performances (F-score =99.7 ± 0.3 and ò = 13.8 ± 18.1 ms) to those obtained with the full set, sufficiently accurate to ensure effective gating.With the 3T database leads V2 and V3 can also be removed, while lead V4, located on the apex of the heart, is crucial to accurate estimation (F-score =99.6 ± 0.9 and ò = 4.0 ± 2.7 ms), as seen from table 2. Removal of V4 leaves leads I and II only, but application of the method results in poor performance (F-score =87.2 ± 20.8 and ò = 59.5 ± 16.6 ms).These results highlight the importance of precordial leads for ICA-based methods, both because of their information content and because ICA requires a sufficiently large number of observations to achieve effective source separation.
For ECG signals acquired within 3T scanners, several 3-lead configurations equivalent to those commonly used in clinical practice are sufficient (Hamilton-Craig et al 2019).The proposed method therefore involves no change in current clinical practice, thereby totally avoiding the need for ECG signal acquisition outside the scanner.
On the other hand, due to the higher level of distortion within a 7T scanner a 5-lead ECG configuration would be necessary.However, the placement of two more leads in addition to those commonly employed undoubtedly requires a shorter time than purposely acquiring ECG signals outside the scanner.Hence, even in the 7T context, the proposed method remains advantageous compared to the state of the art.

Conclusion
This work presents a novel retrospective gating strategy that eliminates the need for a preliminary training phase outside the MRI scanner.The proposed method combines component separation using ICA with a careful selection of the independent component best suited for R-peak detection.The selection process is designed to be completely blind and independent of patient characteristics, allowing for wide and rapid deployment in clinical settings.
The proposed method exhibits robustness to different B0 intensities and can accurately estimate R-peak positions even in the presence of ultra-high fields.The R-peak detection yields ò = 2.4 ± 3.1 ms and ò = 10.6 ± 15.4 ms for data acquired with B0 equal to 3T and 7T, respectively.Moreover, we assessed the method's effectiveness under various subject orientations to ensure its applicability in diverse clinical scenarios for both datasets.
Considering that dataset recordings were acquired using a conventional 12-lead acquisition layout, we investigated lead reduction to identify less informative leads in terms of denoising and R-peak detection, allowing for their removal.Results revealed that the lead set can be effectively reduced to as few as 5 leads (I, II, V2, V3, V4) at 7T field strength and to 3 leads (I, II, V4) at 3T field strength, without significantly compromising R-peak detection accuracy.This significant reduction in the number of leads not only enhances subject comfort during MRI acquisition but also speeds up preparation time required for the examination.

Future developments
A future development plans to apply the proposed method also to signals corrupted not only by the MHD effect but also by artifacts induced by the variable gradient fields and different MR sequences, which were omitted in this work.Gradients introduce artifacts that add to the useful signal without causing waveform distortion, in contrast to the MHD effect (Abi-Abdallah et al 2006).Consequently, the artifacts induced by sequences will not exhibit a magnitude variation according to changes in magnetic field strength.It is expected that the proposed ICA-based method will exhibit robustness against artifacts caused by gradients, as these artifacts are independent of the ECG signal and prevalent across all leads (Oster et al 2009).However, the presence of artifacts is likely to increase the number of sources combined to generate the recorded signals.Therefore, it is plausible to assume that the number of leads required to obtain an accurate HR estimate would be greater than what was demonstrated in this study, and it would be proportional to the complexity of the sequence.To mitigate the influence of artifacts on the effectiveness of separation, an adaptive segmentation method could be a viable solution to reduce the influence of artifacts on the effectiveness of separation (Galli et al 2021).In addition to cardiac gating, the utilization of respiratory gating has also been recognized as a potential technique to enhance MRI imaging.However, in the present study, the focus was primarily on cardiac imaging, and thus the exploration of respiratory gating was not pursued as the impact of respiratory gating on cardiac imaging may be comparatively more limited.Nonetheless, considering the broader context of thoracic imaging, the incorporation of respiratory gating holds promise as a future development as it can potentially enhance the overall diagnostic capabilities in cardiac MRI (Yuan et al 2000), (Ehman et al 1984).
et al 2020), however a 3 Hz cutoff frequency is more effective in reducing the MHD effect without distorting QRS complexes.To preserve the high-frequency content of the QRS complex (Elgendi et al 2010), its cutoff frequency is set to 40 Hz.The digital filter was implemented as a cascade of high-pass and low-pass sections.The former, designed as an infinite impulse response (IIR) Butterworth filter of order three, removes low-frequency noise and disturbances, such as breathing and body movements, and reduces distortion induced by the MHD effect, which is mainly concentrated in the low-frequency band (Abi-Abdallah et al 2005).The low-pass filter (finite impulse response (FIR) filter of order six) removes high-frequency noise caused by the electrical activity of muscle contractions or body movement (Kher 2019, Chatterjee et al 2020).

Figure 5 .
Figure 5. Application of ICA to noise-free ECG signals.Each column refers to a different subject.Rows show independent components containing QRS complexes (top), T waves (middle) and P waves (bottom).
Lower values of Q are associated with a smaller number of outliers, low variability, and individual estimates close to the mean value HR, which correspond to more accurate HR estimates.

Figure 6 .
Figure 6.Detected (blue crosses) and reference (red crosses) R peaks for each of the 8 independent components s s s , ,..., 1 2 8ˆˆˆin an ECG segment.Only for component i = 4 (second row, second column) do R-peak position estimates coincide.

Figure 7 .
Figure 7.Comparison between the HR reference (red line) and the estimate (blue line) provided by the peak detector applied to each component.The corresponding Q index is also given for each component.

Figure 8 .
Figure8.The spectra of the subset of components selected in the first step are displayed in black, while those of the remaining components are shown in gray.The frequency limits at 8 and 15 Hz are highlighted in red, along with the corresponding F-index values for the selected subset.

Figure 9 .
Figure 9. F-score (top) and ò error (bottom) for each subject in the 3T (left) and 7T (right) databases.Red lines in plots at bottom indicate thresholds for effective gating.

Figure 10 .
Figure 10.Boxplot analysis for F-score (top) and ò (bottom) metrics with reduced numbers of ECG leads.Statistically significant differences from full-lead configuration (p < 0.05) are marked by asterisks ( * ).

Table 1 .
Mean ± standard deviation, median and interquartile range (iqr) of the proposed metrics evaluated on 3T and 7T databases.

Table 2 .
Mean ± standard deviation of F-score and ò metrics using reduced lead subsets, 3T and 7T databases.Degradations from the full set (p < 0.05) are highlighted in bold.