@@ -330,7 +330,7 @@ class Dcm2niixInputSpec(CommandLineInputSpec):
330
330
False ,
331
331
argstr = '-t' ,
332
332
usedefault = True ,
333
- desc = "Flag if text notes include private patient details" )
333
+ desc = "Text notes including private patient details" )
334
334
compression = traits .Enum (
335
335
1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ,
336
336
argstr = '-%d' ,
@@ -348,6 +348,9 @@ class Dcm2niixInputSpec(CommandLineInputSpec):
348
348
philips_float = traits .Bool (
349
349
argstr = '-p' ,
350
350
desc = "Philips precise float (not display) scaling" )
351
+ to_nrrd = traits .Bool (
352
+ argstr = "-e" ,
353
+ desc = "Export as NRRD instead of NIfTI" )
351
354
352
355
353
356
class Dcm2niixOutputSpec (TraitedSpec ):
@@ -395,8 +398,11 @@ def version(self):
395
398
return Info .version ()
396
399
397
400
def _format_arg (self , opt , spec , val ):
398
- bools = ['bids_format' , 'merge_imgs' , 'single_file' , 'verbose' , 'crop' ,
399
- 'has_private' , 'anon_bids' , 'ignore_deriv' , 'philips_float' ]
401
+ bools = [
402
+ 'bids_format' , 'merge_imgs' , 'single_file' , 'verbose' , 'crop' ,
403
+ 'has_private' , 'anon_bids' , 'ignore_deriv' , 'philips_float' ,
404
+ 'to_nrrd' ,
405
+ ]
400
406
if opt in bools :
401
407
spec = deepcopy (spec )
402
408
if val :
@@ -425,17 +431,27 @@ def _parse_stdout(self, stdout):
425
431
426
432
def _parse_files (self , filenames ):
427
433
outfiles , bvals , bvecs , bids = [], [], [], []
428
- outtypes = (".nii" , ".nii.gz" , ".bval" , ".bvec" , ".json" )
434
+ outtypes = [".gz" , ".bval" , ".bvec" , ".json" , ".txt" ]
435
+ if self .to_nrrd :
436
+ outtypes += [".nrrd" , ".nhdr" ]
437
+ else :
438
+ outtypes += [".nii" ]
439
+
429
440
for filename in filenames :
430
441
# search for relevant files, and sort accordingly
431
442
for fl in search_files (filename , outtypes ):
432
- if fl .endswith (".nii" ) or fl .endswith (".gz" ):
443
+ if (
444
+ fl .endswith (".nii" ) or
445
+ fl .endswith (".gz" ) or
446
+ fl .endswith (".nrrd" ) or
447
+ fl .endswith (".nhdr" )
448
+ ):
433
449
outfiles .append (fl )
434
450
elif fl .endswith (".bval" ):
435
451
bvals .append (fl )
436
452
elif fl .endswith (".bvec" ):
437
453
bvecs .append (fl )
438
- elif fl .endswith (".json" ):
454
+ elif fl .endswith (".json" ) or fl . endswith ( ".txt" ) :
439
455
bids .append (fl )
440
456
self .output_files = outfiles
441
457
self .bvecs = bvecs
0 commit comments