Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
"""Example radiology reports for training the structuring model. | |
This module contains curated examples of radiology reports with their | |
corresponding structured extractions. These examples are used for few-shot | |
learning with LangExtract to train the model on proper categorization of | |
report sections into prefix, body, and suffix components with appropriate | |
clinical significance labels. | |
The examples cover various imaging modalities including CT, MRI, and different | |
anatomical regions (spine, abdomen, brain, knee) to provide comprehensive | |
training coverage for the radiology report structuring task. | |
""" | |
import textwrap | |
from enum import Enum | |
import langextract as lx | |
class ReportSectionType(Enum): | |
PREFIX = "findings_prefix" | |
BODY = "findings_body" | |
SUFFIX = "findings_suffix" | |
def get_examples_for_model() -> list[lx.data.ExampleData]: | |
"""Examples that structure radiology reports into semantic sections. | |
Returns: | |
List of ExampleData objects containing radiology report examples | |
with their corresponding structured extractions for training | |
the language model. | |
""" | |
return [ | |
lx.data.ExampleData( | |
text=textwrap.dedent( | |
"""\ | |
EXAMINATION: CT ABDOMEN AND PELVIS WITH IV CONTRAST | |
CLINICAL INDICATION: Abdominal pain. | |
COMPARISON: None. | |
TECHNIQUE: Axial images of the abdomen and pelvis were obtained following the administration of intravenous contrast material. Coronal and sagittal reformations were reviewed. | |
FINDINGS: | |
No acute abnormality is seen in the visualized lung bases. The liver is normal in size and contour. There is a 1.2 cm simple-appearing low-attenuation lesion in hepatic segment VII, consistent with a cyst. The gallbladder contains numerous calcified gallstones, compatible with cholelithiasis. | |
IMPRESSION: | |
1. Cholelithiasis without evidence of acute cholecystitis. | |
2. Hepatic cyst. | |
""" | |
).rstrip(), | |
extractions=[ | |
lx.data.Extraction( | |
extraction_text="EXAMINATION: CT ABDOMEN AND PELVIS WITH IV CONTRAST", | |
extraction_class="findings_prefix", | |
attributes={ | |
"section": "Examination", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="CLINICAL INDICATION: Abdominal pain.", | |
extraction_class="findings_prefix", | |
attributes={ | |
"section": "Clinical Indication", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="COMPARISON: None.", | |
extraction_class="findings_prefix", | |
attributes={ | |
"section": "Comparison", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="TECHNIQUE: Axial images of the abdomen and pelvis were obtained following the administration of intravenous contrast material. Coronal and sagittal reformations were reviewed.", | |
extraction_class="findings_prefix", | |
attributes={ | |
"section": "Technique", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="No acute abnormality is seen in the visualized lung bases.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Lungs", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="The liver is normal in size and contour.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Liver", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="There is a 1.2 cm simple-appearing low-attenuation lesion in hepatic segment VII, consistent with a cyst.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Liver", | |
"clinical_significance": "minor", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="The gallbladder contains numerous calcified gallstones, compatible with cholelithiasis.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Gallbladder", | |
"clinical_significance": "minor", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="1. Cholelithiasis without evidence of acute cholecystitis.\n2. Hepatic cyst.", | |
extraction_class="findings_suffix", | |
attributes={}, | |
), | |
], | |
), | |
lx.data.ExampleData( | |
text=textwrap.dedent( | |
"""\ | |
CLINICAL HISTORY: | |
Low back pain, rule out disc herniation | |
MRI LUMBAR SPINE WITHOUT CONTRAST: | |
FINDINGS: | |
The lumbar lordosis is maintained. Vertebral body heights are preserved. | |
There is a small hemangioma in the L3 vertebral body. | |
The conus medullaris terminates at L1 and appears normal. | |
At L2-L3, there is mild disc desiccation without significant stenosis. | |
At L3-L4, a small posterior disc bulge causes mild central canal narrowing. | |
At L4-L5, there is a large posterior disc herniation with severe central canal stenosis and nerve root impingement. | |
At L5-S1, mild disc bulge without significant stenosis. | |
The paraspinal musculature appears unremarkable. | |
IMPRESSION: | |
Large L4-L5 disc herniation with severe stenosis. | |
""" | |
).rstrip(), | |
extractions=[ | |
lx.data.Extraction( | |
extraction_text="CLINICAL HISTORY:\nLow back pain, rule out disc herniation\n\nMRI LUMBAR SPINE WITHOUT CONTRAST:", | |
extraction_class="findings_prefix", | |
attributes={}, | |
), | |
lx.data.Extraction( | |
extraction_text="The lumbar lordosis is maintained. Vertebral body heights are preserved.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Lumbar Spine", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="There is a small hemangioma in the L3 vertebral body.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Bones", | |
"clinical_significance": "minor", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="The conus medullaris terminates at L1 and appears normal.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Spinal Cord", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="At L2-L3, there is mild disc desiccation without significant stenosis.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Lumbar Spine Levels: L2-L3", | |
"clinical_significance": "minor", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="At L3-L4, a small posterior disc bulge causes mild central canal narrowing.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Lumbar Spine Levels: L3-L4", | |
"clinical_significance": "minor", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="At L4-L5, there is a large posterior disc herniation with severe central canal stenosis and nerve root impingement.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Lumbar Spine Levels: L4-L5", | |
"clinical_significance": "significant", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="At L5-S1, mild disc bulge without significant stenosis.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Lumbar Spine Levels: L5-S1", | |
"clinical_significance": "minor", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="The paraspinal musculature appears unremarkable.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Paraspinal Soft Tissues", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="Large L4-L5 disc herniation with severe stenosis.", | |
extraction_class="findings_suffix", | |
attributes={}, | |
), | |
], | |
), | |
lx.data.ExampleData( | |
text=textwrap.dedent( | |
"""\ | |
INDICATION: | |
Neck pain, radiculopathy | |
MRI CERVICAL SPINE: | |
FINDINGS: | |
Normal cervical lordosis is maintained. No vertebral body compression fractures. | |
The cervical spinal cord demonstrates normal signal intensity. | |
At C3-C4, no significant disc disease or stenosis. | |
At C4-C5, mild disc osteophyte complex with mild foraminal narrowing. | |
At C5-C6, moderate disc herniation with moderate central canal stenosis. | |
At C6-C7, small disc bulge without significant stenosis. | |
IMPRESSION: | |
Moderate C5-C6 disc herniation and stenosis. | |
""" | |
).rstrip(), | |
extractions=[ | |
lx.data.Extraction( | |
extraction_text="INDICATION: \nNeck pain, radiculopathy\n\nMRI CERVICAL SPINE:", | |
extraction_class="findings_prefix", | |
attributes={}, | |
), | |
lx.data.Extraction( | |
extraction_text="Normal cervical lordosis is maintained. No vertebral body compression fractures.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Cervical Spine", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="The cervical spinal cord demonstrates normal signal intensity.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Spinal Cord", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="At C3-C4, no significant disc disease or stenosis.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Cervical Spine Levels: C3-C4", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="At C4-C5, mild disc osteophyte complex with mild foraminal narrowing.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Cervical Spine Levels: C4-C5", | |
"clinical_significance": "minor", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="At C5-C6, moderate disc herniation with moderate central canal stenosis.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Cervical Spine Levels: C5-C6", | |
"clinical_significance": "significant", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="At C6-C7, small disc bulge without significant stenosis.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Cervical Spine Levels: C6-C7", | |
"clinical_significance": "minor", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="Moderate C5-C6 disc herniation and stenosis.", | |
extraction_class="findings_suffix", | |
attributes={}, | |
), | |
], | |
), | |
lx.data.ExampleData( | |
text=textwrap.dedent( | |
"""\ | |
TECHNIQUE: | |
Multidetector helical CT from lung bases to adrenals with and without intravenous contrast. | |
FINDINGS: | |
LIVER/GALLBLADDER/SPLEEN: The liver has a normal appearance. Gallbladder wall appears normal. The spleen is normal in size. | |
PANCREAS/ADRENALS: The pancreas and bilateral adrenal glands appear unremarkable. | |
RETROPERITONEUM: No lymphadenopathy. No fluid collection. | |
IMPRESSION: | |
Normal abdominal CT. | |
""" | |
).rstrip(), | |
extractions=[ | |
lx.data.Extraction( | |
extraction_text="TECHNIQUE: \nMultidetector helical CT from lung bases to adrenals with and without intravenous contrast.", | |
extraction_class="findings_prefix", | |
attributes={}, | |
), | |
lx.data.Extraction( | |
extraction_text="The liver has a normal appearance.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Liver", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="Gallbladder wall appears normal.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Gallbladder", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="The spleen is normal in size.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Spleen", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="The pancreas and bilateral adrenal glands appear unremarkable.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Pancreas/Adrenals", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="No lymphadenopathy.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Retroperitoneum", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="No fluid collection.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Retroperitoneum", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="Normal abdominal CT.", | |
extraction_class="findings_suffix", | |
attributes={}, | |
), | |
], | |
), | |
lx.data.ExampleData( | |
text=textwrap.dedent( | |
"""\ | |
HISTORY: | |
Lower abdominal pain | |
CT ABDOMEN/PELVIS WITH CONTRAST: | |
FINDINGS: | |
LIVER: Multiple hepatic metastases are present, measuring up to 3.2 cm. | |
KIDNEYS: The left kidney shows moderate hydronephrosis. The right kidney appears normal. | |
LYMPH NODES: Enlarged retroperitoneal lymph nodes, largest measuring 2.1 cm. | |
IMPRESSION: | |
1. Multiple hepatic metastases | |
2. Left hydronephrosis | |
3. Retroperitoneal lymphadenopathy | |
""" | |
).rstrip(), | |
extractions=[ | |
lx.data.Extraction( | |
extraction_text="HISTORY: \nLower abdominal pain\n\nCT ABDOMEN/PELVIS WITH CONTRAST:", | |
extraction_class="findings_prefix", | |
attributes={}, | |
), | |
lx.data.Extraction( | |
extraction_text="Multiple hepatic metastases are present, measuring up to 3.2 cm.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Liver", | |
"clinical_significance": "significant", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="The left kidney shows moderate hydronephrosis.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Kidneys", | |
"clinical_significance": "significant", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="The right kidney appears normal.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Kidneys", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="Enlarged retroperitoneal lymph nodes, largest measuring 2.1 cm.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Lymph Nodes", | |
"clinical_significance": "significant", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="1. Multiple hepatic metastases\n2. Left hydronephrosis \n3. Retroperitoneal lymphadenopathy", | |
extraction_class="findings_suffix", | |
attributes={}, | |
), | |
], | |
), | |
lx.data.ExampleData( | |
text=textwrap.dedent( | |
"""\ | |
EXAMINATION: | |
MRI brain without contrast | |
CLINICAL HISTORY: | |
Headaches | |
FINDINGS: | |
The brain parenchyma demonstrates normal signal intensity. No mass lesions are identified. | |
The ventricular system is normal in size and configuration. | |
No abnormal enhancement is seen. | |
IMPRESSION: | |
Normal brain MRI. | |
""" | |
).rstrip(), | |
extractions=[ | |
lx.data.Extraction( | |
extraction_text="EXAMINATION:\nMRI brain without contrast\n\nCLINICAL HISTORY:\nHeadaches", | |
extraction_class="findings_prefix", | |
attributes={}, | |
), | |
lx.data.Extraction( | |
extraction_text="The brain parenchyma demonstrates normal signal intensity.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Brain Parenchyma", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="No mass lesions are identified.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Brain Parenchyma", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="The ventricular system is normal in size and configuration.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Ventricular System", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="No abnormal enhancement is seen.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Enhancement", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="Normal brain MRI.", | |
extraction_class="findings_suffix", | |
attributes={}, | |
), | |
], | |
), | |
lx.data.ExampleData( | |
text=textwrap.dedent( | |
"""\ | |
INDICATION: | |
Right knee pain | |
MRI RIGHT KNEE: | |
FINDINGS: | |
MENISCI: There is a complex tear of the medial meniscus. The lateral meniscus appears intact. | |
LIGAMENTS: The ACL shows complete rupture. The PCL, MCL, and LCL are intact. | |
BONES: Mild bone marrow edema is present in the medial femoral condyle. | |
IMPRESSION: | |
1. Complex medial meniscal tear | |
2. Complete ACL rupture | |
3. Bone marrow edema in medial femoral condyle | |
""" | |
).rstrip(), | |
extractions=[ | |
lx.data.Extraction( | |
extraction_text="INDICATION:\nRight knee pain\n\nMRI RIGHT KNEE:", | |
extraction_class="findings_prefix", | |
attributes={}, | |
), | |
lx.data.Extraction( | |
extraction_text="There is a complex tear of the medial meniscus.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Menisci", | |
"clinical_significance": "significant", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="The lateral meniscus appears intact.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Menisci", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="The ACL shows complete rupture.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Ligaments", | |
"clinical_significance": "significant", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="The PCL, MCL, and LCL are intact.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Ligaments", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="Mild bone marrow edema is present in the medial femoral condyle.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Bones", | |
"clinical_significance": "minor", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="1. Complex medial meniscal tear\n2. Complete ACL rupture\n3. Bone marrow edema in medial femoral condyle", | |
extraction_class="findings_suffix", | |
attributes={}, | |
), | |
], | |
), | |
lx.data.ExampleData( | |
text=textwrap.dedent( | |
"""\ | |
EXAMINATION: CT CHEST | |
FINDINGS: | |
The longs are clear bilaterally. The hart size is normal. No pleural effushion. | |
IMPRESSION: | |
Normal chest CT. | |
""" | |
).rstrip(), | |
extractions=[ | |
lx.data.Extraction( | |
extraction_text="EXAMINATION: CT CHEST", | |
extraction_class="findings_prefix", | |
attributes={ | |
"section": "Examination", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="The lungs are clear bilaterally.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Lungs", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="The heart size is normal.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Heart", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="No pleural effusion.", | |
extraction_class="findings_body", | |
attributes={ | |
"section": "Pleura", | |
"clinical_significance": "normal", | |
}, | |
), | |
lx.data.Extraction( | |
extraction_text="Normal chest CT.", | |
extraction_class="findings_suffix", | |
attributes={}, | |
), | |
], | |
), | |
] | |