# Model-based Kalman filtering a noisy signal

In a healthcare application, I need to calculate urine flow by differentiating the mass of urine emitted by a person over time. The measuring instrument consists of a load-cell under a fluid container, with its signal being sampled at 2kHz.

My original dataset is here.

The signals are noisy due to the load cell, and drippings over the fluid container, with an FFT showing an exponential-like decay in the magnitude of higher frequencies. Due to this noise, when I try to differentiate the volume signal to obtain the flow signal, I get a very rough signal.

I have already tried smoothing the volume signal in many ways (savatski-golay, gaussian convolution, butterworth low-pass), but by differentiating the smoothed signal I get either a still very wavy signal, or one that is so smooth that it no longer contains the expected characteristics of the flow profile.

I studied a bit about differentiation of noisy signals so as to estimate, say, velocity and acceleration directly from the position signal, and the main suggestion is to use a Kalman filter, which I never got to the point of making work, or even understanding conceptually.

There are some factors influencing on the signal characteristics, some of them due to the physiological model being represented, others not:

1. Physiological component: the flow is expected to be determined by muscle contractility (mostly involuntary bladder muscles) and urethral shape (affected by static structures like prosthate, and active structures like pelvic floor muscles);
2. Principle of measurement component: the fluid mechanics of the urine falling into the container, especially "turbulent" elements like drippings;
3. Instrumentation component: The load-cell/strain-gauge noise, with a much higher frequency than the two previous factors.

So my goal would be to implement a Kalman filter algorithm (I can use Python or C#) that gives me estimates for both Volume and Flow, based on the measured Volume, and that models the physiological component while "removing" the turbulence of the impact on the container (e.g. drippings) and the instrumentation noise.

I don't expect to get a ready answer, but since this is a bit beyond my skill level, I'm quite lost regarding where to start.

• have you tried, polyfit or spline fit to your data ? Commented Jul 12, 2019 at 20:29
• You will first need to do some sort of system identification to get a model of your system, which can then be used in a Kalman filter. Commented Jul 13, 2019 at 16:34
• 1) It seems your "data set" is already differentiated. If so, could you supply the raw data (which I would expect to be monotonically increasing). 2) I second the "system identification" 3) If you want to classify the "flow rate" into contractions, drips, etc you need to formulate the criteria and perhaps use wavelets to isolate significant events 3) If your load sensor is introducing inband noise you have a physical problem that probably means you have to examine the mechanics and understand it. 4) I really don't think you are geting off by simple filtering: Kalman or not. 5) Think a lot. Commented Jul 16, 2019 at 17:47