def _private_vr_for_tag(ds: Optional["Dataset"], tag: BaseTag) -> str: """Return the VR for a known private tag, otherwise "UN". Parameters ---------- ds : Dataset, optional The dataset needed for the private creator lookup. If not given, "UN" is returned. tag : BaseTag The private tag to lookup. The caller has to ensure that the tag is private. Returns ------- str "LO" if the tag is a private creator, the VR of the private tag if found in the private dictionary, or "UN". """ if tag.is_private_creator: return VR_.LO # invalid private tags are handled as UN if ds is not None and (tag.element & 0xff00): private_creator_tag = tag.group << 16 | (tag.element >> 8) private_creator = ds.get(private_creator_tag, "") if private_creator: try: return private_dictionary_VR(tag, private_creator.value) except KeyError: pass return VR_.UN
def test_private_dict_VR(self): """Test private_dictionary_VR""" assert private_dictionary_VR(0x00090000, 'ACUSON') == 'IS'