Inverse ICA for denoising

Hi there,

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

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:

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!

Hello and welcome to the community!

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

So you could get the matrix by calling

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.

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