0

After looking at such a plot, I'm asked if my smoothing is causal.

Once, during pre-processing, I smooth my raw data using this function:

def _smooth(x, data_freq):
    LpFilt_cutoffFreq = 4
    LpFilt_order = 4
    lowpass_filter = scipy.signal.butter(
        LpFilt_order,
        LpFilt_cutoffFreq,
        fs=data_freq,
        output="sos",
    )
    result = scipy.signal.sosfiltfilt(lowpass_filter, x)
    return result

and one last time, during my analysis, I smooth the plot like this:

signal_avg_conv = np.convolve(signal_avg, np.ones(smoothbin) / smoothbin, 'same')

How can I know if my smoothing is causal?

Zahra
  • 1
  • 2
  • Well, if giving the same data each time results in different answers, you know it is not causal... – Jon Custer Feb 13 '23 at 14:33
  • Thanks @JonCuster, it gives out the exact same result every time, so it must be causal. – Zahra Feb 13 '23 at 15:22
  • If it gives the same results for the same input it is deterministic. Causal, means that the output at a given moment only depends only on past inputs. – Bob Feb 13 '23 at 17:18
  • Thanks @Bob! In the two smoothing steps I apply to my data, do you see any dependence on future inputs? – Zahra Feb 13 '23 at 17:25
  • Since you are applying it to spatial data that was captured in advance it is causal. But I guess this is not the answer you are looking for. What makes sense to talk about in this context is, how the borders of the image is handled. It seems you are using the `same` mode that will pad the input with zeroes and then crop it to the same shape as the input. – Bob Feb 13 '23 at 18:18

0 Answers0