# Filtering on a time signal

I am new to DSP, and am mostly self taught. I have a couple of questions, that may be too basic, but I couldn't really find an answer online.

I have a signal obtained by plotting the motion of a human in 2D from a fixed point of reference (origin).

1. The data is noisy, so I wanted to use a filter to get a smoother signal.
2. I want to filter out different motions. The intuition is that different kind of motions would occur at different frequencies.

From what I googled, and read online; it seems I need a bandpass filter like butterworth. However, after reading a few tutorials and book chapters, I have two questions:

1. My signal is a time-signal (displacement vs time), but the filter takes the input in terms of cut-off frequency. Does this mean I have to convert the signal into frequency domain, or does the filter take care of it? I am bit confused on how this actually works.
2. On a related note, I don't know the frequency of each motion that I am trying to filter out i.e. the intuition is that the frequency for different motions be different, but how do I determine by cut-off values? Is it usually done by trial and error, or is there a more scientific way to accomplish this?
• How fast do you take samples (sample rate)? This will at least give you an idea of the maximum frequency supported by your signal (Nyquist frequency = sampling rate / 2 ). Your cut-off frequency will be expressed as a fraction of the sampling rate. Now just feed the filter with different frequencies and see what comes out. You don't need to convert to FFT before using a filter unless you want to use FFT filtering (FFT convolution) Commented Jul 27, 2017 at 13:31
• mods: The original question was an unregistered account. Can you please merge it with this account? I was not able to leave comments for some reason without registering. @Marcus: Can you explain a bit more about your second point about spectrum estimation? Commented Jul 27, 2017 at 14:16
• @dspnoob123 Please follow the instructions here: stackoverflow.com/help/merging-accounts
– Peter K.
Commented Jul 27, 2017 at 16:33
• well, arpit recommended that you first estimate the spectrum to look where your movement signal lies, and then adjust the filters based on that. I say: Why adjust even have any filters when you get all the info you need from the spectrum estimate? Commented Jul 27, 2017 at 16:51
• @MarcusMüller Is it possible to extract the relevant signal based on simply spectral analysis? I need the relevant signal for a particular motion for post-processing. If that's possible, then yes, your suggestion would work for me. Commented Jul 27, 2017 at 17:28

1. My signal is a time-signal (displacement vs time), but the filter takes the input in terms of cut-off frequency. Does this mean I have to convert the signal into frequency domain, or does the filter take care of it? I am bit confused on how this actually works.

You design or specify the filter in the frequency domain, but the actual filtering can be directly accomplished in time. There are FFT based filtering algorithms that are typically more efficient, but there is no requirement to transform your signal to the frequency domain.

1. On a related note, I don't know the frequency of each motion that I am trying to filter out i.e. the intuition is that the frequency for different motions be different, but how do I determine by cut-off values? Is it usually done by trial and error, or is there a more scientific way to accomplish this?

Anything that doesn't require trial and error is suspect, scientific methodology wise. I suggest that you try to be more specific about what filtering out different motions actually means. Some kinds of phenomena are a superposition of features which are often separable, of which some can be "filtered out" and others don't lend themselves to that.

You might want to use a tool known as the Short Time Fourier Transform (STFT) and see if you can eye ball any patterns associated with desired/undesired motion.

Finally, try Google Scholar.

• By "filtering out", I meant that if there are 2 kind of motions obtained from a single person (e.g. they run for 30 seconds, and then jog for 2 minutes), Both motions would be occurring at different freqs, and I wanted to separate out the 30s signal, and the 2min signal. Commented Jul 30, 2017 at 14:20
• @dspnoob123 I believe that you are actually looking for a time series classification algorithm. There are many mature solutions for identifying one kind of signal over another,particularly if there isn't a lot of "noise" in your signals. I could make some suggestion but Google can provide more. I would be very surprised if the answer you're looking for hasn't been answered elsewhere. I still think looking at the STFT is a good idea.
– user28715
Commented Jul 31, 2017 at 16:23
• Thank you, I'll look into the classification algorithms. Based on your answer, I have started looking at STFT, and I am starting to understand this more now. Commented Jul 31, 2017 at 18:12

Few points to answer the questions

Editing the first answer from the comments of Marcus Muller

• The transform to frequency domain and back always happens on parts of the signal, padded to specific lengths, and thus, the transform is part of the filtering algorithm itself, hence no need to explicitly transform time signal to frequency domain before filtering.

• To find out the cutoff frequencies corresponding to each of the motions, you can see frequency spectrum of the input signal and try to figure out which frequency components are dominant during which type of motion. this will give you a fair idea of cutoffs for designing band pass filters.

• Re: filters: any FIR can be implemented with Frequency-domain-based fast convolution (not just BPFs). In any case, you never have to convert to frequency domain first. Re: motion analysis, exactly, spectrum estimation is the way to see the things happening periodically in your signal. If you see things in there, you'd usually just make a spectrum-estimation-based motion estimator instead of modifying filters and then estimate motion of the filter outputs :) Commented Jul 27, 2017 at 14:03
• @MarcusMüller by frequency domain implementation I meant instead of convolving in time domain, one can multiply in frequency domain. Commented Jul 27, 2017 at 14:23
• exactly, that's fast convolution; but you can't actually work on the discrete Fourier transform of the input signal itself, because that would yield a cyclic rather than a linear convolution. Hence, the transform to frequency domain and back always happens on parts of the signal, padded to specific lengths, and thus, the transform is part of the filtering algorithm itself, not a step happening before. Commented Jul 27, 2017 at 16:01