RFC: Re-applying baseline correction after ICA
See original GitHub issueSkimming over some Study Template analysis results with @agramfort, we found that some of our data appeared to be not baseline-corrected – some traces clearly didn’t have a zero-mean during the baseline period.
So I started digging and figured that we had indeed applied baseline correction to our data; yet after cleaning the Epochs via ICA, the baseline signals of some channels had started floating away from zero.
Now this may not come as a surprise to some of you, but I have to admit it caught me off-guard. I’d never seen this behavior before with the data I’d worked with so far, and I’ve failed to reproduce a similarly visible effect using our sample
data.
However, looking through the ICA tutorial, where we clean Raw data, one can see the essence of this effect too – albeit with Raw and not Epochs (lower panel):
I’d like to propose and discuss the following changes and enhancements to deal with this behavior:
- Clearly state in the docs that baseline correction should be re-applied to Epochs and Evoked data after applying ICA
viz.plot_ica_overlay()
should automatically re-apply baseline correction to the cleaned signal if an Evoked was passed- for this, we’d need to add an
Evoked.baseline
attribute, which gets inherited from the parentEpochs.baseline
. This has been on my agenda for a while anyway in order to improve provenance, so I’d might take a shot at this anyway.
- for this, we’d need to add an
- We could even go so far as to auto-reapply baseline correction to Epochs and Evoked data as part of
ICA.apply()
, so users wouldn’t have to do this themselves. This behavior should be toggle-able using a new kwarg.
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (18 by maintainers)
Top GitHub Comments
we converge to the same thing.
Do not baseline epochs passed to ICA.
Apply baseline only after doing ICA cleaning.
No need to enable not centering the PCA step.
SSP is a linear spatial operator, so if all channels have zero mean (during some interval) all channels will have zero mean after the operation (in that same interval). This is because the mean (over that interval) is also a linear operator.
To demonstrate how ICA violates this, let’s say we have two channels of data for one 3-sample epoch that that each already have zero mean over time, for example
[[1, 0, -1], [0, 0, 0]]
. If the empirical means estimated by ICA during fitting happened to be, say -1 and 0, ICA will:[[2, 1, 0], [0, 0, 0]]
[[0, 1], [1, 0]]
(ICA in practice will do something different like unmix-exclude-mix, but this gives a simple example to play with). So now our data after the ICA operator is[[0, 0, 0], [2, 1, 0]]
.[[-1, -1, -1], [2, 1, 0]]
.Now our previously-zero-mean channels have means
-1
and1
, which is not good. Let’s call this operationB = ICA(A)
. If we apply this operation to identical data, that will (trivially) haveB = ICA(A)
having means-1
and1
, too.And this is where you can see that the
ICA
operation above is not linear. We know thatB + B = ICA(A) + ICA(A)
but that this means2B = ICA(A) + ICA(A)
. We know that sinceB
has means-1
and1
,2B
will have means over time of-2
and2
. For linearity to hold, we need that2B = ICA(A) + ICA(A) = ICA(A + A) = ICA(2A)
, but unfortunatelyICA(2A)
will go from[[2, 0, -2], [0, 0, 0]]
to start, through step 1 to[[3, 0, -1], [0, 0, 0]]
, through step 2 to[[0, 0, 0], [3, 0, -1]]
, through step 3 to[[-1, -1, -1], [3, 0, -1]]
, which has means-1
and2/3
, which do not equal-2
and2
. Hence our ICA operation is not a linear operator, which I think it is meant to be…If we remove the mean subtraction at the beginning and mean re-addition at the end, ICA will be a linear spatial operator (just like SSP) in the end. To me this is starting to seem like the correct option.