Exemple #1
0
def main(args=None):
    args = arg_parser().parse_args(args)
    if args.verbosity == 1:
        level = logging.getLevelName('INFO')
    elif args.verbosity >= 2:
        level = logging.getLevelName('DEBUG')
    else:
        level = logging.getLevelName('WARNING')
    logging.basicConfig(
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
        level=level)
    logger = logging.getLogger(__name__)
    try:
        if not os.path.isdir(args.img_dir):
            raise ValueError(
                '(-i / --img-dir) argument needs to be a directory of NIfTI images.'
            )
        if args.mask_dir is not None:
            if not os.path.isdir(args.mask_dir):
                raise ValueError(
                    '(-m / --mask-dir) argument needs to be a directory of NIfTI images.'
                )

        if args.n4_opts is None:
            n4_opts = None
        else:
            import json
            n4_opts = json.loads(args.n4_opts)
        preprocess(args.img_dir, args.out_dir, args.mask_dir, args.resolution,
                   args.orientation, n4_opts)
        return 0
    except Exception as e:
        logger.exception(e)
        return 1
def main(args=None):
    args = arg_parser().parse_args(args)
    if args.verbosity == 1:
        level = logging.getLevelName('INFO')
    elif args.verbosity >= 2:
        level = logging.getLevelName('DEBUG')
    else:
        level = logging.getLevelName('WARNING')
    logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=level)
    logger = logging.getLogger(__name__)
    try:
        if args.n4_opts is None:
            n4_opts = None
        else:
            import json
            n4_opts = json.loads(args.n4_opts)
        preprocess(args.img_dir, args.out_dir, args.mask_dir, args.resolution, args.orientation, n4_opts)
        return 0
    except Exception as e:
        logger.exception(e)
        return 1