Skip to content

Commit 41540d6

Browse files
Yannick Schwartzmatthew-brett
Yannick Schwartz
authored andcommitted
FMRILinearModel handles the case where contrasts are null for some fmri sessions
1 parent f332367 commit 41540d6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

nipy/modalities/fmri/glm.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
import numpy as np
3434

35+
from warnings import warn
36+
3537
import scipy.stats as sps
3638

3739
from nibabel import load, Nifti1Image
@@ -561,8 +563,11 @@ def contrast(self, contrasts, con_id='', contrast_type=None, output_z=True,
561563
'contrasts must be a sequence of %d session contrasts' %
562564
len(self.glms))
563565

566+
contrast_ = None
564567
for i, (glm, con) in enumerate(zip(self.glms, contrasts)):
565-
if i == 0:
568+
if np.all(con == 0):
569+
warn('Contrast for session %d is null' % i)
570+
elif not contrast_:
566571
contrast_ = glm.contrast(con, contrast_type)
567572
else:
568573
contrast_ = contrast_ + glm.contrast(con, contrast_type)

0 commit comments

Comments
 (0)