Skip to content

Zapline plus plot

MariusKlug edited this page Mar 28, 2022 · 6 revisions

In this article, we will describe the plot and how to analyze whether or not the cleaning was successful. For every frequency-specific noise artifact that is removed, a figure is generated. Example plots can be seen below. Importantly, the plot per frequency is being overwritten in case the parameters are automatically adapted, so the final plots only show the final values. These plots contain all information that is necessary to determine the success of the cleaning in a colorblind-friendly color scheme. The top row of the figure contains visualizations of the cleaning process, the bottom row contains the final spectra and analytics information.

These plots facilitate both, an understanding of the data set itself, as well as the functioning of the cleaning. Although the algorithm is adaptive in many ways and should work “as is,” it is naturally possible that the noise has properties that make cleaning with Zapline-plus difficult or impossible. Hence, these plots should always be inspected to determine if the cleaning was successful.

The most important result to check is the ratio of noise to surroundings of the cleaned data. This should be below 1.2, ideally close to 1.0. At the same time, the removed power below noise should be low. This information can be found in plot G (see below). The the ratio of noise to surroundings of the 50Hz cleaned data is 1.0499, which is below 1.2 and close to 1.0, so it is a nice zapline cleaning result.

Example plots

This is an example plot of removing standard 50 Hz line noise:

Example output plots produced by Zapline-plus for 50 Hz line noise with 50 Hz predefined as the noise to remove. Shown is a 9 min MEG data set. For a detailed explanation of the individual subplots, see below. A) Power spectrum centered around the noise frequency. B) Number of components removed by Zapline for each chunk. Chunks were defined as periods in which the noise was spatially stable. C) Specific noise frequencies are detected within each chunk. D) Component scores, sorted in descending strength. Red line: threshold for rejection based on outlier detection. E) Same as A, but after removal of the noise components. F) Full power spectrum, depicting both the line noise and (sub-)harmonics. G) Same as E, but showing clean and noise data separately. The x-axis expresses frequency relative to the removed noise frequency, where 1 indicates the noise frequency. H) Power spectrum of 10 Hz range below the noise frequency, indicating to what extent non-noise frequencies were affected by the cleaning.

This is an example plot of removing a spectral peak of unknown origin in strongly contaminated data, using the automatic noise detector:

Example output plots produced by Zapline-plus for a 21 Hz noise of unknown origin. Shown is an 87 min EEG data set containing a mobile and a stationary condition. This noise artifact was present only in the first part of the data.

Interpretation

The most important result to check is the ratio of noise to surroundings of the cleaned data. This should be below 1.2, ideally close to 1.0. At the same time, the removed power below noise should be low. This information can be found in plot G (see above). The ratio of noise to surroundings of the 50Hz cleaned data is 1.0499, which is below 1.2 and close to 1.0, so it is a nice zapline cleaning result.

Detailed explanation of the plots

Top row

In the top row, first, the noise frequency of this cleaning iteration is shown in a zoomed-in spectrum to ±1.1 Hz around the frequency (A). The threshold that led to the detection of this frequency is shown in addition (red line), unless the detection is disabled. Next, the cleaning of the individual chunks is visualized in two ways: The number of removed components per chunk (B), and the individual noise frequency detected for each chunk (C). Additionally, chunks in which no noise was detected are marked as such and the mean number of removed components is denoted in the title of the plot. As each chunk contains a set of components and accompanying artifact scores, this is too much to be visualized without cluttering the plot, so we chose to only plot the mean artifact scores overall chunks next (D). This plot also contains the mean number of removed components (red vertical line). Ideally, this line should cross the scores around the “elbow” of the curve, which indicates that the outliers (i.e., the components which carry most of the noise) were detected correctly. The abscissa is cut to one-third of the number of components to allow the visualization of the knee point. The SD value that was used for the detector is denoted in the title of this plot (for example, in the 50Hz example plot D, the SD for detection is 2.75). To finalize the visualization of the cleaning process, the zoomed-in spectrum of the cleaned data is shown alongside the thresholds that determine if the cleaning was too strong or too weak with respective horizontal lines (E). The same y-axis is used as in A to allow a comparison of pre- versus post-cleaning. The legend of this plot also contains the proportion of frequency samples that are below or above these thresholds, which determines whether the cleaning needs to be adapted. It may happen that values exceeding these thresholds remain, which can be either due to the minimum or maximum SD level being reached or due to the fact that the cleaning would to too strong if set to a stronger level.

Bottom row

F shows the raw spectrum as the mean of the log-transformed channel spectra. Vertical shaded areas denote the minimal and maximal frequency to be checked by the detector, as this can be useful to know in case a spectral peak is present in this area and thus goes undetected. In G, the spectra of the cleaned (green), as well as the removed data (red), are plotted. The abscissa in this plot is relative to the noise frequency which facilitates distinguishing removed harmonics from other frequencies. Last, as it was shown that Zapline can have undesirable effects on the spectrum below the noise frequency (Miyakoshi et al., 2021), H shows the spectra of the raw and cleaned data again zoomed in to the part 10 Hz below the noise frequency to determine if this was the case.

In the title of G and H, we also denote several analytics: the proportion of removed power (computed on log-transformed data, corresponding to the geometric mean) of the complete spectrum, of the power ±0.05 Hz around the noise frequency, and of the power −11 Hz to −1 Hz below the noise frequency, as well as the ratios of power ±0.05 Hz around the noise frequency to the center power before and after cleaning.

Clone this wiki locally