Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In my opinion, the current KeyPy code calculates the explained standard deviation, not the explained variance.
In agreement with formulas 10-12 of Pascual-Marqui's 1995 IEEE paper, the projection of the momentous map on the model map (which in KeyPy is calculated as the dot product in line 293) should be squared, and divided by the variance (not std). The same changes should be made in modelmaps.py.
Here is a simple test program with 3 channels, one model map, and one time-frame.
KeyPy gives 0.5 for the explained variance, which probably should be 0.25.
import numpy as np
from math import sqrt
nch = 3
a = sqrt (2);
model = ([-a,0,a])
b=np.sum(np.abs(model)2,axis=-1)(1./2)
for col in range(nch):
model[col]=model[col]/b
org_data = ([0,-a,a])
covm_all=np.dot(org_data,model)
loading_all=covm_all
b_loading_all=(1.0loading_all)/sqrt(nch)
eeg = org_data
exp_var_tot=(b_loading_allb_loading_all)/np.var(eeg)
print (exp_var_tot)