RadReportParser

Lifecycle: experimental codecov

Parse and extract key sections from radiology reports text

radreportparser is a Python package that helps you extract structured information from free-text radiology reports using regular expressions.

This package is in early development phase and subject to change.

Features

  • 📋 Extract common radiology report sections 1
    • Included: Title, History, Technique, Comparison, Findings, and Impression
  • 🔍 Flexible pattern matching with customizable section markers
  • 🔄 Convert extracted sections to Python dictionaries or JSON

Installation

Install the development version from GitHub:

python -m pip install git+https://github.com/Lightbridge-KS/radreportparser

Quick Start

Extract Report

Here’s a simple example of extracting sections from a radiology report:

from radreportparser import RadReportExtractor

# Sample brain CT report (note the markdown formatting)
report_text = """
EMERGENCY MDCT OF THE BRAIN

**HISTORY:** A 25-year-old female presents with headache. Physical examination reveals no focal neurological deficits.

TECHNIQUE: Axial helical scan of the brain performed with coronal and sagittal reconstructions.

*Comparison:* None.

Findings:

The brain shows age-appropriate volume with normal parenchymal attenuation and gray-white differentiation. No acute infarction or hemorrhage identified. The ventricles are normal in size without intraventricular hemorrhage. No extra-axial collection, midline shift, or brain herniation. The vascular structures appear normal. The calvarium and skull base show no fracture. Visualized paranasal sinuses, mastoids, and upper cervical spine are unremarkable.

=== IMPRESSION ===

- No intracranial hemorrhage, acute large territorial infarction, extra-axial collection, midline shift, brain herniation, or skull fracture identified.
"""

# Initialize extractor and parse the report
extractor = RadReportExtractor()
report = extractor.extract_all(report_text)
report
RadReport(title='EMERGENCY MDCT OF THE BRAIN', history='A 25-year-old female presents with headache. Physical examination reveals no focal neurological deficits.', technique='Axial helical scan of the brain performed with coronal and sagittal reconstructions.', comparison='None.', findings='The brain shows age-appropriate volume with normal parenchymal attenuation and gray-white differentiation. No acute infarction or hemorrhage identified. The ventricles are normal in size without intraventricular hemorrhage. No extra-axial collection, midline shift, or brain herniation. The vascular structures appear normal. The calvarium and skull base show no fracture. Visualized paranasal sinuses, mastoids, and upper cervical spine are unremarkable.', impression='- No intracranial hemorrhage, acute large territorial infarction, extra-axial collection, midline shift, brain herniation, or skull fracture identified.')

Access individual sections:

print(report.history)
A 25-year-old female presents with headache. Physical examination reveals no focal neurological deficits.

Convert to dictionary or JSON

report.to_dict()
{'title': 'EMERGENCY MDCT OF THE BRAIN',
 'history': 'A 25-year-old female presents with headache. Physical examination reveals no focal neurological deficits.',
 'technique': 'Axial helical scan of the brain performed with coronal and sagittal reconstructions.',
 'comparison': 'None.',
 'findings': 'The brain shows age-appropriate volume with normal parenchymal attenuation and gray-white differentiation. No acute infarction or hemorrhage identified. The ventricles are normal in size without intraventricular hemorrhage. No extra-axial collection, midline shift, or brain herniation. The vascular structures appear normal. The calvarium and skull base show no fracture. Visualized paranasal sinuses, mastoids, and upper cervical spine are unremarkable.',
 'impression': '- No intracranial hemorrhage, acute large territorial infarction, extra-axial collection, midline shift, brain herniation, or skull fracture identified.'}
print(report.to_json(indent = 2)) # pretty-printed
{
  "title": "EMERGENCY MDCT OF THE BRAIN",
  "history": "A 25-year-old female presents with headache. Physical examination reveals no focal neurological deficits.",
  "technique": "Axial helical scan of the brain performed with coronal and sagittal reconstructions.",
  "comparison": "None.",
  "findings": "The brain shows age-appropriate volume with normal parenchymal attenuation and gray-white differentiation. No acute infarction or hemorrhage identified. The ventricles are normal in size without intraventricular hemorrhage. No extra-axial collection, midline shift, or brain herniation. The vascular structures appear normal. The calvarium and skull base show no fracture. Visualized paranasal sinuses, mastoids, and upper cervical spine are unremarkable.",
  "impression": "- No intracranial hemorrhage, acute large territorial infarction, extra-axial collection, midline shift, brain herniation, or skull fracture identified."
}
Note

The pattern matching mechanism can extract sections from text with plain text or markdown formatting.

Learn More

Footnotes

  1. The “common” radiology report section were based on author experience in our institution.↩︎