Exemplo n.º 1
0
def main():
    parser = _buildArgsParser()
    args = parser.parse_args()

    # Check if the files exist
    if not os.path.isfile(args.transformation):
        parser.error('"{0}" must be a file!'.format(args.transformation))

    if not os.path.isfile(args.ref_file):
        parser.error('"{0}" must be a file!'.format(args.ref_file))

    if not os.path.isfile(args.in_file):
        parser.error('"{0}" must be a file!'.format(args.in_file))

    if os.path.isfile(args.out_name) and not args.force_overwrite:
        parser.error('"{0}" already exists! Use -f to overwrite it.'.format(
            args.out_name))

    transfo = np.loadtxt(args.transformation)
    if args.inverse:
        transfo = np.linalg.inv(transfo)

    ref_name, ref_extension = split_name_with_nii(args.ref_file)
    in_name, in_extension = split_name_with_nii(args.in_file)

    if ref_extension not in ['.nii', '.nii.gz']:
        parser.error('"{0}" is in an unsupported format.'.format(
            args.ref_file))
    if in_extension not in ['.nii', '.nii.gz']:
        parser.error('"{0}" is in an unsupported format.'.format(args.in_file))

    transform_anatomy(transfo, args.ref_file, args.in_file, args.out_name)
Exemplo n.º 2
0
def main():
    parser = _build_args_parser()
    args = parser.parse_args()

    assert_inputs_exist(parser, [args.in_file, args.ref_file])
    assert_outputs_exist(parser, args, args.out_file)

    transform_anatomy(np.eye(4), args.ref_file, args.in_file,
                      args.out_file, interp=args.interpolation)
Exemplo n.º 3
0
def main():
    parser = _build_args_parser()
    args = parser.parse_args()

    assert_inputs_exist(parser,
                        [args.in_file, args.ref_file, args.transformation])
    assert_outputs_exists(parser, args, [args.out_name])

    transfo = np.loadtxt(args.transformation)
    if args.inverse:
        transfo = np.linalg.inv(transfo)

    _, ref_extension = split_name_with_nii(args.ref_file)
    _, in_extension = split_name_with_nii(args.in_file)
    if ref_extension not in ['.nii', '.nii.gz']:
        parser.error('{} is an unsupported format.'.format(args.in_file))
    if in_extension not in ['.nii', '.nii.gz']:
        parser.error('{} is an unsupported format.'.format(args.ref_file))

    transform_anatomy(transfo, args.ref_file, args.in_file, args.out_name)
def main():
    parser = _build_arg_parser()
    args = parser.parse_args()

    assert_inputs_exist(parser, [args.in_file, args.in_target_file,
                                 args.in_transfo])
    assert_outputs_exist(parser, args, args.out_name)

    transfo = load_matrix_in_any_format(args.in_transfo)
    if args.inverse:
        transfo = np.linalg.inv(transfo)

    _, ref_extension = split_name_with_nii(args.in_target_file)
    _, in_extension = split_name_with_nii(args.in_file)
    if ref_extension not in ['.nii', '.nii.gz']:
        parser.error('{} is an unsupported format.'.format(args.in_target_file))
    if in_extension not in ['.nii', '.nii.gz']:
        parser.error('{} is an unsupported format.'.format(args.in_file))

    transform_anatomy(transfo, args.in_target_file, args.in_file,
                      args.out_name, keep_dtype=args.keep_dtype)