Skip to content

Commit 450f1d1

Browse files
committed
Merge pull request #1235 from effigies/suppress_dbz
ENH: Suppress division by zero warning in spm_hrf
2 parents 5e381b4 + a450560 commit 450f1d1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

nipype/algorithms/modelgen.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ def spm_hrf(RT, P=None, fMRI_T=16):
9696
# modelled hemodynamic response function - {mixture of Gammas}
9797
dt = RT / float(fMRI_T)
9898
u = np.arange(0, int(p[6] / dt + 1)) - p[5] / dt
99-
hrf = _spm_Gpdf(u, p[0] / p[2], dt / p[2]) - _spm_Gpdf(u, p[1] / p[3],
100-
dt / p[3]) / p[4]
99+
with np.errstate(divide='ignore'): # Known division-by-zero
100+
hrf = _spm_Gpdf(u, p[0] / p[2], dt / p[2]) - _spm_Gpdf(u, p[1] / p[3],
101+
dt / p[3]) / p[4]
101102
idx = np.arange(0, int((p[6] / RT) + 1)) * fMRI_T
102103
hrf = hrf[idx]
103104
hrf = hrf / np.sum(hrf)

0 commit comments

Comments
 (0)