Skip to content

Myocardial infarction

The eds.myocardial_infarction pipeline component extracts mentions of myocardial infarction. It will notably match:

  • Mentions of various diseases (see below)
  • Mentions of stents with a heart localization
Details of the used patterns
# fmt: off
from ..terms import HEART

main_pattern = dict(
    source="main",
    regex=[
        r"coronaropathie",
        r"angor.{1,5}instable",
        r"cardiopathie(?!.{0,20}non).{0,20}(ischem|arteriosc)",
        r"cardio.?myopathie(?!.{0,20}non).{0,20}(ischem|arteriosc)",
        r"ischemi.{1,15}myocard",
        r"syndrome.{1,5}corona.{1,10}aigu",
        r"syndrome.{1,5}corona.{1,10}st",
        r"pontage.{1,5}mammaire",
    ],
    regex_attr="NORM",
)

with_localization = dict(
    source="with_localization",
    regex=[
        r"\bstent",
        r"endoprothese",
        r"pontage",
        r"anevr[iy]sme",
        "infarctus",
        r"angioplasti",
    ],
    assign=[
        dict(
            name="heart_localized",
            regex="(" + r"|".join(HEART) + ")",
            window=(-10, 10),
        ),
    ],
    regex_attr="NORM",
)

acronym = dict(
    source="acronym",
    regex=[
        r"\bidm\b",
        r"\bsca\b",
        r"\batl\b",
    ],
    regex_attr="NORM",
    assign=dict(
        name="segment",
        regex=r"st([+-])",
        window=2,
    ),
)


default_patterns = [
    main_pattern,
    with_localization,
    acronym,
]
# fmt: on

Extensions

On each span span that match, the following attributes are available:

  • span._.detailed_status: set to "PRESENT"
  • span._.assigned: dictionary with the following keys, if relevant:
    • heart_localized: localization of the stent or bypass

Examples

import edsnlp

nlp = edsnlp.blank("eds")
nlp.add_pipe("eds.sentences")
nlp.add_pipe(
    "eds.normalizer",
    config=dict(
        accents=True,
        lowercase=True,
        quotes=True,
        spaces=True,
        pollution=dict(
            information=True,
            bars=True,
            biology=True,
            doctors=True,
            web=True,
            coding=True,
            footer=True,
        ),
    ),
)
nlp.add_pipe(f"eds.myocardial_infarction")

Below are a few examples:

text = "Une cardiopathie ischémique"
doc = nlp(text)
spans = doc.spans["myocardial_infarction"]

spans
# Out: [cardiopathie ischémique]
text = "Une cardiopathie non-ischémique"
doc = nlp(text)
spans = doc.spans["myocardial_infarction"]

spans
# Out: []
text = "Présence d'un stent sur la marginale"
doc = nlp(text)
spans = doc.spans["myocardial_infarction"]

spans
# Out: [stent sur la marginale]

span = spans[0]

span._.assigned
# Out: {'heart_localized': [marginale]}
text = "Présence d'un stent périphérique"
doc = nlp(text)
spans = doc.spans["myocardial_infarction"]

spans
# Out: []
text = "infarctus du myocarde"
doc = nlp(text)
spans = doc.spans["myocardial_infarction"]

spans
# Out: [infarctus du myocarde]

span = spans[0]

span._.assigned
# Out: {'heart_localized': [myocarde]}

Parameters

PARAMETER DESCRIPTION
nlp

The pipeline

TYPE: Optional[PipelineProtocol]

name

The name of the component

TYPE: Optional[str]

patterns

The patterns to use for matching

DEFAULT: [{'source': 'main', 'regex': ['coronaropathie',...

label

The label to use for the Span object and the extension

TYPE: str DEFAULT: myocardial_infarction

span_setter

How to set matches on the doc

TYPE: SpanSetterArg DEFAULT: {'ents': True, 'myocardial_infarction': True}

Authors and citation

The eds.myocardial_infarction component was developed by AP-HP's Data Science team with a team of medical experts. A paper describing in details the development of those components is being drafted and will soon be available.