Skip to content

Apply Notch filters or Butterworth Low-pass and High-pass filters to data as it arrives

License

Notifications You must be signed in to change notification settings

Kazava/Unity-IIR-Realtime-Filtering

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Unity-IIR-Realtime-Filtering

Apply Notch filters or Butterworth Low-pass and High-pass filters to data as it arrives

Purpose

Data from external hardware like OpenBCI, Bitalino, Arduino etc. typically need to be filtered before they can be processed. When you need to analyze data after it is collected (e.g. in a psychological or medical experiment), there exist excellent packages both for MATLAB and R. If your Unity software needs to respond dynamically to input, one option is to send data to MATLAB, perform signal processing there, and then send data to Unity. This project, however, aims at performing simple filtering of data directly in C#. Specifically, 2nd order Notch and Butterworth filters, but also other IIR filters can be implemented and used on data as it is streamed into Unity. For details see the comments in FilterData.cs.

Example

The below image shows ecg data that was streamed in from an OpenBCI. The upper part of the diagram shows the ecg data, while the lower part shows absolute differences for each data point to the previous data point. In the left third of the diagram, data is not filtered at all, and the 50Hz electric hum is clearly visible. In the middle part, a 50Hz Notch filter is applied. In the right part, a 100Hz Notch filter, a 2nd-order 1Hz Butterworth Highpass filter and a 2nd-order 50Hz Butterworth Lowpass filter are applied additionally. Note that the is ecg is displayed "the wrong way round", but absolute changes in voltage are not affected. Both the 50Hz Notch filter and the other filters lead to a substantial increase in signal-to-noise-ratio, which is most clearly visible on the change in voltage. alt tag

Further Reading

License

These scripts run under the GPLv3 license.

About

Apply Notch filters or Butterworth Low-pass and High-pass filters to data as it arrives

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%