@@ -198,8 +198,8 @@ def _create_ev_files(
198198 # generate sections for conditions and other nuisance
199199 # regressors
200200 num_evs = [0 , 0 ]
201- for field in [ "cond" , "regress" ] :
202- for i , cond in enumerate ( runinfo [field ]) :
201+ for field in ( "cond" , "regress" ) :
202+ for cond in runinfo [field ]:
203203 name = cond ["name" ]
204204 evname .append (name )
205205 evfname = os .path .join (
@@ -278,9 +278,7 @@ def _create_ev_files(
278278 contrastmask_element = load_template ("feat_contrastmask_element.tcl" )
279279 # add t/f contrast info
280280 ev_txt += contrast_header .substitute ()
281- con_names = []
282- for j , con in enumerate (contrasts ):
283- con_names .append (con [0 ])
281+ con_names = [con [0 ] for con in contrasts ]
284282 con_map = {}
285283 ftest_idx = []
286284 ttest_idx = []
@@ -364,7 +362,7 @@ def _run_interface(self, runtime):
364362 n_tcon = 0
365363 n_fcon = 0
366364 if isdefined (self .inputs .contrasts ):
367- for i , c in enumerate ( self .inputs .contrasts ) :
365+ for c in self .inputs .contrasts :
368366 if c [1 ] == "T" :
369367 n_tcon += 1
370368 elif c [1 ] == "F" :
@@ -421,7 +419,7 @@ def _list_outputs(self):
421419 outputs ["ev_files" ].insert (runno , [])
422420 evname = []
423421 for field in ["cond" , "regress" ]:
424- for i , cond in enumerate ( runinfo [field ]) :
422+ for cond in runinfo [field ]:
425423 name = cond ["name" ]
426424 evname .append (name )
427425 evfname = os .path .join (
@@ -1388,8 +1386,7 @@ def _run_interface(self, runtime):
13881386 "" ,
13891387 "/Matrix" ,
13901388 ]
1391- for i in range (self .inputs .num_copes ):
1392- mat_txt += ["1" ]
1389+ mat_txt .extend ("1" for _ in range (self .inputs .num_copes ))
13931390 mat_txt = "\n " .join (mat_txt )
13941391
13951392 con_txt = [
@@ -1411,16 +1408,15 @@ def _run_interface(self, runtime):
14111408 "" ,
14121409 "/Matrix" ,
14131410 ]
1414- for i in range (self .inputs .num_copes ):
1415- grp_txt += ["1" ]
1411+ grp_txt .extend ("1" for _ in range (self .inputs .num_copes ))
14161412 grp_txt = "\n " .join (grp_txt )
14171413
14181414 txt = {"design.mat" : mat_txt , "design.con" : con_txt , "design.grp" : grp_txt }
14191415
14201416 # write design files
1421- for i , name in enumerate ([ "design.mat" , "design.con" , "design.grp" ] ):
1417+ for name , name_txt in txt . items ( ):
14221418 with open (os .path .join (cwd , name ), "w" ) as f :
1423- f .write (txt [ name ] )
1419+ f .write (name_txt )
14241420
14251421 return runtime
14261422
@@ -1559,7 +1555,7 @@ def _run_interface(self, runtime):
15591555 "" ,
15601556 "/Matrix" ,
15611557 ]
1562- for conidx , con in enumerate ( self .inputs .contrasts ) :
1558+ for con in self .inputs .contrasts :
15631559 if con [1 ] == "F" :
15641560 convals = np .zeros ((ntcons , 1 ))
15651561 for tcon in con [2 ]:
0 commit comments