def check_logic(args):
    """Some arguments/options are not compatible, or required jointly. This
    function checks them and may raise Exceptions if logic rules are failed."""
    if (args.bg or len(args.files) > 0) and (args.config or args.experiment):
        msg = 'Offline mode and XNAT options cannot be used simultaneously'
        raise Exception(msg)
    if (args.bg or len(args.files) > 0) and args.cache:
        msg = '--cache can be used in XNAT mode only.'
        raise Exception(msg)
    if args.config:
        if not args.experiment:
            msg = 'Missing option --experiment'
            raise Exception(msg)
    if args.experiment:
        if not args.config:
            msg = 'Missing option --config'
            raise Exception(msg)
    if args.nobg and args.opacity:
        msg = 'Warning. --nobg and --opacity used simultaneously.'
        raise Exception(msg)
    if args.opacity and not args.config:
        if not args.bg:
            msg = 'Missing option --bg'
            raise Exception(msg)
    if not args.config:
        if len(args.files) == 0 or len(args.files) > 3:
            msg = 'List of files must be of length 1, 2 or 3.'
            raise Exception(msg)
    if not args.opacity:
        args.opacity = 90
    if args.output.endswith('.gif') and (args.config and args.nobg or not
        args.config and not args.bg):
        msg = 'GIF animation can be created only providing a background image.'
        raise Exception(msg)
    if args.disable_warnings:
        import urllib3
        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
    import logging as log
    logger = log.getLogger()
    if args.verbose:
        logger.setLevel(level=log.DEBUG)
    else:
        logger.setLevel(level=log.INFO)
