# Frequency estimates from three-dimensional data

I have a lot of three-dimensional positional data from patients with tremor, unevenly sampled at approx. 50 Hz, with timestamps. I am trying to find the dominant frequencies in the signal/tremor. However, the dominant frequency may not be constant.

My current strategy so far has been

• Calculating the magnitude (dR = sqrt(df$X**2+df$Y**2+df$Z**2), and detrending by removing the mean. • Interpolating this to a sample rate of 50 Hz using spline (see sample data in Figure 1) • Using pwelchfrom package oce to obtain the PSD with pwelch(indsp$y, fs = smplfrq)

My hypothesis is that I should observe a peak somewhere around 8-12 Hz. However, zero to few peaks are observed (if I'm reading this right), and those peaks have very little strength. What can I do to improve my frequency analysis? Is it correct to do the calculation on the magnitude of the "signal"? I would love to be able to extract the dominant frequencies and amplitude from my data.

• You mention "3D" in the beginning of the question but subsequently it does not seem to matter to you too much (?). What would you be trying to achieve with this? – A_A Apr 10 '19 at 8:38
• Sorry, I realize I may not have given sufficient context. I have done measurements on patients with tremor, and have the position (in x,y, and z dimension) of their hands over time. What I would like to accomplish is to find a measure of the frequency of their tremor. – mhh Apr 10 '19 at 9:36
• OK, yes, that's a bit more clear but now I cannot but ask why does your "Magnitude" take negative values when it is simply a Euclidean distance (?) – A_A Apr 10 '19 at 10:02
• My bad again, I forgot to mention that the magnitude displayed has the mean removed. Thus, it has negative values. – mhh Apr 10 '19 at 10:05
• No worries, it is good to have clarified though. Are these absolute positions or accelerations? And if they are absolute positions, is the zero point arbitrary or fixed? – A_A Apr 10 '19 at 10:09

I have [...] three-dimensional positional data [...], unevenly sampled at approx. 50 Hz, with timestamps.

As a first step, it would be good to interpolate them so that they appear to be sampled at regular $$\frac{1}{50Hz}$$ intervals.

I am trying to find the dominant frequencies in the signal/tremor.

In this case, even a simple Discrete Fourier Transform (DFT) over a long enough segment (say for instance 10 times the longest period you are trying to discover) would suffice.

However, the dominant frequency may not be constant.

In which case, you would have to consider something like a spectrogram or more generally, obtaining the frequency response over time (i.e. sliding windows).

The only "problem" that the Magnitude representation has is that $$d = \sqrt{\sin(\theta_1)^2 + \sin(\theta_2)^2}$$ is constant for the right choice of $$\theta_1, \theta_2$$, even if the individual components oscillate.

The danger of this happening in exactly that way depends on how the data are acquired but the point remains that by obtaining the magnitude you are introducing some interference in the measurements.

So, use with caution.

Now, the way that a multidimensional DFT works is by first of all assuming that the dimensions the signal is measured over are orthogonal and then (as a byproduct of that) repeatedly applying the transform to the "remaining" dimension.

In the one dimensional case, you have the way a quantity evolves in time, as a time series. The application of the DFT here is straightforward and it decomposes the quantity over time into a sum of sinusoids over time.

In the two dimensional case, you apply the DFT over the "rows" of a two dimensional matrix holding your "signal" and then once more over the columns of the already transformed rows from the previous step. The result of this process is a two dimensional spectrum where the equivalent frequency bin (from the one dimensional case) is now a frequency ring. And this is because in the two dimensional case, it is not enough to ask "which frequency... (?)", you also have to specify "...along a particular direction". For more information about this, please see here and here.

In the three dimensional case, you apply DFT to the "rows", you then apply DFT to the "columns" of the transformed "rows" and then you apply DFT once again along the "depth" rows (or, really, the remaining dimension) of the previously transformed data. This returns a spatial representation of your data where the "frequency ring" (which used to be the "frequency bin") is now a "frequency shell", that is, a hollow sphere. It is not enough to ask "which frequency..." now, you have to specify the direction on the surface of a sphere.

You may be wondering "so what?" by now and that is putting it mildly.

The point here is that if you do a three dimensional DFT you will also be able to infer the most dominant direction along which the tremor is happening too. And that might be "correlateable" with other parameters of the health condition. That is, different brain circuits deteriorating, leading to tremors along specific directions.

To do that, do a three dimensional DFT, shift the spectrum, so that the low frequencies are towards the centre of the described "cube", take the magnitude of the complex result and find the maximum value (that is not at DC). The maximum value will be at some point $$m,n,k$$. The "angle" between a vector denoting the "forward" direction and the $$m,n,k$$ vector would give you the direction that this movement is happening.

The tremor might be up-down, diagonal, back to front, circular, etc. A three dimensional DFT will characterise this periodic movement fully.

Hope this helps.

• Thank you very much for your in-depth reply, it helps a lot! – mhh Apr 11 '19 at 7:54
• @mhh Thanks for letting me know, good luck with your project. – A_A Apr 11 '19 at 8:42
• Would you happen to know if R supports multi-dimensional FFT, and what an example command might be? – mhh Apr 11 '19 at 8:52
• @mhh Not really. If R can do a one dimensional DFT, you can use it repeatedly to do a multidimensional one. You might want to try these though... – A_A Apr 11 '19 at 9:19