@@ -353,7 +353,7 @@ def _assign_dicom_time(ti):
353
353
return outtar
354
354
355
355
356
- def embed_nifti (dcmfiles , niftifile , infofile , bids_info , force , min_meta ):
356
+ def embed_nifti (dcmfiles , niftifile , infofile , bids_info , min_meta ):
357
357
"""
358
358
359
359
If `niftifile` doesn't exist, it gets created out of the `dcmfiles` stack,
@@ -370,7 +370,6 @@ def embed_nifti(dcmfiles, niftifile, infofile, bids_info, force, min_meta):
370
370
niftifile
371
371
infofile
372
372
bids_info
373
- force
374
373
min_meta
375
374
376
375
Returns
@@ -387,10 +386,11 @@ def embed_nifti(dcmfiles, niftifile, infofile, bids_info, force, min_meta):
387
386
388
387
if not min_meta :
389
388
import dcmstack as ds
390
- stack = ds .parse_and_stack (dcmfiles , force = force ).values ()
389
+ stack = ds .parse_and_stack (dcmfiles , force = True ).values ()
391
390
if len (stack ) > 1 :
392
391
raise ValueError ('Found multiple series' )
393
- stack = stack [0 ]
392
+ # may be odict now - iter to be safe
393
+ stack = next (iter (stack ))
394
394
395
395
#Create the nifti image using the data array
396
396
if not op .exists (niftifile ):
@@ -458,21 +458,18 @@ def embed_metadata_from_dicoms(bids, item_dicoms, outname, outname_bids,
458
458
item_dicoms = list (map (op .abspath , item_dicoms ))
459
459
460
460
embedfunc = Node (Function (input_names = ['dcmfiles' , 'niftifile' , 'infofile' ,
461
- 'bids_info' , 'force' , ' min_meta' ],
461
+ 'bids_info' , 'min_meta' ],
462
462
output_names = ['outfile' , 'meta' ],
463
463
function = embed_nifti ),
464
464
name = 'embedder' )
465
465
embedfunc .inputs .dcmfiles = item_dicoms
466
466
embedfunc .inputs .niftifile = op .abspath (outname )
467
467
embedfunc .inputs .infofile = op .abspath (scaninfo )
468
468
embedfunc .inputs .min_meta = min_meta
469
- if bids :
470
- embedfunc .inputs .bids_info = load_json (op .abspath (outname_bids ))
471
- else :
472
- embedfunc .inputs .bids_info = None
473
- embedfunc .inputs .force = True
469
+ embedfunc .inputs .bids_info = load_json (op .abspath (outname_bids )) if bids else None
474
470
embedfunc .base_dir = tmpdir
475
471
cwd = os .getcwd ()
472
+
476
473
lgr .debug ("Embedding into %s based on dicoms[0]=%s for nifti %s" ,
477
474
scaninfo , item_dicoms [0 ], outname )
478
475
try :
0 commit comments