edsnlp.pipes.ner.frailty.cognitive_status.factory
create_component = registry.factory.register('eds.cognitive_status', assigns=['doc.ents', 'doc.spans'])(CognitiveStatusMatcher) module-attribute [source]
The eds.cognitive_status pipeline component extracts mentions of the cognitive status.
Details of the used patterns
# fmt: off
from ..utils import (
ALTERED_STATUS_COMPLEMENTS,
HEALTHY_STATUS_COMPLEMENTS,
make_assign_regex,
make_include_dict_from_list,
make_status_assign,
normalize_space_characters,
)
healthy = dict(
source="healthy",
regex=[
"langage fluent",
r"ne s'est jamais perdue?",
r"discours (?:clair|adapte)(?: et (?:adapte|clair))?",
"discours spontane",
],
regex_attr="NORM",
)
severe = dict(
source="severe",
regex=[
"demence",
"tncm",
"alzheimer",
r"\bdts complete",
r"neuro[\s-]?degenerati(?:f|ve)",
r"neuro[\s-]?denerati(?:f|ve)", # Faute de frappe
"syndrome dementiel",
],
regex_attr="NORM",
)
altered = dict(
source="altered",
regex=[
"agitation",
"agressivite",
r"aphasi(?:qu)?e",
r"apraxi(?:qu)?e",
"confusion",
r"patiente? confuse?",
r"\bapathi(?:e|que)",
"deficit de la memoire",
"atteinte de la memoire",
"delirium",
r"idees? delirantes?",
r"hallucin(e|ations?)",
r"syndrome (amnesique|confusionnel)",
"tncm",
"plainte mnesique",
"plainte cognitive",
r"syndromes? extra(?:[\s-])?pyramida(?:l|ux)",
r"signes? extra(?:[\s-])?pyramida(?:l|ux)",
"roue dentee",
r"syndromes? parkinsonn?iens?",
r"marche a petits? pas",
"manque du mot",
r"(?:syndrome )?dysexecuti(?:f|ve)",
r"\boubli[es]?\b",
r"pertes? de memoire",
"se plaint de la memoire",
"dyscalculie",
r"n'arrive (?:pas|plus) a s'\sorienter",
r"neuro(?:[\s-]?psycho)?logue",
"anosognosie",
"alteration cognitive",
"accueil de jour",
],
regex_attr="NORM",
exclude=dict(regex="aigue?s?", window=(-3, 3)),
)
recognition = dict(
source="altered_recognition",
regex=["reconnaissance"],
regex_attr="NORM",
assign=dict(
name="complement",
regex=make_assign_regex(["perturbee?", "perturbation"]),
window=(-4, 4),
required=True,
),
)
consultation = dict(
source="other_consultation",
regex=[
"consultation",
r"\bcs\b",
],
regex_attr="NORM",
assign=dict(name="memoire", regex="(memoire)", window=3, required=True),
)
memory = dict(
source="other_memory",
regex=["memoire"],
regex_attr="NORM",
assign=make_status_assign(),
include=make_include_dict_from_list(make_status_assign()),
)
TROUBLE_COMPLEMENTS_ALTERED = [
"attentionnels?",
"attention",
"gnosiques?",
"praxiques?",
"praxies?",
"memoire",
"comprehension",
"mnesiques?",
"phasiques?",
"fonctions? superieure?s?",
"fonctions? executives?",
"denomination",
"flexibilite mentale",
"sommeil paradoxal",
r"cogniti(?:f|ve)s?",
]
TROUBLE_COMPLEMENTS_SEVERE = [
"jugement",
"comportement",
]
troubles = dict(
source="altered_troubles",
regex=[
r"(?<!bilan de )(?<!bilan )troubles?",
"anomalies?",
"difficultes?",
"fragilites?",
],
regex_attr="NORM",
assign=[
dict(
name="trouble_complement",
regex=make_assign_regex(TROUBLE_COMPLEMENTS_ALTERED),
window=8,
),
dict(
name="severe_trouble_complement",
regex=make_assign_regex(TROUBLE_COMPLEMENTS_SEVERE),
window=8,
),
],
include=dict(
regex=make_assign_regex(
TROUBLE_COMPLEMENTS_ALTERED + TROUBLE_COMPLEMENTS_SEVERE
),
window=6,
),
)
frailty = dict(
source="altered_frailty",
regex=["fragilite", "fragile"],
regex_attr="NORM",
assign=dict(
name="frailty_complement",
regex=make_assign_regex(["cognitive"]),
window=6,
required=True,
),
)
tnc = dict(
source="altered_tnc",
regex=[r"troubles? (?:neuro[\s-]?)?cogniti(?:f|ve)s?"],
assign=[
dict(name="mild", regex=r"(legers?|mineurs?)", window=2),
dict(name="severe", regex="(majeurs?)", window=2),
],
)
ORIENTATION_COMPLEMENTS = [
"temps",
"espace",
"temporel(?:le)?",
"spatiale?",
r"spatio[\s-]?temporelle",
]
desorientation = dict(
source="altered_desorientation",
regex=[
r"(?:patiente? )?desorient(?:ee?|ation)",
],
assign=[
dict(
name="complement",
regex=make_assign_regex(ORIENTATION_COMPLEMENTS),
window=15,
reduce_mode=None,
),
dict(
name="severe_complement",
regex=r"(\bcomplete(?:ment)?\b)",
window=(-2, 15),
),
],
regex_attr="NORM",
)
orientation_healthy = dict(
source="healthy_orientation",
regex=[
r"(?:patiente? )?orientee?\b",
],
assign=dict(
name="complement",
regex=make_assign_regex(ORIENTATION_COMPLEMENTS),
window=15,
reduce_mode=None,
),
regex_attr="NORM",
)
orientation_other = dict(
source="other_orientation",
regex=[
r"orientation",
],
assign=make_status_assign(-2, 2)
+ [
dict(
name="complement",
regex=make_assign_regex(ORIENTATION_COMPLEMENTS),
window=15,
reduce_mode=None,
required=True,
),
],
regex_attr="NORM",
)
cognitive_status = dict(
source="other_cognitive_status",
regex=[
"etat cognitif",
"statut cognitif",
r"etat neuro(?:[\s-]?psycho)?logi(?:e|que)",
r"statut neuro(?:[\s-]?psycho)?logi(?:e|que)",
],
regex_attr="NORM",
assign=make_status_assign(),
)
other = dict(
source="other",
regex=[
r"evaluation neuro[\s-]?psychique",
r"examen neurologi(?:e|que)",
"tests? de memoire",
"epreuves? de praxie",
r"neuro[\s-]?cognitif",
"fonctions? cognitives?",
"(?:sur le )?plan cognitif",
"(?:sur le )?plan attentionnel",
"(?:sur le )?plan du comportement",
r"(?:sur le )?plan neurologi(?:e|que)",
r"(?:sur le )plan neuro[\s-]?psychologi(?:e|que)",
"praxies? gestuelles?",
"praxies? constructives?",
"profil cognitif",
"evolution cognitive",
"evolution comportementale",
"tableau cognitif",
"evaluation cognitive",
r"psycho[-\s]?motricite",
"remediation cognitive",
r"test de l'horloge (?:(?!sans)\w+\s){0,5}succes",
r"rappel des (?:trois|3) mots",
"test des (?:cinq|5) mots",
r"\bdubois \d{1,2}(?:/10)?",
"suivi memoire",
"orthophonie",
r"contention (chimique|physique)",
"stimulations? cognitives?",
"nuits? difficiles?",
],
regex_attr="NORM",
)
BILAN_COMPLEMENTS = [
"memoire",
r"troubles? (?:neuro[\s-]?)?cognitifs?",
r"neuro[\s-]?psychologi(?:e|que)",
"cognitif",
]
bilan = dict(
source="other_bilan",
regex=["bilan"],
regex_attr="NORM",
assign=[
dict(
name="complement",
regex=make_assign_regex(BILAN_COMPLEMENTS),
required=True,
)
],
)
ralentissement = dict(
source="altered_ralentissement",
regex=["ralentissement"],
assign=dict(
name="complement",
regex=make_assign_regex(["ideatoire"]),
window=3,
required=True,
),
)
sleep = dict(
source="other_sleep",
regex=["sommeil", "endormissement", r"\bdort\b"],
regex_attr="NORM",
exclude=[
dict(name="apnee", regex=["apnee"], window=-4),
dict(
name="medecine",
regex=["gelule", "cachet", "comprime", "souhaite"],
window=(-6, 6),
),
],
assign=[
dict(
name="sleep_healthy",
regex=make_assign_regex(HEALTHY_STATUS_COMPLEMENTS),
window=(-4, 4),
),
dict(
name="sleep_bad",
regex=make_assign_regex(ALTERED_STATUS_COMPLEMENTS),
window=(-4, 4),
),
],
)
night = dict(
source="other_night",
regex=["nuits?"],
regex_attr="NORM",
assign=make_status_assign(-2, 2, priority=False),
include=make_include_dict_from_list(make_status_assign(-2, 2)),
)
default_patterns = normalize_space_characters(
[
healthy,
altered,
severe,
other,
desorientation,
orientation_healthy,
orientation_other,
ralentissement,
cognitive_status,
frailty,
troubles,
bilan,
consultation,
memory,
recognition,
sleep,
night,
tnc,
]
)
# fmt: on
Extensions
On each span span that match, the following attribute is available:
span._.cognitive_status: set to None.
It will specify the severity of the mention regarding the cognitive status of the patient.
Possible values are:
healthy: this span suggests the patient is well regarding that domain.altered_nondescript: this span suggests the patient is not well, but it is not yet possible to ascertain the degree of alteration.altered_mild: this span suggests a light alteration regarding this domain.altered_severe: this span suggests a severe alteration regarding this domain.other: this span is not indicative of the level of alteration regarding this domain. Still, it hints that this domain has been evaluated.
Examples
import edsnlp, edsnlp.pipes as eds
nlp = edsnlp.blank("eds")
nlp.add_pipe(eds.sentences())
nlp.add_pipe(eds.normalizer())
nlp.add_pipe(f"eds.cognitive_status")
Below are a few examples:
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
nlp | The pipeline TYPE: |
name | The name of the component TYPE: |
patterns | The patterns to use for matching TYPE: |
label | The label to use for the TYPE: |
span_setter | How to set matches on the doc TYPE: |