Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update parameters.py #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

reinoudmaex
Copy link

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_all
b_loading_all)/np.var(eeg)

print (exp_var_tot)

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.0*loading_all)/sqrt(nch)
eeg = org_data
exp_var_tot=(b_loading_all*b_loading_all)/np.var(eeg)

print (exp_var_tot)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant