Skip to content

Commit dfdd6b0

Browse files
author
Shoshana Berleant
committed
more intelligent testing
1 parent 4fd169a commit dfdd6b0

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

nipype/algorithms/compcor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,11 @@ def _run_interface(self, runtime):
6666
# "The constant and linear trends of the columns in the matrix M were removed ..."
6767
regress_poly(self.inputs.regress_poly_degree, voxel_timecourses)
6868

69-
'''
7069
timesteps = range(numvols)
7170
for voxel in range(numvoxels):
7271
m, b, _, _, _ = stats.linregress(timesteps, M[:, voxel])
7372
M[:, voxel] = M[:, voxel] - [m*t + b for t in timesteps]
74-
'''
73+
7574
# "... prior to column-wise variance normalization."
7675
M = M / self._compute_tSTD(M, 1.)
7776

nipype/algorithms/tests/test_compcor.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,31 @@ def test_compcor(self):
3030
mask[0,0,1] = 0
3131
mask_file = utils.save_toy_nii(mask, self.filenames['masknii'])
3232

33-
expected_sha1 = 'b0dd7f9ab7ba8f516712eb0204dacc9e397fc6aa'
33+
expected_components = [['-0.1989607212', '-0.5753813646'],
34+
['0.5692369697', '0.5674945949'],
35+
['-0.6662573243', '0.4675843432'],
36+
['0.4206466244', '-0.3361270124'],
37+
['-0.1246655485', '-0.1235705610']]
3438

3539
ccresult = self.run_cc(CompCor(realigned_file=self.realigned_file,
3640
mask_file=mask_file),
37-
expected_sha1)
41+
expected_components)
3842

3943
accresult = self.run_cc(ACompCor(realigned_file=self.realigned_file,
4044
mask_file=mask_file,
4145
components_file='acc_components_file'),
42-
expected_sha1)
46+
expected_components)
4347

4448
assert_equal(os.path.getsize(ccresult.outputs.components_file),
4549
os.path.getsize(accresult.outputs.components_file))
4650

4751
def test_tcompcor(self):
4852
ccinterface = TCompCor(realigned_file=self.realigned_file)
49-
self.run_cc(ccinterface, '12e54c07281a28ac0da3b934dce5c9d27626848a')
53+
self.run_cc(ccinterface, [['-0.2846272268'], ['0.7115680670'],
54+
['-0.6048328569'], ['0.2134704201'],
55+
['-0.0355784033']])
5056

51-
def run_cc(self, ccinterface, expected_components_data_sha1):
57+
def run_cc(self, ccinterface, expected_components):
5258
# run
5359
ccresult = ccinterface.run()
5460

@@ -60,12 +66,12 @@ def run_cc(self, ccinterface, expected_components_data_sha1):
6066
assert_equal(ccinterface.inputs.num_components, 6)
6167

6268
with open(ccresult.outputs.components_file, 'r') as components_file:
63-
components_data = [line for line in components_file]
69+
components_data = [line.split() for line in components_file]
6470
num_got_components = len(components_data)
6571
assert_true(num_got_components == ccinterface.inputs.num_components
6672
or num_got_components == self.fake_data.shape[3])
67-
print(str(components_data), "comdata")
68-
assert_equal(sha1(str(components_data)).hexdigest(), expected_components_data_sha1)
73+
first_two = [row[:2] for row in components_data]
74+
assert_equal(first_two, expected_components)
6975
return ccresult
7076

7177
def tearDown(self):

0 commit comments

Comments
 (0)