13
13
14
14
import argparse
15
15
from pathlib import Path
16
- import sys
17
16
18
17
from nibabel import __version__
19
- from nibabel .loadsave import load
18
+ from nibabel .loadsave import load , save
20
19
from nibabel .processing import conform
21
20
22
21
@@ -43,23 +42,18 @@ def _get_parser():
43
42
def main (args = None ):
44
43
"""Main program function."""
45
44
parser = _get_parser ()
46
- if args is None :
47
- namespace = parser .parse_args (sys .argv [1 :])
48
- else :
49
- namespace = parser .parse_args (args )
45
+ opts = parser .parse_args (args )
46
+ from_img = load (opts .infile )
50
47
51
- kwargs = vars (namespace )
52
- from_img = load (kwargs ["infile" ])
53
-
54
- if not kwargs ["force" ] and Path (kwargs ["outfile" ]).exists ():
55
- raise FileExistsError ("Output file exists: {}" .format (kwargs ["outfile" ]))
48
+ if not opts .force and Path (opts .outfile ).exists ():
49
+ raise FileExistsError ("Output file exists: {}" .format (opts .outfile ))
56
50
57
51
out_img = conform (
58
52
from_img = from_img ,
59
- out_shape = kwargs [ " out_shape" ] ,
60
- voxel_size = kwargs [ " voxel_size" ] ,
53
+ out_shape = opts . out_shape ,
54
+ voxel_size = opts . voxel_size ,
61
55
order = 3 ,
62
56
cval = 0.0 ,
63
- orientation = kwargs [ " orientation" ] )
57
+ orientation = opts . orientation )
64
58
65
- nb . save (out_img , kwargs [ " outfile" ] )
59
+ save (out_img , opts . outfile )
0 commit comments