question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ICA and line noise can be unstable?

See original GitHub issue

I have been trying to remove the line noise of some ECoG data using ICA (I am trying to avoid bandstop filter here).

However, the results I get are pretty unstable, and I am not quite sure why. That is, fitting the ICA several times of the same data can give radically different results (very good or very bad).

  • I think I checked that this was not a copy/memory problem.
  • Setting the ICA(random_state) stabilizes the results (but is arbitrary, since different random_state give very different results).

Here is a summary of what I do [complete notebook here]:

  • sources = 1/F random source signal
  • mix these source signals together with a line noise (raw = dot(cov, vstack(sources, linenoise))
  • filtered_raw = raw.copy().filter(55, 65) to filter around line noise (because of this ref)
  • ICA().fit(filtered_raw)`
  • compute PSD of the data in component space dot(ica.components, original_raw)
  • find the component carying the line noise: bad
  • remove it from the data: ica.apply(original_raw, exclude=[bad])
  • check the PSD of this cleaned data

This works ~ well for low sampling frequency with or without decim>1, but gets unstable for high sampling frequency when we use a decim>1.

This could be due to aliasing, so I tried to shuffle the data just prior to fitting the ICA

times = np.arange(raw.n_times)
np.random.shuffle(times)
raw._data = raw._data[:, times]

the results are a bit better, but still pretty unstable. In the notebook, you can see that it works 50% of the time

Any idea what I do wrong?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:32 (32 by maintainers)

github_iconTop GitHub Comments

2reactions
mmagnuskicommented, Mar 23, 2016

And just by the way: do you think implementing eeglab’s cleanline in mne would be a worthwhile investment?

0reactions
kingjrcommented, May 11, 2016

I’m closing it for now. Thank you all for your comments and help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Independent Component Analysis for artifact removal
The noise above is most likely due to instability in the ICA decomposition algorithm, which here forced to create two components compensating for...
Read more >
Powerline noise elimination in biomedical signals via blind ...
Usually, powerline noise in biomedical recordings are extinguished via band-stop filters. However, due to the instability of biomedical signals ...
Read more >
How To Reduce Noise In EEG Recordings [11 Solutions]
If you are working with bio-data, you have probably come across noisy data. Here is how to remove the noise from the signal...
Read more >
Beyond Noise: Using Temporal ICA to Extract Meaningful ...
Thus, the BOLD signal can be seen as temporally smoothed in comparison with the neuronal activity, motivating the neglect of signal fluctuations ...
Read more >
Identifying key factors for improving ICA‐based ...
It can be achieved by applying spatial filter methods to the data, ... then interpolated (e.g. channels heavily contaminated by line noise, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found