Filters, derivatives and lap values in Muretto math channels
Logged data is noisy. How to choose between Muretto's five smoothing functions, take a rate of change without amplifying the noise, and reduce a lap to a single number.
Scorsa Team4 min read

Raw channels are noisy. A damper potentiometer picks up vibration, a throttle sensor jitters, GPS speed steps. This post covers the functions that clean a channel up, measure how fast it changes, and sum it up for the whole lap.
Five ways to smooth
Muretto has five smoothing functions. They are not interchangeable, and picking the right one matters most when you are going to differentiate the result or compare it against something else in time.
filtfilt(x, hz) is the one to reach for first. It is a low-pass filter run forwards and then backwards, so it removes noise above the cutoff without moving anything in time. A brake application happens at the same metre before and after filtering.
filtfilt([Throttle], 8)
lowpass(x, hz) is the same filter run forwards only. It lags: features appear slightly later than they happened. That is how a filter in the car's electronics behaves, so use it when you want to see what the car's own systems would have seen. For analysis, filtfilt is usually better.
For both, the cutoff is in hertz and has to be a fixed number below half the logging rate. At 60 Hz the cutoff must be under 30 Hz.
movavg(x, seconds) is a centred moving average over a time window. It does not lag, and because the window is in seconds it behaves the same at any logging rate.
median(x, seconds) is a centred moving median. It removes single spikes, such as a dropout or a glitch in a sensor, without rounding off real steps. Use it on channels that jump, like a gear or a ride height that clips the ground.
smooth(x, n) is a trailing average over n samples. Because it counts samples, not seconds, it smooths a 10 Hz channel ten times more heavily than a 100 Hz one. Prefer movavg unless you want exactly that.
A rule of thumb: filtfilt for most things, median for spikes, movavg when you think in seconds.
Rates of change
deriv(x) is the rate of change per second, worked out from the samples either side. derivative() is the same function.
Differentiating noise makes it much worse, so smooth first. Every rate channel Muretto ships follows the same pattern:
deriv(filtfilt([Brake Pres], 8))
Some uses:
- Brake release rate. The negative part of the brake pressure rate shows how smoothly the driver comes off the brake into the corner.
- Damper velocity, if your logger records damper position but not velocity:
deriv(filtfilt([Damper FL], 20)). - Wheelspin on exit. In one gear, engine speed and road speed rise at the same rate. When engine speed pulls away from road speed on the power, the driven wheels are spinning:
[Throttle] > 50 && [Brake Pres] < 5 &&
deriv([RPM]) / max([RPM], 1000) - deriv([Speed]) / max([Speed], 20) > 0.3
The max(..., 1000) and max(..., 20) keep the divisions sensible at low revs and low speed.
Running totals
integ(x) is the running integral over lap time, from the start of the lap. integral() is the same function.
Integrating a condition gives you time spent in that condition, because a condition is 1 while true and 0 otherwise. Time spent flat out so far this lap:
integ([Throttle] > 98)
The value at the end of the lap is the total for the lap. The same pattern gives time on the brakes, time coasting, or time over a tyre temperature limit.
A related function, timein(x), counts the seconds x has been on without a break and drops back to 0 when it turns off. Use timein for "how long has this lasted?" and integ for "how much in total?".
acc(x) is a running sum of the samples, without multiplying by time. count(x) counts how many times x has turned on this lap.
A single number for the lap
Some calculations need one value for the whole lap:
lapmin(x),lapmax(x),lapmean(x): the lap's minimum, maximum and mean.lapfirst(x),laplast(x): the value at the start and at the end of the lap.
These are useful for normalising. Speed as a share of the lap's top speed:
[Speed] / lapmax([Speed]) * 100
Fuel used so far in the lap:
lapfirst([Fuel Level]) - [Fuel Level]
The built-in Corner Speed Limit uses lapmax on filtered lateral g, so the grip it assumes is the best grip the car showed on that lap.
There are also two running averages. avg(x) is the average from the start of the lap so far. meanwhen(x, condition) averages only where the condition holds, for example average throttle while cornering:
meanwhen([Throttle], abs([G Lat]) > 0.8)
Calibrating a sensor
Real-car loggers sometimes record a sensor as a raw voltage. maprange(x, x0, x1, y0, y1) is a two-point calibration: it maps x0 to y0 and x1 to y1, in a straight line, and holds the ends.
A linear potentiometer that reads 0.5 V at 0 mm and 4.5 V at 75 mm:
maprange([Damper FL Raw], 0.5, 4.5, 0, 75)
Use whatever name your logger gives the raw channel.
Status words
Some ECUs pack several flags into one number. bit(x, i) reads bit i, and bits(x, lo, n) reads the whole number held in n bits starting at bit lo. If bit 3 of an ECU status word is the traction control flag, bit([ECU Status], 3) is a channel you can plot and raise as an event.
Moving things in time
Two more for aligning signals:
shift(x, seconds)moves a channel later in time, or earlier with a negative value. Useful when one sensor lags another.sincestart()andelapsed()give seconds since the lap started.
Next in the series: turning any of these into events you can count, list and step through.