rb643 / resting_state_eeg

8 stars 5 forks source link

Issues with PCA #4

Closed janfreyberg closed 7 years ago

janfreyberg commented 7 years ago

Currently getting this issue:

RuntimeError: One PCA component captures most of the explained variance, your threshold results in 0 components. You should select a higher value.

Not sure what is going on there - the threshold is set to 0.99, i.e. 99% of variance. So it's suggesting that one PCA component covers 0.99 of variance...

janfreyberg commented 7 years ago

Just pushed a plot of 10 ICA components in the notebook:

https://github.com/rb643/resting_state_eeg/blob/master/resting_state_eeg.ipynb

Doesn't look particularly informative at the moment...

rb643 commented 7 years ago

Hmm that is interesting... For the PCA what comes to mind is that (1) there is one incredibly noisy channel in there somewhere that is messing up everything and we thus need to do some more filtering before or (2) something is happening during the re-referencing that causes it all to become relative to the re-reference channel.

Solution to 1 would be to just remove that PCA component and re-run it. I think its a fair assumption that if one component explains more than 95% of all the signal variance then its likely to be noise. Solution to 2 might be to not re-reference to the mastoid channel, but instead use the default re-referencing that uses the mean of all channels.

As for the ICA components we should probably take notice of the warning and use the maximum number of ICA components (which should be 64). That will also make it easier maybe to see specifically noisy channels?

What do you think?

rb643 commented 7 years ago

Increasing the ICA component number fixes the warning at least. How do you check the automated component classification from the PCA?

janfreyberg commented 7 years ago

It fixes the warning, but all components look the same...

I'm not sure how you can check the PCA. As far as I understand it, it runs a PCA first to find out how many components to use, and then does the ICA to find that many components.

I think it could be that it's one extremely noisy channel, but then at the same time, that would be visible in the ICA components, right? And it doesn't look as though it's one channel driving it.

janfreyberg commented 7 years ago

Actually, one easy thing we could try is high-pass filtering it

janfreyberg commented 7 years ago

Yeah I think that fixes a lot of the issues! For the WPLI, do you need a particular frequency spectrum? At the moment I'm filtering from 0.5 to 45 and the components look like they make sense now:

https://github.com/rb643/resting_state_eeg/blob/master/resting_state_eeg.ipynb

janfreyberg commented 7 years ago

I've updated it to only show the components it would automatically exclude

rb643 commented 7 years ago

Nice! would be good to know what the pca is picking out indeed, from the plots it seems fairly reasonable that those are relatively noisy components, but would still like to know the exact criteria :)

For the bandwidth I'm tempted to take anything in between 0.5-60 to allow quite a large gamma range, but only if you are sure the notch filter takes care of the line noise at 50Hz efficiently of course.

I think initially we can look at the WPLI for the whole spectrum but ultimately we would need to split them out across frequency bands.

janfreyberg commented 7 years ago

For the PCA criteria, you can actually choose them yourself, see here: https://mne-tools.github.io/stable/generated/mne.preprocessing.run_ica.html

At the moment for these two participants, it removes a reasonable amount based on EOG correlation, and they look pretty convincingly ocular. Not sure about other components, for example 0 and 1 for participant 0001...