Hi everyone,

First time posting here!

When using the spectrogram to pre-process accelerometer data, the number of inputs that are created from that step does not correspond with the explanation of the spectrogram in the documentation.

Example:

3 axis accelerometer data for 1 second (fs = 100 Hz)

Frame length = 0.02 seconds

Frame stride = 0.01 seconds

FFT length = 128

Number of NN inputs

According to documentation: 99 frames * (128/2+1) * 3 (axis) = **19305** inputs

According to edge impulse: **9750** inputs (which is 50 frames * (128/2+1) * 3)

By calculating (and counting on the spectrogram previews) I found out that it used 50 frames instead of 99. It also uses FFT/2+1 number of frequency bins, which does not correspond with the documentation (there it says FFT/2).

So how should I actually calculate the number of frames that are used?

Best regards,

Jonas Lannoo

Hi @JLannoo With a one second sample at 100Hz and 0.02 frame length / 0.01 frame stride this yields me a 99x65 matrix per axis, and lists 19,305 input layer as well:

Whatâ€™s your project ID? Iâ€™ll take a look.

`FFT/2+1`

is indeed a documentation bug, have fixed this.

Hi @janjongboom,

Hmm, thatâ€™s how it should be!

My project ID is: 27208

Thanks for the quick response!

Best regards,

Jonas

Very interesting, your data is at 101Hz, and indeed only generates a 50x65 spectrogramâ€¦ Let me dive into that!

Indeed, sorry for that detail!

My data is at 101Hz (although I configured a datarate of 100 Hz in the forwarding microcrontroller).

Looking forward what the influence of that 1 Hz does!

OK, so this is what happens: To deal with frame stride / length that does not align exactly to your frequency, we normalize the values via `ceil(sampling_freq * frame_length)`

. For 2ms @ 100Hz => 2 values per slice, but for 2ms @ 101Hz => 2.02 => 3 values per slice. The same goes for the frame stride, leading to taking 3 values per frame, and a stride of 2 values => leading to 50 frames in total.

Quick workaround: set frame length to `0.019`

and frame stride to `0.009`

.

Note: if the data forwarder sees an incorrect frequency, you can override via `edge-impulse-data-forwarder --frequency 100`

(but you shouldnâ€™t mix multiple frequencies in one project, so Iâ€™d keep it at 101 for now).

2 Likes