@@ -198,8 +198,8 @@ def _create_ev_files(
198
198
# generate sections for conditions and other nuisance
199
199
# regressors
200
200
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 ]:
203
203
name = cond ["name" ]
204
204
evname .append (name )
205
205
evfname = os .path .join (
@@ -278,9 +278,7 @@ def _create_ev_files(
278
278
contrastmask_element = load_template ("feat_contrastmask_element.tcl" )
279
279
# add t/f contrast info
280
280
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 ]
284
282
con_map = {}
285
283
ftest_idx = []
286
284
ttest_idx = []
@@ -364,7 +362,7 @@ def _run_interface(self, runtime):
364
362
n_tcon = 0
365
363
n_fcon = 0
366
364
if isdefined (self .inputs .contrasts ):
367
- for i , c in enumerate ( self .inputs .contrasts ) :
365
+ for c in self .inputs .contrasts :
368
366
if c [1 ] == "T" :
369
367
n_tcon += 1
370
368
elif c [1 ] == "F" :
@@ -421,7 +419,7 @@ def _list_outputs(self):
421
419
outputs ["ev_files" ].insert (runno , [])
422
420
evname = []
423
421
for field in ["cond" , "regress" ]:
424
- for i , cond in enumerate ( runinfo [field ]) :
422
+ for cond in runinfo [field ]:
425
423
name = cond ["name" ]
426
424
evname .append (name )
427
425
evfname = os .path .join (
@@ -1388,8 +1386,7 @@ def _run_interface(self, runtime):
1388
1386
"" ,
1389
1387
"/Matrix" ,
1390
1388
]
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 ))
1393
1390
mat_txt = "\n " .join (mat_txt )
1394
1391
1395
1392
con_txt = [
@@ -1411,16 +1408,15 @@ def _run_interface(self, runtime):
1411
1408
"" ,
1412
1409
"/Matrix" ,
1413
1410
]
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 ))
1416
1412
grp_txt = "\n " .join (grp_txt )
1417
1413
1418
1414
txt = {"design.mat" : mat_txt , "design.con" : con_txt , "design.grp" : grp_txt }
1419
1415
1420
1416
# write design files
1421
- for i , name in enumerate ([ "design.mat" , "design.con" , "design.grp" ] ):
1417
+ for name , name_txt in txt . items ( ):
1422
1418
with open (os .path .join (cwd , name ), "w" ) as f :
1423
- f .write (txt [ name ] )
1419
+ f .write (name_txt )
1424
1420
1425
1421
return runtime
1426
1422
@@ -1559,7 +1555,7 @@ def _run_interface(self, runtime):
1559
1555
"" ,
1560
1556
"/Matrix" ,
1561
1557
]
1562
- for conidx , con in enumerate ( self .inputs .contrasts ) :
1558
+ for con in self .inputs .contrasts :
1563
1559
if con [1 ] == "F" :
1564
1560
convals = np .zeros ((ntcons , 1 ))
1565
1561
for tcon in con [2 ]:
0 commit comments