## 3 Methodology
### Spectrogram Cross-Correlation  
Once the ELM and pellet time locations have been found, a criterion to determine if a pellet triggered an ELM is needed. In this work, the spectrogram cross-correlation (SPCC) method has been used [20]. For each detected ELM, the calculation of the SPCC signal as a function of the time delay is performed as described in the following. Considering the \(i\)-th ELM located at the time \(t_{i}\), the local spectrogram of the ELM and the pellets are calculated as follows:  
\[Pellet:\ X\big{(}t_{i}-\Delta t_{trig},f\big{)}=\int_{t_{i}-\Delta t_{trig}- \Delta t_{backward}}^{t_{i}-\Delta t_{trig}+\Delta t_{expand}}x(t)e^{-i2\pi ft}dt \tag{1}\]  
Figure 3: UV diamond line of sight.  
\[ELM:\ Y(t_{i},f)=\int_{t_{i}-\Delta t_{backward}}^{t_{i}+\Delta t_{upward}}y(t)e^{ -i2\pi f/t}dt \tag{2}\]  
where \(\Delta t_{backward}\) and \(\Delta t_{upward}\) are the backward and upward time windows used to calculate the spectrogram, and \(\Delta t_{upward}+\Delta t_{backward}\) is the total spectrogram window. The values of the backward and upward time windows must be set to ensure that most of the relevant features are calculated in the frequency domain. In this work, \(\Delta t_{backward}\) is 400 us and \(\Delta t_{upward}\) is 100 us, leading to a total spectrogram window of 500 us (and thus, the minimum spectrogram frequency is 2 kHz). A numerical example of such spectrograms is reported in Figure 4b for the pellet and in Figure 4c for the ELM-like structure.  
Then, the cross-correlation between the two spectrograms is computed as a function of \(\Delta t_{trig}\):  
\[P\big{(}\Delta t_{trig}\big{)}=\frac{1}{\Delta f(\Delta t_{a}+\Delta t_{b})} \int_{t_{start}}^{f_{end}}\int_{t_{i}-\Delta t_{a}}^{t_{i}+\Delta t_{b}}\frac{ \overline{X}\big{(}t_{i}-\Delta t_{trig},f\big{)}}\ Y(t_{i},f)\ dt\ df \tag{3}\]  
Figure 4: Numerical example of spectrogram cross-correlation profile calculation. The top image represents two numerical pulses (**a**), the pellet one simulated by a Delta’s Dirac and the ELM one. The second row (**b**) shows the spectrogram of the pellet pulse shifted at three different times (\(\Delta t_{trig}\)), 0 s, 0.05 s and 0.1 s, respectively, while the third row(**c**) shows the ELM spectrogram (unshifted). The last row (**d**) represents the cross-correlation between pellet and ELM as a function of the time shift, and a maximum is obtained for the actual value (0.1 s).  
where \(\overline{X\left(t_{i}-\Delta t_{trig},f\right)}\) is the complex conjugate of \(X\left(t_{i}-\Delta t_{trig},f\right)\), and \(f_{start}\) and \(f_{end}\) are, respectively, the minimum and maximum frequency of the spectrogram. The SPCC is performed in a time window ranging from \(t_{i}-\Delta t_{b}\) to \(t_{i}+\Delta t_{b}\), where \(\Delta t_{a}\) and \(\Delta t_{b}\) must be large enough to ensure that the most important features are considered in the cross-correlation (in this work, \(\Delta t_{a}\) is 3 ms and \(\Delta t_{b}\) is 1 ms). Figure 4d shows an example (by using synthetic signals) of spectrogram cross-correlation as a function of \(\Delta t_{trig}\) to illustrate the method. In this example, the pellet is placed 0.1 s before the ELM; therefore, the maximum P is obtained for \(\Delta t_{trig}\) equal to 0.1 s.  
The presence of a peak in the spectrogram cross-correlation does not demonstrate that the pellet triggered the ELM, but just that the time distance between the two events is that value. The assessment of ELM triggering must be performed by a statistical assumption, i.e., that the SPCC of triggered ELMs should be statistically similar, with maxima located at comparable values, while natural ELMs are expected to have SPCC profiles without prominent peaks or with peaks located at random positions. In order to separate the two classes of SPCC profiles, a k-means clustering approach has been used as described in the next section.