def count_nb_fov(recipe):
    """Count the number of different fields of view that can be defined from
    the recipe.

    Parameters
    ----------
    recipe : dict
        Map the images according to their field of view, their round,
        their channel and their spatial dimensions. Can only contain the keys
        'pattern', 'fov', 'r', 'c', 'z', 'ext' or 'opt'.

    Returns
    -------
    nb_fov : int
        Number of different fields of view in the recipe.

    """
    # check recipe is a dictionary
    if not isinstance(recipe, dict):
        raise Exception("The recipe is not valid. It should be a dictionary.")

    # check the fov key exists
    if "fov" not in recipe:
        return 1

    # case where fov is directly a string
    elif isinstance(recipe["fov"], str):
        return 1

    # case where fov is a list of strings
    elif isinstance(recipe["fov"], list):
        return len(recipe["fov"])

    # non valid cases
    else:
        raise ValueError("'fov' should be a List or a str, not {0}"
                         .format(type(recipe["fov"])))