Skip to content

Commit 4f79c18

Browse files
author
Shoshana Berleant
committed
make nilearn optional
1 parent 700ecce commit 4f79c18

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

nipype/algorithms/stats.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from builtins import str
1717

1818
import numpy as np
19-
import nilearn.input_data as nl
2019

2120
from .. import logging
2221
from ..interfaces.base import (traits, TraitedSpec, BaseInterface,
@@ -67,6 +66,8 @@ class SignalExtraction(BaseInterface):
6766
output_spec = SignalExtractionOutputSpec
6867

6968
def _run_interface(self, runtime):
69+
import nilearn.input_data as nl
70+
7071
ins = self.inputs
7172

7273
if ins.stat == 'mean': # always true for now

nipype/algorithms/tests/test_stats.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@
77

88
import numpy as np
99

10-
from ...testing import (assert_equal, utils, assert_almost_equal, raises)
10+
from ...testing import (assert_equal, utils, assert_almost_equal, raises,
11+
skipif)
1112
from .. import stats
1213

14+
no_nilearn = True
15+
try:
16+
import nilearn
17+
no_nilearn = False
18+
except ImportError:
19+
pass
20+
1321
class TestSignalExtraction(unittest.TestCase):
1422

1523
filenames = {
@@ -26,6 +34,7 @@ def setUp(self):
2634
utils.save_toy_nii(self.fake_fmri_data, self.filenames['in_file'])
2735
utils.save_toy_nii(self.fake_label_data, self.filenames['label_file'])
2836

37+
@skipif(no_nilearn)
2938
def test_signal_extraction(self):
3039
# setup
3140
wanted = [[-2.33333, 2, .5],
@@ -53,6 +62,7 @@ def test_signal_extraction(self):
5362
for j, segment in enumerate(time):
5463
assert_almost_equal(segment, wanted[i][j], decimal=1)
5564

65+
@skipif(no_nilearn)
5666
@raises(ValueError)
5767
def test_signal_extraction_bad_class_labels(self):
5868
# run

requirements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,3 @@ xvfbwrapper
1212
psutil
1313
funcsigs
1414
configparser
15-
nilearn
16-
sklearn

0 commit comments

Comments
 (0)