def filename(config, key, ext = '.h5', num = None):
    """
    Get the real file name by looking up the key in the config and suffixing.

    :param config: configuration read from JSON
    :type config: dict
    :param key: key to use in the config
    :type key: str
    :return: filepath
    :rtype: str
    """

    filepath = config[key] + '_' + str(config['multiplier']) + '_' \
           + str(config['image_height']) + 'x' + str(config['image_width']) + '_' \
           + str(config['height']) + 'x' + str(config['width']) + 'x' + str(config['depth'])

    if num is not None:
        filepath += '_' + str(num)

    return filepath + config['suffix'] + ext