lookup_dicom_tag
Find DICOM tag details including number, name, VR, VM, description, common values, and usage notes by entering group/element numbers or keywords like '0010,0010' or 'PatientName'.
Instructions
Look up any DICOM tag by group/element number or keyword. Returns tag number, name, VR, VM, description, common values, and usage notes. Accepts formats: '0010,0010', '(0010,0010)', 'PatientName', 'patient name'.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tag | Yes | DICOM tag number (e.g., '0010,0010') or keyword (e.g., 'PatientName', 'patient name'). |
Implementation Reference
- The `lookup_dicom_tag` function implementation, which takes a tag string (number or keyword), parses it, and returns a formatted description of the DICOM tag.
def lookup_dicom_tag(tag: str) -> str: """Look up a DICOM tag by group/element number or keyword. Args: tag: Tag identifier. Accepts: - Tag number: "0010,0010", "(0010,0010)", "00100010" - Keyword: "PatientName", "patient name", "Patient's Name" Returns: Formatted string with tag information. """ # Try parsing as a numeric tag parsed = _parse_tag_input(tag) if parsed is not None: info = DICOM_TAGS.get(parsed) if info: return _format_tag_result(parsed, info) # Check if it's in a private tag range group, element = parsed if group % 2 == 1: # Odd group = private return _format_private_tag_info(group, element) return ( f"Tag {format_dicom_tag(*parsed)} not found in the dictionary.\n\n" f"This could be:\n" f"- A less common standard tag not in our database\n" f"- A private tag (odd group numbers are private)\n" f"- An incorrect tag number\n\n" f"Try searching by keyword instead, or check the DICOM PS3.6 Data Dictionary." ) # Try keyword search results = _find_by_keyword(tag) if not results: return ( f"No DICOM tags found matching '{tag}'.\n\n" f"Tips:\n" f"- Try a different keyword (e.g., 'patient' instead of 'pt')\n" f"- Use the tag number format: '0010,0010'\n" f"- Keywords are searched case-insensitively" ) if len(results) == 1: return _format_tag_result(results[0][0], results[0][1]) # Multiple results output_parts = [f"Found {len(results)} tags matching '{tag}':\n"] for tag_key, tag_info in results[:15]: # Limit to 15 results retired = " [RETIRED]" if tag_info.get("retired") else "" output_parts.append( f" {format_dicom_tag(*tag_key)} {tag_info['keyword']} " f"VR: {tag_info['vr']} — {tag_info['name']}{retired}" ) if len(results) > 15: output_parts.append(f"\n ... and {len(results) - 15} more. Try a more specific keyword.") return "\n".join(output_parts)