2.11.14 fft_filters

Menu Information

Analysis: Signal Processing: FFT Filters

Brief Information

Perform FFT Filtering

Command Line Usage

1. fft_filters Col(2) cutoff:=5;

2. fft_filters Col(2) filter:=bandpass Freq1:=3 Freq2:=3.6;

3. fft_filters Col(2) filter:=threshold threshold:=1;

4. fft_filters Col(2) filter:=bandblock Freq1:=1.1 Freq2:=1.3 oy:= (Col(3), Col(4));

X-Function Execution Options

Please refer to the page for additional option switches when accessing the x-function from script

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Input iy

Input

XYRange

<active>

Specifies the input range

Filter Type filter

Input

int

Low Pass

Specifies the type of the filter

Option list

  • low:Low Pass
    Allows only low frequency components to pass
  • high:High Pass
    Allows only high frequency components to pass
  • bandpass:Band Pass
    Allow only frequency components within a specified range to pass
  • bandblock:Band Block
    Allow only frequency components outside a specified range to pass
  • threshold:Threshold
    Allow only frequency components whose amplitudes are larger than the threshold to pass
  • lowpp :
    This is a parabolic low-pass filter.
Lower Cutoff Frequency freq1

Input

double

0

This option is available only when the filter type is band pass or band block. It specifies the lower cutoff frequency.

Upper Cutoff Frequency freq2

Input

double

-1

This option is available only when the filter type is band pass or band block. It specifies the upper cutoff frequency.

Cutoff Frequency cutoff

Input

double

0

This option is available only when the filter type is low pass or high pass. It specifies the cutoff frequency. If no cutoff frequency is specified ("Auto"), an arbitrary cutoff of 25% and 75% of the frequency range of raw data, is used.

Pass Frequency pass

Input

double

-1

This option is available only when the filter type is Low Pass Parabolic. All frequencies below this value will be kept unchanged after being filtered.

Stop Frequency stop

Input

double

-1

This option is available only when the filter type is Low Pass Parabolic. All frequencies above this value will be removed completely.

Threshold threshold

Input

double

-1

This option is available only when the filter type is threshold. It specifies the amplitude threshold.

Keep DC Offset offset

Input

int

1

This option is available only when the filter type is high pass, band pass or band block. If this option is checked, the DC offset will remain unchanged during the filtering.

Output oy

Output

XYRange

<new>

Specifies the output

See the syntax here.

Description

Filtering is a process of selecting frequency components from a signal. A FFT filter performs filtering by using Fourier transforms to analyze the frequency components in the input signal.

There are six types of filters available in this function: low-pass, high-pass, band-pass, band-block, low-pass parabolic and threshold. The first four types are actually ideal filters. The low-pass filters block all frequency components above the cutoff frequency, allowing only the low frequency components to pass. High-pass filters are just the opposite: they block frequency components that are below the cutoff frequency. Band-pass filters only allow frequencies within a specific range determined by the lower and upper cutoff frequencies to pass the filters, while band-block filters remove all frequencies within the chosen range. The low-pass parabolic filter is different from the ideal low-pass filter in that its window function does not jump abruptly at the cut-off frequency. Between the pass frequency and the stop frequency, the window function used to select the frequencies looks like a parabolic curve. On the other hand, you can choose to use the threshold filter, which removes frequencies whose amplitudes are below a specific threshold value.

The dialog of this function allows you to see the real-time preview of the filtered signal when you change the variables. The cutoff frequencies, pass frequency, stop frequency or the threshold can be selected by dragging the lines on the preview pane.

Examples

  • To perform low pass filtering using cutoff frequency as 3, to XY data in columns 2 of the active worksheet, use the script command:
fft_filters iy:=col(2) cutoff:=3
  • To perform fft_filtering to data using a pre-saved theme file, save your preferences in the fft_filter dialog, and then execute it by typing the script command as follows, using your own saved-theme title:
fft_filters -t "my fft filter theme.oth"
  • Code Sample
/*
This script remove the high frequency part of a section of sound. 
The sample data is located in exe_path\Samples\Signal Processing\.
1. Import a wav file to a new book.
2. Perform low-pass filters on the data to remove the high frequency part of the sound.
3. Export the data to a new wav file.
*/
// Import the wav file
fnin$ = system.path.program$ + "Samples\Signal Processing\sample.wav";
fnout$ = system.path.program$ + "Samples\Signal Processing\Low-pass sample.wav";
newbook s:=0;
newsheet col:=1;
impWav fnin$;
string bkn$=%H;

// Remove the high frequency part
fft_filters [bkn$]1!col(1) cutoff:=2000 oy:=(<input>,<new name:="Low Frequency of the Sound">);

// Set the new wav column's format to be short(2) type for later export
wks.col2.format=1;
wks.col2.numerictype=3;
// Export to a new wav file;
expWav iw:=[bkn$]1! left:=2 fname:=fnout$;

Algorithm

The Fourier transform of the input signal is first computed. Then for low pass, high pass, band pass, band block and low pass parabolic filters, a window (determined by the filter type) is used to multiply the Fourier transform. If 1 is chosen for the variable Keep DC Offset, the first point of the window will be set as 1. For threshold filter, the power of every frequency component is examined. If it is not larger than the threshold, the corresponding frequency component will be discarded. After the altering of the frequencies, a backward or inverse Fourier transform is applied to gain the filtered signal.

Window for low pass filter:

Fft filters help English files image004.gif

Let f_c be the cut-off frequency. The window function can be expressed by:

w(f) = 
\begin{cases} 
  1, & \mbox{if }f  \le f_{c} \\
  0, & \mbox{if }f  > f_{c}
\end{cases}

Window for high pass filter:

Fft filters help English files image006.gif

Let f_c be the cut-off frequency. The window function can be expressed by:

w(f) = 
\begin{cases} 
  0, & \mbox{if }f  \le f_{c} \\
  1, & \mbox{if }f  > f_{c}
\end{cases}

Window for band pass filter:

Fft filters help English files image008.gif

Let f_{c1} be the lower cutoff frequency and f_{c2} be the upper cutoff frequency. The window function can be expressed by: w(f) = 
\begin{cases} 
  1, & \mbox{if } f_{c1} < f < f_{c2} \\
  0, & \mbox{otherwise }
\end{cases}

Window for band block filter

Fft filters help English files image010.gif

Let f_{c1} be the lower cutoff frequency and f_{c2} be the upper cutoff frequency. The window function can be expressed by: w(f) = 
\begin{cases} 
  0, & \mbox{if } f_{c1} < f < f_{c2} \\
  1, & \mbox{otherwise }
\end{cases}

Window for low-pass parabolic filter

Low pass parabolic filter.PNG

Let f_{c1} be the pass frequency and f_{c2} be the stop frequency. The window function can be expressed by: w(f) = 
\begin{cases} 
  1, & \mbox{if }f \le f_{c1} \\
  1-\frac{(f-f_{c1})^2}{(f_{c2}-f_{c1})^2}, & \mbox{if } f_{c1} < f < f_{c2} \\
  0, & \mbox{if }f \ge f_{c2}
\end{cases}

Related X-Functions

fft1, ifft1


Keywords:fourier, fft, window, band, block, threshold