1
+ """The dcm2nii module provides basic functions for dicom conversion
2
+
3
+ Change directory to provide relative paths for doctests
4
+ >>> import os
5
+ >>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
6
+ >>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
7
+ >>> os.chdir(datadir)
8
+ """
9
+
1
10
from nipype .interfaces .base import (CommandLine , CommandLineInputSpec ,
2
11
InputMultiPath , traits , TraitedSpec ,
3
12
OutputMultiPath , isdefined ,
8
17
import re
9
18
10
19
class Dcm2niiInputSpec (CommandLineInputSpec ):
11
- source_names = InputMultiPath (File (exists = True ), argstr = "%s" , position = 10 , mandatory = True )
20
+ source_names = InputMultiPath (File (exists = True ), argstr = "%s" , position = 10 ,
21
+ copyfile = False , mandatory = True )
12
22
gzip_output = traits .Bool (False , argstr = '-g' , position = 0 , usedefault = True )
13
23
nii_output = traits .Bool (True , argstr = '-n' , position = 1 , usedefault = True )
14
24
anonymize = traits .Bool (argstr = '-a' , position = 2 )
@@ -18,7 +28,8 @@ class Dcm2niiInputSpec(CommandLineInputSpec):
18
28
output_dir = Directory (exists = True , argstr = '-o %s' , genfile = True , position = 6 )
19
29
config_file = File (exists = True , argstr = "-b %s" , genfile = True , position = 7 )
20
30
convert_all_pars = traits .Bool (argstr = '-v' , position = 8 )
21
- args = traits .Str (argstr = '%s' , desc = 'Additional parameters to the command' , position = 9 )
31
+ args = traits .Str (argstr = '%s' , desc = 'Additional parameters to the command' ,
32
+ position = 9 )
22
33
23
34
class Dcm2niiOutputSpec (TraitedSpec ):
24
35
converted_files = OutputMultiPath (File (exists = True ))
@@ -28,6 +39,21 @@ class Dcm2niiOutputSpec(TraitedSpec):
28
39
bvals = OutputMultiPath (File (exists = True ))
29
40
30
41
class Dcm2nii (CommandLine ):
42
+ """Uses MRICRON's dcm2nii to convert dicom files
43
+
44
+ Examples
45
+ ========
46
+
47
+ >>> from nipype.interfaces.dcm2nii import Dcm2nii
48
+ >>> converter = Dcm2nii()
49
+ >>> converter.inputs.source_names = ['functional_1.dcm', 'functional_2.dcm']
50
+ >>> converter.inputs.gzip_output = True
51
+ >>> converter.inputs.output_dir = '.'
52
+ >>> converter.cmdline #doctest: +ELLIPSIS
53
+ 'dcm2nii -g y -n y -i n -o . -b config.ini functional_1.dcm functional_2.dcm'
54
+ >>> converter.run() # doctest: +SKIP
55
+ """
56
+
31
57
input_spec = Dcm2niiInputSpec
32
58
output_spec = Dcm2niiOutputSpec
33
59
0 commit comments