ANY-maze Help > The ANY-maze reference > The Protocol page > The elements of a protocol > Inputs and outputs > Signals > Setting up a filtered signal > Specifying a filtered signal's filter characteristics

Specifying a filtered signal's filter characteristics

In brief

There are four filters available for generating a filtered signal from a source signal. These are: low pass, high pass, band pass and averaging. In the case of low and high pass filters, you just have to specify the filter's cut off frequency, which is the frequency above which (for high pass) or below which (for low pass) the signal will pass. For a band pass filter, you have to specify both a low and a high cut off frequency - the signal between these frequencies will pass. For high, low and band pass filters, there is also a Transition width setting; this is described in detail below, but you can usually just it leave blank - this will cause ANY-maze to use an automatic value.

The final filter type is an averaging filter - this just averages across a certain number of samples of the incoming signal; you have to specify how many samples this is.

Details

In order to understand the details of the filters which can be applied to a signal, you need to first understand what a signal actually is. Although signals were introduced in this help as 'inputs which have a continuously variable value', that's not exactly correct - or to be precise, the thing the signal is reporting on does have a continuously variable value, but the signal will only actually know its value at discrete (usually very short) moments in time. In other words, a signal will 'sample' the physical input at some set frequency (perhaps 100 times a second) and will then string all the values together to produce something which looks pretty much like the input - see figure 1.

  

  

Figure 1. A signal is actually made up of lots of discrete values (the orange dots), which are 'sampled' at some set frequency by the signal's interface device. In this case, the dots are 10ms apart, so the signal is being sampled 100 times per second, i.e. at 100Hz.

While this may seem quite esoteric, it actually has an important repercussion - it means that a signal can't detect changes which are shorter than its sampling period. If you stop and think about it, this is self-evident. If the signal in figure 1 had a change which happened so quickly it fell between two of the dots, then it would be 'missed'. In fact, the highest frequency which can be successfully sampled by a signal is HALF the sampling frequency - this is called the Nyquist frequency. For example, if a signal is sampled at 100Hz then the Nyquist frequency is 50Hz - in other words with a sampling frequency of 100Hz, you won't be able to 'capture' any signal with a frequency higher than 50Hz.

And this is important for various reasons:

 •You should always endeavour to use a sampling frequency which has a Nyquist frequency above (ideally well above) the highest frequency you expect to be present in the signal. This is true even if you're not interested in any high frequency components. 
 •You can't use a filter to remove frequencies above the Nyquist frequency. 
 •The filter parameters - which are what we're about to talk about - are limited by the Nyquist frequency. In this case, ANY-maze will check that you don't try to use inappropriate parameters and will warn you if you do.  

Low pass filter

Let's start by considering a low pass filter, although many of the considerations I'll describe apply to high and band pass filters too.

To set up a low pass filter, you need to specify the Low pass cut off frequency in Hertz. This is the frequency below which the signal will pass and above which it will be blocked - see figure 2.

  

  

Figure 2. The frequency response of a low pass filter. Here you can see that the transition width represents how quickly the filter changes from the pass band to the stop band.

Transition width

You can also optionally specify the transition width. As can be seen in figure 2, this determines how quickly the filter transitions from the pass band to the stop band. It seems quite obvious that a narrow transition width is desirable; however, there's a trade-off, because a narrow transition width will generate a large 'delay' while a wide one will create a small 'delay'. The 'delay' is how far behind the source signal the filtered signal will be. For example, imagine that you have a source signal which is not oscillating at all, so it's at 0Hz. You then introduce a small burst of 5Hz oscillations. How long after the 5Hz signal actually starts would you expect the output of a 10Hz low-pass filter to show this 5Hz signal? The answer seems obvious - immediately! But in fact, digital filters (like those used in ANY-maze) introduce a delay.

In the above example, if we were to use the default transition width (which for a low pass filter is 10% of the cut off frequency, so 1Hz in this case) then the delay would be about 1s. If we changed the transition width to 0.2Hz, the delay would be about 5s, and if we changed it to 10Hz it would be about 0.1s.

The fact that this delay exists is often not actually very important. What it means is that we'll only know what the filtered signal looks like 1 second (using the default transition width in our example) after the signal enters the filter - but who cares?

Well, if you're analysing this data to generate results after the test has actually occurred (which is what ANY-maze will do) then the delay is almost meaningless - the only point to be aware of is that it will mean that you won't have any filtered signal data for the last 1s of the test. This is because the filter needs all the data from a 1s 'window' into the future in order to generate its output. So the filtered data for time 0s is created from the source data for time 0s-1s and the filtered data for time 0.1s is created from the source data for time 0.1s-1.1s, and so on. But if the test ends at time 10s, then the filtered data for time 9.5s (for example) needs the source data from time 9.5s - 10.5s - but we have no data after time 10s, so we can't create this output. So, other than the fact that we'll lose the last 'delay length' of the filtered signal, the delay doesn't really matter too much...

Except when we're using the filtered signal in real time. For example, imagine that you were using a filtered signal to monitor some aspect of an animal's physiology, and you wanted to switch on a light if the signal value increases by 10%. This would be simple to do using a procedure, but there'd be a problem - the signal would only actually change at a point 'delay' seconds after the animal's physiology changed, and so the light would come on 'delay' seconds too late. There's nothing you can do about this, but as filter delay will usually be quite small, it's generally not really a problem. However, if you decided to change the transition width to something very small, then you'd create a long delay and then this effect might become important.

You'll find that when you enter the cut-off frequency(s) and transition width for a filter, ANY-maze will calculate the delay and tell you what it will be. You can then make a decision as to whether to adjust the parameters so as to reduce the delay, based on the requirements of your experiment.

High pass

Setting up a high pass filter is almost identical to setting up a low pass filter, just that the cut off frequency will define the frequency above which the signal will pass. The filter will have a transition width and a delay, just like the low pass filter has (see above).

Band pass filter

A band pass filter passes the signal in a specific band of frequencies - see figure 3. Again, like the low pass filter, the band pass filter has a transition width and a delay.

  

  

Figure 3. The frequency response of a band pass filter.

 

Averaging filter

An averaging filter simply averages a certain number of source 'samples' to create the filter output. For example, if you specify that an averaging filter should average 20 samples, then for each sample it will take the 10 samples before it and the 10 after it (including the sample itself) and average their values to produce the new, filtered, sample.

If you think about how this works for a moment, you'll realise that it means that the filter requires the ten (in our example) samples after the sample it's working on; this means it will have to wait for these samples to arrive, and so this filter will have a delay, just like the low, high and band pass filters. The same considerations relating to the delay (described above) apply to this filter too. Again, ANY-maze will calculate the delay and display it when you enter the filter parameters.

Charting filtered signals

It can often be very helpful to have ANY-maze plot a chart of the source and filtered signals. This makes it easy to see the effect the filter is having.

  

  

Figure 4. A source signal (top) and a low pass filtered signal (bottom). The filter had a cut off frequency of 3Hz and a transition width of 1Hz. The source signal starts at around 2.5Hz goes to about 9Hz and drops back to around 2Hz again.

 

© Copyright 2003-2026 Stoelting Co. All rights reserved

ANY-maze help topic T0164