Skip to content

Commit 6e19298

Browse files
committed
clean up code
1 parent 527400d commit 6e19298

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

nibabel/cmdline/conform.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313

1414
import argparse
1515
from pathlib import Path
16-
import sys
1716

1817
from nibabel import __version__
19-
from nibabel.loadsave import load
18+
from nibabel.loadsave import load, save
2019
from nibabel.processing import conform
2120

2221

@@ -43,23 +42,18 @@ def _get_parser():
4342
def 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

Comments
 (0)