1313
1414import argparse
1515from pathlib import Path
16- import sys
1716
1817from nibabel import __version__
19- from nibabel .loadsave import load
18+ from nibabel .loadsave import load , save
2019from nibabel .processing import conform
2120
2221
@@ -43,23 +42,18 @@ def _get_parser():
4342def main (args = None ):
4443 """Main program function."""
4544 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 )
5047
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 ))
5650
5751 out_img = conform (
5852 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 ,
6155 order = 3 ,
6256 cval = 0.0 ,
63- orientation = kwargs [ " orientation" ] )
57+ orientation = opts . orientation )
6458
65- nb . save (out_img , kwargs [ " outfile" ] )
59+ save (out_img , opts . outfile )
0 commit comments