Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Functions added to fetch the termURLs of diagnosis, assessment, sex and image modality #20

Merged
merged 13 commits into from
Jul 25, 2024
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- name: Pull Mistral Model
run: |
ollama pull mistral
ollama pull llama3

- name: Run tests
run: |
Expand All @@ -42,3 +43,4 @@ jobs:
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ repos:
- id: mypy
args:
- --ignore-missing-imports
additional_dependencies: ['types-requests']
27 changes: 25 additions & 2 deletions app/LLM_extractions/extractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ class Parameters(BaseModel):
min_age: Optional[str] = Field(
description="minimum age (lower age limit) if specified", default=None
)
sex: Optional[str] = Field(description="sex", default=None)
sex: Optional[str] = Field(
description="sex, only accepts 'male' or 'female' or 'other'",
default=None,
examples=["male", "female", "other"],
)
diagnosis: Optional[str] = Field(description="diagnosis", default=None)
is_control: Optional[bool] = Field(
description="healthy control subjects", default=None
Expand Down Expand Up @@ -93,7 +97,26 @@ def extract_information(context: str) -> Optional[Union[dict, str, None]]:

# Filter out keys where the value is None or 'None' (string)
filtered_ordered_response = {
k: v
k: (
float(v)
rmanaem marked this conversation as resolved.
Show resolved Hide resolved
if k in ["min_age", "max_age"] and v is not None
else (
int(v)
if k
in [
"min_num_phenotypic_sessions",
"min_num_imaging_sessions",
]
and v is not None
else (
v.lower()
if isinstance(v, str)
and k
in ["diagnosis", "assessment", "image_modal", "sex"]
else v
)
)
)
for k, v in ordered_response.items()
if v is not None and v != "None"
}
Expand Down
6 changes: 6 additions & 0 deletions app/fetch_termURLs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import os
import sys

sys.path.append(
os.path.dirname(os.path.realpath(__file__))
) # Fixes relative import error.
6 changes: 6 additions & 0 deletions app/fetch_termURLs/abbreviations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import os
import sys

sys.path.append(
os.path.dirname(os.path.realpath(__file__))
) # Fixes relative import error.
91 changes: 91 additions & 0 deletions app/fetch_termURLs/abbreviations/abbreviations_assessment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
abbreviations_assessment = [
{
"label": "behavioral approach/inhibition systems",
"abbreviations": ["BIS"],
},
{"label": "Barratt Impulsiveness Scale", "abbreviations": ["BIS"]},
{"label": "DOSPERT", "abbreviations": ["DO", "DOTS", "DOS"]},
{
"label": "Positive and Negative Affect Scale",
"abbreviations": ["PANAS"],
},
{"label": "balloon analogue risk task", "abbreviations": ["BART"]},
{"label": "stop signal task", "abbreviations": ["SST", "SSTT"]},
{"label": "breath-holding", "abbreviations": ["BH"]},
{"label": "paired associate learning", "abbreviations": ["PAL", "PALA"]},
{"label": "paired associate recall", "abbreviations": ["PAIR"]},
{
"label": "spatial working memory task",
"abbreviations": ["SWM", "SWMT", "N-back"],
},
{
"label": "Wechsler Memory Scale Fourth Edition",
"abbreviations": ["WMS-IV"],
},
{"label": "letter number sequencing", "abbreviations": ["LNS", "LNSS"]},
{
"label": "Wechsler Adult Intelligence Scale - Revised",
"abbreviations": ["WAIS-R"],
},
{
"label": "n-back task",
"abbreviations": ["NVT", "N-Task", "NTB", "n-task"],
},
{
"label": "Scale for the Assessment of Negative Symptoms",
"abbreviations": ["SANS"],
},
{
"label": "Scale for the Assessment of Positive Symptoms",
"abbreviations": ["SAPS"],
},
{"label": "big five questionnaire", "abbreviations": ["NEO-FFI", "PAQ"]},
{"label": "Mini Mental State Examination", "abbreviations": ["MMSE"]},
{"label": "PEBL Perceptual Vigilance Task", "abbreviations": ["PVT"]},
{
"label": "Raven's Advanced Progressive Matrices",
"abbreviations": ["RAPM"],
},
{"label": "Kaufman Brief Intelligence Test", "abbreviations": ["KBIT"]},
{"label": "theory of mind task", "abbreviations": ["ToM", "TOMS"]},
{"label": "Stroop task", "abbreviations": ["ST"]},
{
"label": "Comprehensive Test of Phonological Processing",
"abbreviations": ["CTOPP"],
},
{"label": "Peabody Picture Vocabulary Test", "abbreviations": ["PPVT"]},
{
"label": "Wechsler Abbreviated Scale of Intelligence",
"abbreviations": ["WASI"],
},
{"label": "multisource interference task", "abbreviations": ["MIST"]},
{
"label": "Center for Epidemiologic Studies Depression Scale",
"abbreviations": ["CES-D"],
},
{"label": "Kirby Delay Discounting Task", "abbreviations": ["KD", "KDDT"]},
{
"label": "UPPS-P Impulsivity Scale",
"abbreviations": ["UPISS", "UPPS-PIS"],
},
{"label": "Zuckerman Sensation Seeking Scale", "abbreviations": ["SSS"]},
{"label": "Eriksen flanker task", "abbreviations": ["EF"]},
{"label": "Continuous Performance Task", "abbreviations": ["CPT", "CPCT"]},
{"label": "Emotion Regulation Questionnaire", "abbreviations": ["ERQ"]},
{"label": "Motor Screening Task", "abbreviations": ["MST"]},
{"label": "Reaction Time", "abbreviations": ["RT", "RTT"]},
{
"label": "Rapid Visual Information Processing",
"abbreviations": ["RVIP", "RVP"],
},
{"label": "Stockings of Cambridge Task", "abbreviations": ["SCAT"]},
{
"label": "Edinburgh Handedness Inventory",
"abbreviations": ["EHI", "EHII"],
},
{"label": "National Adult Reading Test", "abbreviations": ["NART", "NAT"]},
{
"label": "Structured Clinical Interview for Diagnostic and Statistical Manual of Mental Disorders (DSM-IV)",
"abbreviations": ["SCID"],
},
]
36 changes: 36 additions & 0 deletions app/fetch_termURLs/abbreviations/abbreviations_diagnosis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
abbreviations_diagnosis = [
{"label": "Schizophrenia", "abbreviations": ["SZ", "SP", "SZD"]},
{"label": "Bipolar disorder", "abbreviations": ["BD", "BPI"]},
{
"label": "Attention deficit hyperactivity disorder",
"abbreviations": ["ADHD", "ADHD-PI", "ADHD-C"],
},
{"label": "Separation anxiety", "abbreviations": ["SAD", "SAS"]},
{"label": "Generalized anxiety disorder", "abbreviations": ["GAD", "GAN"]},
{"label": "Social phobia", "abbreviations": ["SAD", "SPS", "SPH"]},
{"label": "Major depressive disorder", "abbreviations": ["MDD"]},
{
"label": "Autism spectrum disorder",
"abbreviations": ["ASD", "AS", "ASDs"],
},
{"label": "Overweight", "abbreviations": ["OW", "BW"]},
{"label": "Parkinson's disease", "abbreviations": ["PD", "PDx", "PDs"]},
{"label": "Traumatic brain injury", "abbreviations": ["TBI", "TBI-SCI"]},
{"label": "Obsessive-compulsive disorder", "abbreviations": ["OCD"]},
{"label": "Fibromyalgia", "abbreviations": ["FM"]},
{"label": "Visual impairment", "abbreviations": ["VI", "VIa", "VA"]},
{"label": "Depressive disorder", "abbreviations": ["MDD", "DD"]},
{"label": "Dysthymia", "abbreviations": ["DYSM", "DD"]},
{"label": "Mood disorder", "abbreviations": ["MDD", "MD"]},
{"label": "Dyslexia", "abbreviations": ["ID", "IDR", "DLX", "dys."]},
{"label": "Specific spelling disorder", "abbreviations": ["SSD"]},
{
"label": "Mental disorder",
"abbreviations": ["MD", "MDD", "BD", "PD", "MPD"],
},
{"label": "Anxiety disorder", "abbreviations": ["AD"]},
{"label": "Concussion injury of brain", "abbreviations": ["CI"]},
{"label": "Moderate depression", "abbreviations": ["MDD", "MODD"]},
{"label": "Mild depression", "abbreviations": ["MD"]},
{"label": "Aphasia", "abbreviations": ["AS", "AP", "Aphas."]},
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
abbreviations_image_modality = [
{"label": "Arterial Spin Labeling", "abbreviations": ["ASL"]},
{"label": "Diffusion Weighted", "abbreviations": ["DWI", "DW"]},
{"label": "Electroencephalogram", "abbreviations": ["EEG", "ECG"]},
{"label": "Flow Weighted", "abbreviations": ["FW"]},
{"label": "T1 Weighted", "abbreviations": ["T1W", "T1WI"]},
{"label": "T2 Weighted", "abbreviations": ["TW", "T2W"]},
]
5 changes: 5 additions & 0 deletions app/fetch_termURLs/abbreviations/abbreviations_sex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
abbreviations_sex = [
{"label": "male", "abbreviations": ["MALE", "M", "m"]},
{"label": "female", "abbreviations": ["WF", "F", "Fem.", "Female", "F."]},
{"label": "other", "abbreviations": ["OTH", "Oth", "OT"]},
]
Loading