Skip to content

Commit d5e1a0b

Browse files
author
Shoshana Berleant
committed
specify tab delimiter
1 parent 9239f7b commit d5e1a0b

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

nipype/algorithms/confounds.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,8 @@ def _run_interface(self, runtime):
363363
components_file = os.path.join(os.getcwd(), self.inputs.components_file)
364364

365365
self._set_header()
366-
np.savetxt(components_file, components, fmt=b"%.10f", header=self._make_headers(components.shape[1]))
366+
np.savetxt(components_file, components, fmt=b"%.10f", delimiter='\t',
367+
header=self._make_headers(components.shape[1]))
367368
return runtime
368369

369370
def _list_outputs(self):

nipype/algorithms/tests/test_compcor.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import nibabel as nb
99
import numpy as np
1010

11-
from ...testing import assert_equal, assert_true, utils
11+
from ...testing import assert_equal, assert_true, utils, assert_in
1212
from ..confounds import CompCor, TCompCor, ACompCor
1313

1414
class TestCompCor(unittest.TestCase):
@@ -39,7 +39,7 @@ def test_compcor(self):
3939
['-0.1246655485', '-0.1235705610']]
4040

4141
self.run_cc(CompCor(realigned_file=self.realigned_file, mask_file=self.mask_file),
42-
expected_components)
42+
expected_components)
4343

4444
self.run_cc(ACompCor(realigned_file=self.realigned_file, mask_file=self.mask_file,
4545
components_file='acc_components_file'),
@@ -105,10 +105,12 @@ def run_cc(self, ccinterface, expected_components, expected_header='CompCor'):
105105
with open(ccresult.outputs.components_file, 'r') as components_file:
106106
expected_n_components = min(ccinterface.inputs.num_components, self.fake_data.shape[3])
107107

108-
components_data = [line.split() for line in components_file]
108+
components_data = [line.split('\t') for line in components_file]
109109

110-
header = components_data.pop(0)[1:] # the first item will be '#', we can throw it out
111-
assert_equal(header, [expected_header + str(i) for i in range(expected_n_components)])
110+
header = components_data.pop(0) # the first item will be '#', we can throw it out
111+
expected_header = [expected_header + str(i) for i in range(expected_n_components)]
112+
for i, heading in enumerate(header):
113+
assert_in(expected_header[i], heading)
112114

113115
num_got_timepoints = len(components_data)
114116
assert_equal(num_got_timepoints, self.fake_data.shape[3])

0 commit comments

Comments
 (0)