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

spm_Gpdf function attempts to calculate log of zero #11

Open
TYH0517 opened this issue Apr 8, 2022 · 0 comments
Open

spm_Gpdf function attempts to calculate log of zero #11

TYH0517 opened this issue Apr 8, 2022 · 0 comments

Comments

@TYH0517
Copy link

TYH0517 commented Apr 8, 2022

When running neurodesign, the process fails with the following error:

C:\Users\User\anaconda3\lib\site-packages\neurodesign\neurodesign.py:561: RuntimeWarning: divide by zero encountered in log
  s = np.array(s)

This corresponds to the spm_Gpdf function. In this, the line

res = (h - 1) * np.log(s) + h * np.log(l) - l * s - np.log(gamma(h))

appears to be trying to calculate the log of zero as the first value of the variable s is 0. s is generated in the canonical function from the line

s = np.array(range(int(np.ceil(p[6] / dt)))).

It is not clear why this behaviour occurs since it doesn't appear to be a problem for anyone else. I've altered the code slightly to make it compatible with python3, but there isn't an obvious link between those changes and this behaviour.

The input used was:

    TR = 2.0, 
     n_trials = 200, 
     P = [0.5, 0.5], 
     C = [[1.0, 0.0], [0.0, 1.0], [-0.5, 0.5], [0.5, -0.5], [1.0, 0.0], [0.0, 1.0], [0.5, -0.5]], 
     duration = None, 
     n_stimuli = 2, 
     rho = 0.3,  
     stim_duration = 2.0, 
     restnum = 40, 
     restdur = 20.0, 
     ITImodel = 'uniform', 
     ITImin = 2.0, 
     ITImean = 3.0, 
     ITImax = 4.0, 
     confoundorder = 10, 
     maxrep = 10, 
     hardprob = False, 
     t_pre = 1.0, 
     t_post = 1.0, 
)```

These values were obtained through the neurodesign web tool.

Any clues to what might be the problem would be appreciated!
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

No branches or pull requests

1 participant