mbauman / Signals.jl

An abandoned work-in-progress for a high level Signal type with a common timebase (in seconds) and groups of channels. Deprecated in favor of AxisArrays.jl.
github.com/JuliaArrays/AxisArrays.jl
Other
6 stars 0 forks source link

High-level filtering #1

Open mbauman opened 10 years ago

mbauman commented 10 years ago

A very nice side-effect of carrying around a time range is that it can greatly simplify the calculation of normalized cutoff frequencies. This allows the user to specify things in Hz, deferring coefficient calculation until the filtering is actually performed.

But what do I want this to look like? I would need to export more types, one for each wrapped filter type. I like the DSP.jl way of using types for the kinds of filter (Highpass, Lowpass, etc). But coopting those types to hold cutoffs in Hz instead of Wn seems wrong. What if I also used SIUnits.jl?

API sketch:

f = ButterworthFilterSpec(5 #=pole=#, Lowpass(10Hz))
filtfilt(f, Signal(…))

# Now f has been "realized" and holds the normalized Wn
f: ButterworthFilterSpec(5, Lowpass(#= unitless normalized Wn =#))
plot(f) # Shows the frequency response

I might even be able to coopt DSP.jl's digitalfilter method to return a higher level type for digitalfilter(::FilterType{Hertz}, …) (although that'd require some changes to DSP.jl).

As an added bonus, do I want to enable filtering pipelines to do several filters at once? Perhaps a filtfilt{F<:FilterSpec}(::Array{F}, ::Signal)? What about rectification? Perhaps a more generic processing pipeline is more appropriate than shoe-horning all this into "filtering."

mbauman commented 10 years ago

Another option would be filt(::Signal, ::FilterType, ::Filter). This is much simpler, but it has the downside that it's not as easy to plot the frequency response.