@@ -412,28 +412,35 @@ def _run_interface(self, runtime):
412
412
# may use return code 1 despite conversion
413
413
runtime = super (Dcm2niix , self )._run_interface (
414
414
runtime , correct_return_codes = (0 , 1 , ))
415
- (self .output_files , self .bvecs ,
416
- self .bvals , self .bids ) = self ._parse_stdout (runtime .stdout )
415
+ self ._parse_files (self ._parse_stdout (runtime .stdout ))
417
416
return runtime
418
417
419
418
def _parse_stdout (self , stdout ):
420
- outfiles , bvals , bvecs , bids = [], [], [], []
419
+ filenames = []
421
420
for line in stdout .split ("\n " ):
422
421
if line .startswith ("Convert " ): # output
423
422
fname = str (re .search ('\S+/\S+' , line ).group (0 ))
424
- fname = os .path .abspath (fname )
425
- outtypes = (".nii" , ".nii.gz" , ".bval" , ".bvec" , ".json" )
426
- # search for relevant files, and sort accordingly
427
- for fl in search_files (fname , outtypes ):
428
- if fl .endswith (".nii" ) or fl .endswith (".gz" ):
429
- outfiles .append (fl )
430
- elif fl .endswith (".bval" ):
431
- bvals .append (fl )
432
- elif fl .endswith (".bvec" ):
433
- bvecs .append (fl )
434
- elif fl .endswith (".json" ):
435
- bids .append (fl )
436
- return outfiles , bvecs , bvals , bids
423
+ filenames .append (os .path .abspath (fname ))
424
+ return filenames
425
+
426
+ def _parse_files (self , filenames ):
427
+ outfiles , bvals , bvecs , bids = [], [], [], []
428
+ outtypes = (".nii" , ".nii.gz" , ".bval" , ".bvec" , ".json" )
429
+ for filename in filenames :
430
+ # search for relevant files, and sort accordingly
431
+ for fl in search_files (filename , outtypes ):
432
+ if fl .endswith (".nii" ) or fl .endswith (".gz" ):
433
+ outfiles .append (fl )
434
+ elif fl .endswith (".bval" ):
435
+ bvals .append (fl )
436
+ elif fl .endswith (".bvec" ):
437
+ bvecs .append (fl )
438
+ elif fl .endswith (".json" ):
439
+ bids .append (fl )
440
+ self .output_files = outfiles
441
+ self .bvecs = bvecs
442
+ self .bvals = bvals
443
+ self .bids = bids
437
444
438
445
def _list_outputs (self ):
439
446
outputs = self .output_spec ().get ()
0 commit comments