# Packages for signal decomposition

**URL:** <https://discourse.julialang.org/t/packages-for-signal-decomposition/5909>\
**Category:** Signal and Image Processing\
**Created:** [September 15, 2017, 4:38pm UTC](https://discourse.julialang.org/t/packages-for-signal-decomposition/5909 "2017-09-15T16:38:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [September 15, 2017, 4:38pm UTC](https://discourse.julialang.org/t/packages-for-signal-decomposition/5909/1 "2017-09-15T16:38:34Z")

</div>

What are the packages out there for decomposing a signal into a basis of functions? Fourier basis, Radial basis, Cosine basis, …

I need to decompose a signal into a set of basis functions and coefficients, manipulate these coefficients, and reconstruct a _new_ signal with the same basis. I found [BasisFunctionExpansions.jl](https://github.com/baggepinnen/BasisFunctionExpansions.jl) but it currently doesn’t export an API to reconstruct a signal given a set of coefficients and a basis.

Interestingly, Python SciPy’s radial basis functions doesn’t seem to have this feature either.

---

<div class="post-metadata">

**Author:** ![ssfrr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ssfrr/32/3736_2.png) [@ssfrr](https://discourse.julialang.org/u/ssfrr)\
**Post date:** [September 15, 2017, 5:00pm UTC](https://discourse.julialang.org/t/packages-for-signal-decomposition/5909/2 "2017-09-15T17:00:47Z")

</div>

`dct` and `fft` and their inverses are both built-in (for cosine and fourier bases respectively) - but I’m assuming there’s something I’m missing about what you’re looking for.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [September 15, 2017, 5:32pm UTC](https://discourse.julialang.org/t/packages-for-signal-decomposition/5909/3 "2017-09-15T17:32:11Z")

</div>

@ssfrr I need to reduce the dimensionality of the signal. WIth radial basis functions for example, we can pick the number of basis in the expansion to be smaller than the number of points in the signal. If I have a very smooth signal represented by 1000-vector, I can represent it with let’s say only 10 coefficients in the basis. My ultimate goal is to perform [FPCA](https://en.wikipedia.org/wiki/Functional_principal_component_analysis), which is basically a fancy name for PCA on the coefficients of the expansion.

If you know a package for FPCA, that also solves my problem.

---

<div class="post-metadata">

**Author:** ![ssfrr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ssfrr/32/3736_2.png) [@ssfrr](https://discourse.julialang.org/u/ssfrr)\
**Post date:** [September 15, 2017, 7:55pm UTC](https://discourse.julialang.org/t/packages-for-signal-decomposition/5909/4 "2017-09-15T19:55:08Z")

</div>

Looks like [MultivariateStats](http://multivariatestatsjl.readthedocs.io/en/latest/pca.html) provides a PCA type and also get the projection matrix to convert back to the original space. so you’d have:

Original dataset (1000xN) → FFT(1000xN) → PCA(10xN) → manipulate stuff(10xN) → project (1000xN) → IFFT (1000xN)

If you know your signal is real-valued you can use `rfft` and `irfft` so your spectra is half the length.

(sorry if this is obvious or dumb or not what you’re looking for. I’ve never used FPCA before and am mostly thinking out loud).

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [September 15, 2017, 8:52pm UTC](https://discourse.julialang.org/t/packages-for-signal-decomposition/5909/5 "2017-09-15T20:52:19Z")

</div>

Thanks @ssfrr, I will be using Scipy’s splrep for now, I am already using `MultivariateStats.jl` for the PCA part. 🙂
