1#!/usr/bin/env python
2
3"""
4Split image sequence into individual volumes.
5"""
6
7import mirtk
8import argparse
9
10
11if __name__ == '__main__':
12    parser = argparse.ArgumentParser(description=__doc__)
13    parser.add_argument('input', help="Input sequence.")
14    parser.add_argument('output', help="Output file path.")
15    parser.add_argument('-t', type=int, default=0, help="Index of volume to extract.")
16    parser.add_argument('-n', type=int, default=0,
17                        help="Number of volumes to extract. Extract all from -t to maximum index when non-positive.")
18    args = parser.parse_args()
19    opts = {"Rt1": args.t}
20    if args.n > 0:
21        opts["Rt2"] = args.t + args.n - 1
22    mirtk.extract_image_region(args.input, args.output, split='t', **opts)
23