# Inverse ICA for denoising

**URL:** https://discourse.julialang.org/t/inverse-ica-for-denoising/84334
**Category:** Signal and Image Processing
**Created:** [July 16, 2022, 9:23pm UTC](https://discourse.julialang.org/t/inverse-ica-for-denoising/84334 "2022-07-16T21:23:16Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![nbagg](https://avatars.discourse-cdn.com/v4/letter/n/85e7bf/32.png) [@nbagg](https://discourse.julialang.org/u/nbagg)
#### Post date: [July 16, 2022, 9:23pm UTC](https://discourse.julialang.org/t/inverse-ica-for-denoising/84334/1 "2022-07-16T21:23:17Z")

</div>

Hi there,

I am trying to use ICA to denoise an EEG signal. I am currently using the MultivariateStats.jl to perform the ICA:

```julia
W = fit(ICA, data, num_elec)

```

This returns the mixing matrix as an ICA model. I want the inverse of this matrix. However, W is an ICA model and not a matrix so I get an error when I try to do:

```julia
inverse_W = inv(W)

```

I get this error:  
MethodError: no method matching inv(::ICA{Float64})

How can I get the inverse of this matrix or apply the inverse of the ICA?

Thank you!

---

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [July 17, 2022, 7:56am UTC](https://discourse.julialang.org/t/inverse-ica-for-denoising/84334/2 "2022-07-17T07:56:56Z")

</div>

Hello and welcome to the community!

Inside the ICA model struct, there’s a field called `W`

> <https://github.com/JuliaStats/MultivariateStats.jl/blob/master/src/ica.jl#L10>

So you could get the matrix by calling

```julia
model = fit(ICA, data, num_elec)
inverse_W = inv(model.W)

```

Note that you an only invert this matrix if it’s square, so you must opt to calculate as many components as there are features in the data.

---

<div class="post-metadata">

### Author: ![nbagg](https://avatars.discourse-cdn.com/v4/letter/n/85e7bf/32.png) [@nbagg](https://discourse.julialang.org/u/nbagg)
#### Post date: [July 19, 2022, 1:47pm UTC](https://discourse.julialang.org/t/inverse-ica-for-denoising/84334/4 "2022-07-19T13:47:14Z")

</div>

This is exactly what I was looking for, thank you!
