Hacker News new | ask | show | jobs
by jononor 701 days ago
The use of accelerometer/gyro/IMU for activity tracking is quite well researched, including for animals. I found some papers on seizure detection for dogs using collar mounted accelerometer, though nothing for cat/feline. Based on the linked video, I think the phenomenona would be quite detectable. It might be that overall vibration every N seconds would be sufficient, but ideally you would have the energies at various frequency bands - like 0.5-1hz,2-4hz etc, as the near periodic motion is likely very characteristic - and easier to separate from regular activity. As mentioned you will need some sensor on the cat, and a gateway to get the data online. There is a bunch of DIY options, but it can be quite overwhelming and one can easily get stuck on seemingly minor things...
4 comments

There exists ready made BLE beacon hardware with accelerometer, which is excellent for an application like this. Many with NRF52 and LIS2/LIS3, for example. A well documented option is RuuviTag. May others from Moko, Minew, HolyIot etc. CR2032 battery would be great for small size. However one would have to write custom firmware, as the stock firmware just extracts orientation from the accelerometer, or notifies on any movement, which is not useful in this case. Zephyr RTOS has excellent support for the typical accelerometers and NRF52 - though it will be a step learning curve if one has never done any embedded. Conceptually the firmware is simple. Initialize accelerometer, say to 20 Hz sample rate, using FIFO. Sleep for 1 seconds, wake up, fetch accelerometer data from FIFO. High pass filter the samples, compute FFT to get energy at different frequencies. Stuff the FFT coefficients into a BLE advertisement packet, send N=4 times. Go back to sleep, repeat.
> There exists ready made BLE beacon hardware with accelerometer, which is excellent for an application like this.

I didn't know that and it's a great start. If I get something like the MOKOSmart M1 Ultra Thin Beacon Tag [1], will I be able to send accelerometer data to let's say a Raspberry Pi, process it further, and send a push notification when needed?

[1] https://www.mokosmart.com/beacon-tag/

You would need to write custom firmware. Which means access at least to the pin mappings. Moko dos not publish them openly. Ruuvi however does. One would also need a Nordic 52 Development Kit in practice. Other devices like ESP32 are not as power efficient but more beginner friendly.
I also think this is a better solution compared to the other suggesions. ML for audio and computer vision are both very interesting but absolutely not easy / short projects, from my limited experience it was never as straightforward as you'd expect. Reflections, inconsistent lighting conditions, echo, multipath propagation are all very unpredicatble factors that require a ton of math and signal (pre)processing to solve. Compared to this, I think one can boge together an ugly prototype to send data to a server over wifi / BLE in a few days even with close to zero electronics experience.

> though it will be a step learning curve if one has never done any embedded

For someone who has not previously worked with hardware I'd suggest to buy first a cheap Arduino-compatible board like this one [1] with BLE and WiFi instead of professional hardware. Although not as efficient, calls to hardware sensors are much simpler and well documented for example here [2, 3]. For the filtering part jononor is talking about I'd suggest this chapter 10 of this book [4] complemeted with more accessible resources like this video [5] (the book is to dig deeper into the maths, but not strictly necessary).

Then once you have this you can be as fancy as you want on the server side with ML models etc, but I suspect that since the seizures are rather long (minutes) just looking at the mean frequency about 15 ~ 30 seconds could already be a pretty good indicator.

[1]: https://www.lilygo.cc/products/t-energy-s3

(This is the first board I found, but I'm sure are also other smaller boards with ESP32 or ESP8266 using a CR2032 battery like https://hackaday.com/2019/02/22/a-coin-cell-powers-this-tiny... on AliExpress / BangGood / etc.)

[2]: https://www.arduino.cc/reference/en/libraries/arduinoble/

[3]: https://docs.arduino.cc/built-in-examples/sensors/ADXL3xx/

[4]: http://eceweb1.rutgers.edu/~orfanidi/intro2sp/orfanidis-i2sp...

http://eceweb1.rutgers.edu/~orfanidi/intro2sp/

[5]: https://www.youtube.com/watch?v=uNNNj9AZisM

These are extremely helpful resources, now I have somewhere to start! The ESP32_CoinCell project looks very promising, since I'm mostly worried about the size and weight of whatever I'll put on the collar. Thank you so much!
There are standard solutions for BLE advertisement to web (HTTP/MQTT). The best is when they just forward the raw BLE bytes, then you can decode and handle on the server. ble2mqtt on GitHub, for example. Or finished router-type units like Ruuvi Gateway or GL.inet GLS10. I have both of these lying around as backups, though not tested them yet. There are also Android apps. Not sure about iOS anymore, since restrictions were added around low level BLE a while back.
I have found two datasets of cats wearing accelerometer, none of these contain seizures. However they would be valuable in understanding the normal activity, and the data coming from that. Especially the natural variability, since one needs to discriminate the seizures from that. "Domestic cat accelerometer data calibrated with behaviours" (Dunford, 2024): https://datadryad.org/stash/dataset/doi:10.5061/dryad.q2bvq8...

"The Use of Triaxial Accelerometers and Machine Learning Algorithms for Behavioural Identification in Domestic Cats (Felis catus), A Validation Study" (Smit, 2023): https://www.mdpi.com/1424-8220/23/16/7165 https://figshare.com/articles/dataset/R_dataframes_of_annote...

And I found one paper on real-world detection of seizures in dogs: "Evaluation of a collar‐mounted accelerometer for detecting seizure activity in dogs" (Muñana, 2020). They conclusion was: "Generalized seizures in dogs can be detected with a collar-mounted accelerometer, but the overall sensitivity is low." https://onlinelibrary.wiley.com/doi/full/10.1111/jvim.15760 Their methodology for the model development seems generally sound. However, it does not seem like they have spent a lot of time on it, or are ML/DSP specialists. So there might be considerable room for improvement. If one could get a hold of this dataset, it might be possible to work on improving the detection method. With the goal that this would be highly transferrable to cats.

The lack of data for cat seizures is a challenge in this endeavour. However, there seems to be quite some videos of such events on Youtube. At the very least, they can be used for qualitative insights. But an idea would be to use motion tracking on the images to simulate an accelerometer, and generate a dataset from that. I have seen a paper on this kind of approach in another setting, but I cannot quite recall where to find it.

> The lack of data for cat seizures is a challenge in this endeavour

Not so much as you might think.

The approach I'd take (from airborne geophysics) is to treat the datasets as "environmental normal" and pull out tens of thousand of (overlapping) 5 minute data runs and treat those as input vectors to an SVD (Singular Value Decomposition) reduction which becomes the kernal of monitoring going forward.

Next rig up the cat in question with accelorometers and record data just as was done in the prior datasets.

Your input now is a continuous pipeline (say every 20secs) of "the last five minutes of data" as a vector - reduce each vector to kernal (spanned by the basis for the "normal" dataset) + noise (doesn't match the normal span).

There will be a regular amout of "noise"; seizures and unusual behaviour should spike the amount of noise and deserve attention.

After a bit, you'll know what you're looking for (/cough /handwave /details).

This, more or less, is how "out of band" signal is found in 256 channel radiometric spectrometer surveys - primed with a back catalog of hours of regular boring survey data and trained to look for the abnormal.

I agree that this is not a "big data" type problem, and that your approach of modelling the normal days is the way to go. Basically outlier/anomaly detection. But still, before on has 3-10 examples of the event being looked for - it is very hard to say something meaningful about how well it will work in practice. Getting over to the low data regime from the current zero data regime would help.
The insight from decades in exploration is "all anomalies are interesting"; the background drone matching helps to find the things of interest (until they're common and understood) - cats fighting, cats having sex, kittens stalk playing, etc. are all going to have differing (and overlapping) fingerprinting.

As with many projects of this nature there's very little more to say at this point in time until there's a pile of data to start wading through :)

Maybe someone will run with it.

You have quite successfully nerd sniped me. I love cats. :D
I really appreciate your help, thanks! Yuri says hi :) https://imgur.com/a/LfDttO9
You are most welcome :) Hi Yuri! What a lovely little panther!