Skip to content

Commit 8dbd988

Browse files
committed
emd: review text
1 parent d68d098 commit 8dbd988

1 file changed

Lines changed: 21 additions & 17 deletions

File tree

content/tutorials/empirical_mode_decomposition/empirical_mode_decomposition.qmd

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ If signals oscillate regularly, Fourier methods are applicable.
1616
These methods are well known and readily applied.
1717

1818

19-
However, these methods fail to capture the complex characteristics of a signal.
19+
However, these methods occasionally fail to capture the complex characteristics of a signal.
2020
Irregular changes, varying amplitudes, and changing frequencies can result in derived measures which are no good representation of the data.
2121

2222

@@ -78,7 +78,7 @@ import matplotlib.pyplot as PLT
7878

7979
## gape angle data
8080

81-
For exploration, take this brief episode of beak gape angle of a canary cracking hemp seeds, courtesy of [Maja Mielke](https://orcid.org/0000-0001-6328-0589) ([*website*](http://mielke-bio.info/maja/blog)).
81+
For exploration, take this brief episode of beak gape angle of a canary cracking hemp seeds, courtesy of [Maja Mielke](https://orcid.org/0000-0001-6328-0589) ([*website*](https://maja.mielke.ws/blog/)).
8282

8383

8484
::: {.panel-tabset group="language"}
@@ -144,7 +144,7 @@ ShowPlot()
144144

145145
:::
146146

147-
This bird was in ["positioning" and "biting" phase](http://mielke-bio.info/maja/blog/01_eating_or_being_eaten), placing a hemp seed in the right position for cracking with the help of their upper beak, lower beak and tongue.
147+
This bird was in ["positioning" and "biting" phase](https://doi.org/10.1242/jeb.244360), placing a hemp seed in the right position for cracking with the help of their upper beak, lower beak and tongue.
148148
On the x axis of [@fig-data-py]/[@fig-data-r], you see the time (available in video frames, or normalized).
149149
On the y axis, gape angle indicates (approximately) the angle between the beak tips and corner[^1].
150150

@@ -160,7 +160,7 @@ You can clearly see an initial episode with large gape angle oscillations, and a
160160
Engineers often talk about "peak amplitude" (as in: amplitude along the peaks) and quantify a **momentary amplitude** of a noticably oscillating signal ([see here](https://www.keysight.com/used/be/en/knowledge/guides/how-to-measure-amplitude-engineers-guide)).
161161

162162
This goes by the framework of ["Hilbert Transform"](https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.hilbert.html#scipy.signal.hilbert) and ["Analytical Signal"](https://en.wikipedia.org/wiki/Analytic_signal).
163-
All fascinating, yet we will here stick with the practical implementation.
163+
All fascinating, yet we will here stick to the practical implementation.
164164

165165

166166
To find the peak amplitude of the signal, one obviously has to detect the **peaks** (i.e. local maxima) of the signal.
@@ -295,7 +295,7 @@ One which is used by the reference implementation is `pchip`, "Piecewise Cubic"[
295295
::: {.panel-tabset group="language"}
296296
### R
297297

298-
In R, the `pracma` and `signal` libraries contain interpoltion functions which are not accurate (copies of matlab).
298+
In R, the `pracma` and `signal` libraries contain interpolation functions which are not accurate (copies of matlab).
299299

300300
Then, there is the `interpolators` library, yet for some weird design choice it does not offer the choice to extrapolate beyond the data range (though splines can do that easily, see Python).
301301

@@ -596,7 +596,7 @@ These functions can help a lot to play around with the peak finding parameters a
596596
# Example II: Random Walk on Water
597597
## anachronistic measures
598598

599-
Ultimately, I would like to apply these functions to quasi-continuous water level measurements from `watina`.
599+
Ultimately, I would like to apply these functions to quasi-continuous water level measurements from [`watina`](https://www.vlaanderen.be/inbo/datasets/watina/).
600600
My goal is to slightly improve water level analysis, for the following reason.
601601

602602

@@ -620,7 +620,7 @@ the mean of the three lowest/highest ground water levels measured in bi-weekly m
620620

621621

622622
The anachronism is that we still calculate `xG3` like this, despite the availability of high frequency sampled water levels.
623-
We artificially pick bi-weekly values.
623+
We artificially pick bi-weekly values, at 8:00 AM or at noon.
624624
We disregard the continuous, temporally periodic nature of the phenomenon.
625625
We choose an arbitrary sampling cadence.
626626
We ignore measurement uncertainty.
@@ -1059,7 +1059,7 @@ PLT.show();
10591059
As with the random walks above, unguided peak detection *should* find each tiny local peak, therefore initially extracting white noise where it is present.
10601060

10611061

1062-
## Guided Mode Search
1062+
## Guided Mode Search (*advanced*)
10631063

10641064
Experimenting with the peak detection parameters is worth a try.
10651065
(Because this works much better in Python, I will omit the R code here.)
@@ -1069,6 +1069,7 @@ First, search the long-term oscillations, by setting `prominence`, `width`, or `
10691069
In this special case, `width` will exclude the local minima: the lower peaks seem to be rather narrow on this water hole.
10701070
If this is an issue, remember that you can control peak finding for maxima and minima separately.
10711071
However, a combination of distance (more than half a year; remember that peaks and troughs are found separately) and prominence (*meaningful* peak) did the job to find the yearly baseline and straighten out the data (which might not be what we want).
1072+
This **effectively eliminates drift**.
10721073

10731074

10741075
```{python py-emd-wata-topdown1}
@@ -1121,8 +1122,10 @@ There are some obvious problems in this:
11211122
- wet summer ~2015: pronounced "dry" minimum was lacking; water levels around that year are dragged towards the zero
11221123
- peak chopping: some peaks, e.g. mid-2010 and 2016, are lost by smoothing
11231124

1125+
Note that, in this particular example, drainage might be the cause of the asymmetrical (capped) distribution of water level values; EMD still handles it relatively well.
11241126

1125-
Nevertheless, there is another valuable outcome of EMD: we get the lower and upper **envelope**!
1127+
1128+
There is another valuable outcome of EMD: we get the lower and upper **envelope**!
11261129

11271130
```{python py-wateremd-envelope}
11281131
#| label: fig-water-envelope-py
@@ -1140,10 +1143,11 @@ PLT.show();
11401143
11411144
```
11421145

1146+
This envelope, if averaged over time, is somewhat related to the GxG's.
11431147

11441148

11451149

1146-
Note that there is no guarantee that the same guiding parameters will work on every observation in your data set.
1150+
There is no guarantee that the same guiding parameters will work on every observation in your data set.
11471151
In my experience, a "guided" (top-down or bottom-up) EMD approach requires a lot of fiddling with the parameters, possibly even case distinction.
11481152

11491153

@@ -1162,13 +1166,13 @@ PLT.show();
11621166
11631167
```
11641168

1165-
However, these peak detection controls are unavailable in R, so we might better stick with the defaults anyways (which usually work).
1169+
The peak detection controls are unavailable in R (at least I did not find them), so we might better stick with the defaults anyways (which usually work).
11661170

11671171

11681172
## Summary: Water Level EMD
11691173

11701174
::: {.callout-note}
1171-
To "wrap up" (envelope-pun), some observations:
1175+
To "wrap up" (envelope-pun intended), some observations:
11721176

11731177
- "guided EMD": yearly oscillations are found first by selecting for peak characteristics
11741178
- noise can be extracted either before or after; EMD is one way of naturally smoothing a signal
@@ -1181,17 +1185,17 @@ And the most important take-home message:
11811185
:::
11821186

11831187

1184-
One goal of my application of EMD was to find a better way to extract a yearly range of water levels, to replace the anachronistic `LG3` and `HG3` calculations.
1188+
One goal of my application of EMD was to find a better way to extract a yearly range of water levels, to replace the anachronistic `LG3` and `HG3` calculations (which, nevertheless, worked surprisingly well on random walks).
11851189
With plain application of EMD (i.e. no pre-processing of the data), the envelope seems to be a promising aspect for further inspection.
11861190

1187-
The reason that water levels turned out to be non-ideal for EMD application is that they lack regular oscillations.
1188-
They are not symmetric (winter wet plateau; summer dry dip), and not necessarily regular (e.g. "wet summer").
1189-
Generally, water level measurements such as the first example above might be more usefully approached with [wavelets](https://docs.scipy.org/doc/scipy-1.12.0/reference/signal.html#wavelets) to find the summer minima.
1191+
The cases in which water levels turned out to be non-ideal for EMD application is when they lack regular oscillations.
1192+
They are not symmetric (e.g. winter wet plateau due to drainage, summer dry dip, drift, ...), and not necessarily regular (e.g. "wet summer").
1193+
Water level measurements such as the first example above might be more usefully approached with [wavelets](https://docs.scipy.org/doc/scipy-1.12.0/reference/signal.html#wavelets) to find the summer minima.
11901194
This is just my [almost-uneducated guess](http://mielke-bio.info/falk/posts/27.cycle_extraction/#orgac5a9c6), based on the visual form of the curves.
11911195
CWT (Continuous Wavelet Transform, [e.g. in R](https://www.rdocumentation.org/packages/Rwave/versions/2.6-5/topics/cwt)) is a great subject for another tutorial.
11921196

11931197

1194-
As a reminder, there are many tools to consider for signal analysis.
1198+
As a general reminder, there are many tools to consider for signal analysis.
11951199
I hope this tutorial could help to bring EMD to your personal repertoire.
11961200

11971201

0 commit comments

Comments
 (0)