Skip to content

Commit 3e2049f

Browse files
committed
fix: matplotlib import to inside function
1 parent e310282 commit 3e2049f

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

nipype/interfaces/nipy/model.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
import nibabel as nb
55
import numpy as np
66

7-
pylab_available = True
8-
try:
9-
import pylab
10-
except:
11-
pylab_available = False
127

138
from ...utils.misc import package_check
149

@@ -140,13 +135,11 @@ def _run_interface(self, runtime):
140135
design_matrix[:,i] = (design_matrix[:,i]-design_matrix[:,i].mean())/design_matrix[:,i].std()
141136

142137
if self.inputs.plot_design_matrix:
143-
if pylab_available:
144-
pylab.pcolor(design_matrix)
145-
pylab.savefig("design_matrix.pdf")
146-
pylab.close()
147-
pylab.clf()
148-
else:
149-
Exception('Pylab not available for saving design matrix image')
138+
import pylab
139+
pylab.pcolor(design_matrix)
140+
pylab.savefig("design_matrix.pdf")
141+
pylab.close()
142+
pylab.clf()
150143

151144
glm = GLM.glm()
152145
glm.fit(timeseries.T, design_matrix, method=self.inputs.method, model=self.inputs.model)

0 commit comments

Comments
 (0)