@@ -47,11 +47,13 @@ def test_compcor(self):
4747 ['-0.1246655485' , '-0.1235705610' ]]
4848
4949 self .run_cc (CompCor (realigned_file = self .realigned_file ,
50- mask_files = self .mask_files ),
50+ mask_files = self .mask_files ,
51+ mask_index = 0 ),
5152 expected_components )
5253
5354 self .run_cc (ACompCor (realigned_file = self .realigned_file ,
5455 mask_files = self .mask_files ,
56+ mask_index = 0 ,
5557 components_file = 'acc_components_file' ),
5658 expected_components , 'aCompCor' )
5759
@@ -63,7 +65,8 @@ def test_tcompcor(self):
6365 ['0.4566907310' , '0.6983205193' ],
6466 ['-0.7132557407' , '0.1340170559' ],
6567 ['0.5022537643' , '-0.5098322262' ],
66- ['-0.1342351356' , '0.1407855119' ]], 'tCompCor' )
68+ ['-0.1342351356' , '0.1407855119' ]],
69+ 'tCompCor' )
6770
6871 def test_tcompcor_no_percentile (self ):
6972 ccinterface = TCompCor (realigned_file = self .realigned_file )
@@ -75,12 +78,14 @@ def test_tcompcor_no_percentile(self):
7578
7679 def test_compcor_no_regress_poly (self ):
7780 self .run_cc (CompCor (realigned_file = self .realigned_file ,
78- mask_files = self .mask_files ,
79- use_regress_poly = False ), [['0.4451946442' , '-0.7683311482' ],
80- ['-0.4285129505' , '-0.0926034137' ],
81- ['0.5721540256' , '0.5608764842' ],
82- ['-0.5367548139' , '0.0059943226' ],
83- ['-0.0520809054' , '0.2940637551' ]])
81+ mask_files = self .mask_files ,
82+ mask_index = 0 ,
83+ use_regress_poly = False ),
84+ [['0.4451946442' , '-0.7683311482' ],
85+ ['-0.4285129505' , '-0.0926034137' ],
86+ ['0.5721540256' , '0.5608764842' ],
87+ ['-0.5367548139' , '0.0059943226' ],
88+ ['-0.0520809054' , '0.2940637551' ]])
8489
8590 def test_tcompcor_asymmetric_dim (self ):
8691 asymmetric_shape = (2 , 3 , 4 , 5 )
@@ -96,7 +101,8 @@ def test_compcor_bad_input_shapes(self):
96101
97102 for data_shape in (shape_less_than , shape_more_than ):
98103 data_file = utils .save_toy_nii (np .zeros (data_shape ), 'temp.nii' )
99- interface = CompCor (realigned_file = data_file , mask_files = self .mask_files )
104+ interface = CompCor (realigned_file = data_file ,
105+ mask_files = self .mask_files [0 ])
100106 with pytest .raises (ValueError , message = "Dimension mismatch" ): interface .run ()
101107
102108 def test_tcompcor_bad_input_dim (self ):
@@ -124,6 +130,12 @@ def test_tcompcor_index_mask(self):
124130 assert np .array_equal (nb .load ('mask_000.nii.gz' ).get_data (),
125131 ([[[0 ,0 ],[0 ,0 ]],[[0 ,1 ],[0 ,0 ]]]))
126132
133+ def test_tcompcor_multi_mask_no_index (self ):
134+ interface = TCompCor (realigned_file = self .realigned_file ,
135+ mask_files = self .mask_files )
136+ with pytest .raises (ValueError , message = 'more than one mask file' ):
137+ interface .run ()
138+
127139 def run_cc (self , ccinterface , expected_components , expected_header = 'CompCor' ):
128140 # run
129141 ccresult = ccinterface .run ()
@@ -136,11 +148,13 @@ def run_cc(self, ccinterface, expected_components, expected_header='CompCor'):
136148 assert ccinterface .inputs .num_components == 6
137149
138150 with open (ccresult .outputs .components_file , 'r' ) as components_file :
139- expected_n_components = min (ccinterface .inputs .num_components , self .fake_data .shape [3 ])
151+ expected_n_components = min (ccinterface .inputs .num_components ,
152+ self .fake_data .shape [3 ])
140153
141154 components_data = [line .split ('\t ' ) for line in components_file ]
142155
143- header = components_data .pop (0 ) # the first item will be '#', we can throw it out
156+ # the first item will be '#', we can throw it out
157+ header = components_data .pop (0 )
144158 expected_header = [expected_header + '{:02d}' .format (i ) for i in
145159 range (expected_n_components )]
146160 for i , heading in enumerate (header ):
0 commit comments