@@ -47,11 +47,13 @@ def test_compcor(self):
47
47
['-0.1246655485' , '-0.1235705610' ]]
48
48
49
49
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 ),
51
52
expected_components )
52
53
53
54
self .run_cc (ACompCor (realigned_file = self .realigned_file ,
54
55
mask_files = self .mask_files ,
56
+ mask_index = 0 ,
55
57
components_file = 'acc_components_file' ),
56
58
expected_components , 'aCompCor' )
57
59
@@ -63,7 +65,8 @@ def test_tcompcor(self):
63
65
['0.4566907310' , '0.6983205193' ],
64
66
['-0.7132557407' , '0.1340170559' ],
65
67
['0.5022537643' , '-0.5098322262' ],
66
- ['-0.1342351356' , '0.1407855119' ]], 'tCompCor' )
68
+ ['-0.1342351356' , '0.1407855119' ]],
69
+ 'tCompCor' )
67
70
68
71
def test_tcompcor_no_percentile (self ):
69
72
ccinterface = TCompCor (realigned_file = self .realigned_file )
@@ -75,12 +78,14 @@ def test_tcompcor_no_percentile(self):
75
78
76
79
def test_compcor_no_regress_poly (self ):
77
80
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' ]])
84
89
85
90
def test_tcompcor_asymmetric_dim (self ):
86
91
asymmetric_shape = (2 , 3 , 4 , 5 )
@@ -96,7 +101,8 @@ def test_compcor_bad_input_shapes(self):
96
101
97
102
for data_shape in (shape_less_than , shape_more_than ):
98
103
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 ])
100
106
with pytest .raises (ValueError , message = "Dimension mismatch" ): interface .run ()
101
107
102
108
def test_tcompcor_bad_input_dim (self ):
@@ -124,6 +130,12 @@ def test_tcompcor_index_mask(self):
124
130
assert np .array_equal (nb .load ('mask_000.nii.gz' ).get_data (),
125
131
([[[0 ,0 ],[0 ,0 ]],[[0 ,1 ],[0 ,0 ]]]))
126
132
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
+
127
139
def run_cc (self , ccinterface , expected_components , expected_header = 'CompCor' ):
128
140
# run
129
141
ccresult = ccinterface .run ()
@@ -136,11 +148,13 @@ def run_cc(self, ccinterface, expected_components, expected_header='CompCor'):
136
148
assert ccinterface .inputs .num_components == 6
137
149
138
150
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 ])
140
153
141
154
components_data = [line .split ('\t ' ) for line in components_file ]
142
155
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 )
144
158
expected_header = [expected_header + '{:02d}' .format (i ) for i in
145
159
range (expected_n_components )]
146
160
for i , heading in enumerate (header ):
0 commit comments