feat(tasks): generalized note section extraction by note type#34
Open
Rian354 wants to merge 12 commits into
Open
feat(tasks): generalized note section extraction by note type#34Rian354 wants to merge 12 commits into
Rian354 wants to merge 12 commits into
Conversation
Introduces _RADIOLOGY_SECTION_TARGETS and a general-purpose extract_note_sections(text, note_type) static method that routes to discharge vs radiology target sets. _parse_note_sections splits the shared parsing logic. _extract_admission_sections is now a backward-compatible alias (all 18 unit tests still pass unchanged). Adds Social History, Family History, Allergies, ROS to discharge targets. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ers" This reverts commit 1541b11.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR: Generalized Note Section Extraction by Note Type
Problem
The current
_extract_admission_sections()method inBaseMultimodalMIMIC4Taskis discharge-note specific. It targets headers like "Chief Complaint", "HPI", and "Past Medical History": sections that are meaningless in radiology notes.When
ClinicalNotesICDLabsMIMIC4processes radiology notes today, it passes the raw text through w/o section-aware filtering. Radiology reports have a very different structure:The "Impression" and "Findings" sections contain the actual diagnostic signal. The rest (technique, demographics) is noise that increases token count w/o clinical value.
Discharge notes also have more valuable admission-time sections than the current target set: Social History, Family History, Allergies, and Review of Systems are all clinically available at admission.
Solution
Introduce a general-purpose
extract_note_sections(text, note_type)static method that:_DISCHARGE_SECTION_TARGETSvs_RADIOLOGY_SECTION_TARGETS)_parse_note_sections()parser (header regex + line accumulator)text[:1024]when no matching headers are foundThe old
_extract_admission_sections(text)becomes a backward-compatible alias callingextract_note_sections(text, note_type="discharge").Changes
pyhealth/tasks/multimodal_mimic4.py_ADMISSION_SECTION_TARGETS_DISCHARGE_SECTION_TARGETS. Added Social History, Family History, Allergies, Review of Systems._RADIOLOGY_SECTION_TARGETS_parse_note_sections(text){lowered_header: content}dict.extract_note_sections(text, note_type)_extract_admission_sections(text)extract_note_sections(..., note_type="discharge").Target Header Rationale
Discharge notes: admission-context sections:
Radiology notes: diagnostic output sections:
Usage
Testing
Run existing unit tests. All 18 should pass unchanged (backward-compatible alias):
Impact on Downstream Tasks
NotesLabsMIMIC4: no change (uses discharge only, alias is backward-compatible).ClinicalNotesICDLabsMIMIC4: should callextract_note_sections(text, note_type="radiology")for radiology events. Tracked in a follow-up.Files Changed
pyhealth/tasks/multimodal_mimic4.py