Skip to content

Myocardial infarction[source]

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 None
  • span._.assigned: dictionary with the following keys, if relevant:
    • heart_localized: localization of the stent or bypass

Examples

import edsnlp, edsnlp.pipes as eds

nlp = edsnlp.blank("eds")
nlp.add_pipe(eds.sentences())
nlp.add_pipe(
    eds.normalizer(
        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(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, following the insights of the algorithm proposed by Petit-Jean et al., 2024.


  1. Petit-Jean T., Gérardin C., Berthelot E., Chatellier G., Frank M., Tannier X., Kempf E. and Bey R., 2024. Collaborative and privacy-enhancing workflows on a clinical data warehouse: an example developing natural language processing pipelines to detect medical conditions. Journal of the American Medical Informatics Association. 31, pp.1280-1290. 10.1093/jamia/ocae069