Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 27,601 Bytes
fab8051 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
"""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={},
),
],
),
]
|