https://github.com/baggepinnen/adaptivefilters.jl

Classical adaptive linear filters in Julia

https://github.com/baggepinnen/adaptivefilters.jl

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (8.6%) to scientific vocabulary

Keywords

adaptive-filtering adaptive-line-enhancer adaptive-systems dsp lms nlms recursive-least-squares signal-processing

Keywords from Contributors

symbolic-computation neural-sde control estimate pde symbolic-numerics bode-plot control-theory delay-systems discrete-systems
Last synced: 5 months ago · JSON representation

Repository

Classical adaptive linear filters in Julia

Basic Info
  • Host: GitHub
  • Owner: baggepinnen
  • License: mit
  • Language: Julia
  • Default Branch: master
  • Homepage:
  • Size: 55.7 KB
Statistics
  • Stars: 14
  • Watchers: 2
  • Forks: 4
  • Open Issues: 1
  • Releases: 3
Topics
adaptive-filtering adaptive-line-enhancer adaptive-systems dsp lms nlms recursive-least-squares signal-processing
Created about 6 years ago · Last pushed over 2 years ago
Metadata Files
Readme License

README.md

AdaptiveFilters

CI Coverage

Simple adaptive AR filters. We export two functions:

julia yh = adaptive_filter(y, alg=MSPI; order=4, lr=0.1) This filters y with an adaptive AR (only poles) filter with specified order and returns yh which is the predicted output from an adaptive line enhancer (ALE). If your noise is wideband and signal narrowband, yh is your desired filtered signal. If the noise is narrowband and the signal is wideband, then y-yh is your desired filtered signal.

Arguments: - alg: Stochastic approximation algorithm or weight function. Examples: OMAP, MSPI, OMAS, ADAM, ExponentialWeight, EqualWeight. ExponentialWeight corresponds to the recursive least-squares algorithm (RLS). ADAM corresponds roughly to the normalized least-mean squares (NLMS) algorithm. More options exist if OnlineStats is loaded. - y: Input signal - order: Filter order - lr: Learning rate or weight depending on alg

The function julia focused_adaptive_filter(y, band, fs, args...; kwargs...) allows you to specify a frequency band (tuple) in which to focus the attention of the adaptive filter. fs here denotes the sample rate, e.g., 44100Hz.

Installation

julia using Pkg; Pkg.add("AdaptiveFilters")

Demo app

```julia using AdaptiveFilters, Plots, Interact inspectdr() # Preferred plotting backend for waveforms

y = [sin.(1:100); sin.(0.2 .(1:100))] # A sinusoid with changing frequency yn = y .+ 0.1randn(length(y)) # A sinusoid with noise

function app(req=nothing) @manipulate for order = 2:2:10, lr = LinRange(0.01, 0.99, 100), alg = [ExponentialWeight, MSPI, OMAP, OMAS, ADAM] yh = adaptive_filter(yn, alg, order=order, lr=lr) e = yn.-yh plot([yn yh], lab=["Measured signal" "Prediction"], layout=(2,1), show=false, sp=1) plot!(e, lab="Error", sp=2, title="RMS: $(√mean(abs2, e))") end end

app()

Save filtered sound to disk

using WAV yh = adaptive_filter(yn, OMAP, order=4, lr=0.25) e = yn.-yh wavwrite(e, "filtered.wav", Fs=fs) ``` window

NLMS

A normalized least-mean squares (NLMS) filter can be created like julia using AdaptiveFilters, Random N = 60 # Number of filter taps μ = 0.01 # Learning rate f = NLMS(N, μ)

This filter can then be called like ŷ, e = f(x, d) where x is the input signal, d is the desired signal and is the filtered signal. The error e is also returned. This call modifies the internal state of f.

Adaptive line enhancer

The NLMS filter can be used to build an adaptive line enhancer (ALE) by letting the input signal be the desired signal delayed by a number of samples Δ:

```julia using Random Random.seed!(0) y = sin.(0:0.1:100) yn = y + 0.1*randn(length(y)) # A sinusoid with noise

T = length(y) YH = zeros(T) E = zeros(T)

Δ = 1 # Delay in samples

for i = eachindex(y) YH[i], E[i] = f(yn[max(i-Δ, 1)], yn[i]) end

using Plots, Test @test mean(abs2, y[end-100:end] - YH[end-100:end]) < 1e-3 plot([y yn YH E y-YH], lab=["y" "yn" "yh" "e" "y-yh"]) ```

Internals

This is a lightweight wrapper around functionality in OnlineStats.jl which does all the heavy lifting.

Usage from python

  1. First install Julia and install this package in Julia.
  2. Install pyjulia using their instructions.
  3. Now the following should work

```python $ python3

import julia from julia import AdaptiveFilters as af yh = af.adaptivefilter(y) if that fails, try replacing the first line with python from julia.api import Julia jl = Julia(compiledmodules=False) ```

Keyword args etc. work as normal python af.adaptive_filter(y, af.ADAM, order=2)

Example: Adaptive cicada filtering

The following function does a reasonable job at filtering out the sound of cicadas from an audio recording julia cicada_filter(y,fs,args...; kwargs...) = y-focused_adaptive_filter(data,(4200,11000),fs,args...; kwargs...)

Owner

  • Name: Fredrik Bagge Carlson
  • Login: baggepinnen
  • Kind: user
  • Location: Lund, Sweden

Control systems, system identification, signal processing and machine learning

GitHub Events

Total
Last Year

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 33
  • Total Committers: 3
  • Avg Commits per committer: 11.0
  • Development Distribution Score (DDS): 0.061
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Fredrik Bagge Carlson b****n@g****m 31
github-actions[bot] 4****] 1
Fredrik Bagge Carlson b****n@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 4
  • Total pull requests: 3
  • Average time to close issues: 3 days
  • Average time to close pull requests: about 2 months
  • Total issue authors: 3
  • Total pull request authors: 2
  • Average comments per issue: 3.25
  • Average comments per pull request: 1.0
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 1
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • baggepinnen (2)
  • Sinansi (1)
  • JuliaTagBot (1)
Pull Request Authors
  • baggepinnen (2)
  • github-actions[bot] (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • julia 3 total
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 3
juliahub.com: AdaptiveFilters

Classical adaptive linear filters in Julia

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 3 Total
Rankings
Dependent repos count: 9.9%
Forks count: 24.5%
Average: 25.8%
Stargazers count: 29.9%
Dependent packages count: 38.9%
Last synced: 6 months ago

Dependencies

.github/workflows/CompatHelper.yml actions
  • julia-actions/setup-julia latest composite
.github/workflows/TagBot.yml actions
  • JuliaRegistries/TagBot v1 composite
.github/workflows/main.yml actions
  • actions/checkout v2 composite
  • codecov/codecov-action v1 composite
  • julia-actions/julia-processcoverage v1 composite
  • julia-actions/julia-runtest latest composite
  • julia-actions/setup-julia latest composite