Skip to content

Commit 974a42b

Browse files
author
Shoshana Berleant
committed
use abs paths; +appropriate way to test this
1 parent 8313923 commit 974a42b

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

nipype/interfaces/nilearn.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class SignalExtraction(BaseInterface):
7474
'''
7575
input_spec = SignalExtractionInputSpec
7676
output_spec = SignalExtractionOutputSpec
77+
_results = {}
7778

7879
def _run_interface(self, runtime):
7980
maskers = self._process_inputs()
@@ -86,7 +87,8 @@ def _run_interface(self, runtime):
8687
output = np.vstack((self.inputs.class_labels, region_signals.astype(str)))
8788

8889
# save output
89-
np.savetxt(os.path.abspath(self.inputs.out_file), output, fmt=b'%s', delimiter='\t')
90+
self._results['out_file'] = os.path.abspath(self.inputs.out_file)
91+
np.savetxt(self._results['out_file'], output, fmt=b'%s', delimiter='\t')
9092
return runtime
9193

9294
def _process_inputs(self):
@@ -137,6 +139,4 @@ def _4d(self, array, affine):
137139
return nb.Nifti1Image(array[:, :, :, np.newaxis], affine)
138140

139141
def _list_outputs(self):
140-
outputs = self._outputs().get()
141-
outputs['out_file'] = self.inputs.out_file
142-
return outputs
142+
return self._results

nipype/interfaces/tests/test_nilearn.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from ...testing import (assert_equal, utils, assert_almost_equal, raises,
1111
skipif)
1212
from .. import nilearn as iface
13+
from ...pipeline import engine as pe
1314

1415
no_nilearn = True
1516
try:
@@ -110,6 +111,22 @@ def test_signal_extr_shared(self):
110111
# run & assert
111112
self._test_4d_label(wanted, self.fake_4d_label_data)
112113

114+
@skipif(no_nilearn)
115+
def test_signal_extr_traits_valid(self):
116+
''' Test a node using the SignalExtraction interface.
117+
Unlike interface.run(), node.run() checks the traits
118+
'''
119+
# run
120+
node = pe.Node(iface.SignalExtraction(in_file=os.path.abspath(self.filenames['in_file']),
121+
label_files=os.path.abspath(self.filenames['label_files']),
122+
class_labels=self.labels,
123+
incl_shared_variance=False),
124+
name='SignalExtraction')
125+
node.run()
126+
127+
# assert
128+
# just checking that it passes trait validations
129+
113130
def _test_4d_label(self, wanted, fake_labels, include_global=False, incl_shared_variance=True):
114131
# set up
115132
utils.save_toy_nii(fake_labels, self.filenames['4d_label_file'])

0 commit comments

Comments
 (0)