@@ -27,31 +27,38 @@ def setUp(self):
27
27
noise = np .fromfunction (self .fake_noise_fun , self .fake_data .shape )
28
28
self .realigned_file = utils .save_toy_nii (self .fake_data + noise ,
29
29
self .filenames ['functionalnii' ])
30
-
31
- def test_compcor (self ):
32
30
mask = np .ones (self .fake_data .shape [:3 ])
33
31
mask [0 ,0 ,0 ] = 0
34
32
mask [0 ,0 ,1 ] = 0
35
- mask_file = utils .save_toy_nii (mask , self .filenames ['masknii' ])
33
+ self . mask_file = utils .save_toy_nii (mask , self .filenames ['masknii' ])
36
34
35
+ def test_compcor (self ):
37
36
expected_components = [['-0.1989607212' , '-0.5753813646' ],
38
37
['0.5692369697' , '0.5674945949' ],
39
38
['-0.6662573243' , '0.4675843432' ],
40
39
['0.4206466244' , '-0.3361270124' ],
41
40
['-0.1246655485' , '-0.1235705610' ]]
42
41
43
42
ccresult = self .run_cc (CompCor (realigned_file = self .realigned_file ,
44
- mask_file = mask_file ),
43
+ mask_file = self . mask_file ),
45
44
expected_components )
46
45
47
46
accresult = self .run_cc (ACompCor (realigned_file = self .realigned_file ,
48
- mask_file = mask_file ,
47
+ mask_file = self . mask_file ,
49
48
components_file = 'acc_components_file' ),
50
49
expected_components )
51
50
52
51
assert_equal (os .path .getsize (ccresult .outputs .components_file ),
53
52
os .path .getsize (accresult .outputs .components_file ))
54
53
54
+ @mock .patch ('nipype.algorithms.compcor.CompCor._add_extras' )
55
+ def test_compcor_with_extra_regressors (self , mock_add_extras ):
56
+ regressors_file = 'regress.txt'
57
+ open (regressors_file , 'a' ).close () # make sure file exists
58
+ CompCor (realigned_file = self .realigned_file , mask_file = self .mask_file ,
59
+ extra_regressors = regressors_file ).run ()
60
+ assert_true (mock_add_extras .called )
61
+
55
62
def test_tcompcor (self ):
56
63
ccinterface = TCompCor (realigned_file = self .realigned_file )
57
64
self .run_cc (ccinterface , [['-0.2846272268' ], ['0.7115680670' ],
0 commit comments