# pydicom.filewriter.correct_ambiguous_vr_element

pydicom.filewriter.correct_ambiguous_vr_element(elem: DataElement | RawDataElement, ds: Dataset, is_little_endian: bool, ancestors: list[Dataset] | None = None) → DataElement | RawDataElement

  Attempt to correct the ambiguous VR element elem.

  When it’s not possible to correct the VR, the element will be returned unchanged. Currently the only ambiguous VR elements not corrected for are all retired or part of DICONDE.

  If the VR is corrected and is ‘US’ or ‘SS’ then the value will be updated using the `convert_numbers()` function.

  Changed in version 3.0: The ancestors keyword argument was added.

  Parameters:

    - elem (dataelem.DataElement or dataelem.RawDataElement) – The element with an ambiguous VR.

    - ds (dataset.Dataset) – The dataset containing elem.

    - is_little_endian (bool) – The byte ordering of the values in the dataset.

    - ancestors (list[pydicom.dataset.Dataset] | None) – A list of the ancestor datasets to look through when trying to find the relevant element value to use in VR correction. Should be ordered from closest to furthest. If `None` then will build itself automatically starting at ds (default).

  Returns:

    The corrected element

  Return type:

    dataelem.DataElement or dataelem.RawDataElement