Skip to content

Tag Exists

imgtools.dicom.tag_exists cached

tag_exists(keyword: str) -> bool

Boolean check if a DICOM tag exists for a given keyword.

Parameters:

Name Type Description Default

keyword

str

The DICOM keyword to check.

required

Returns:

Type Description
bool

True if the tag exists, False otherwise.

Examples:

>>> tag_exists("PatientID")
True
>>> tag_exists("InvalidKeyword")
False
Source code in src/imgtools/dicom/utils.py
@functools.lru_cache(maxsize=1024)
def tag_exists(keyword: str) -> bool:
    """Boolean check if a DICOM tag exists for a given keyword.

    Parameters
    ----------
    keyword : str
        The DICOM keyword to check.

    Returns
    -------
    bool
        True if the tag exists, False otherwise.

    Examples
    --------

    >>> tag_exists("PatientID")
    True

    >>> tag_exists("InvalidKeyword")
    False
    """
    return dictionary_has_tag(keyword)