Multimodal MRI marker of cognition explains the association between cognition and mental health in the UK Biobank.
The 18 matches
- [1] § Materials and methods › Brain MRI › Diffusion-weighted MRI (dwMRI) ↔ 3_MRI_preprocessing/01_GetMRIData_dwMRI_IDP.ipynb, lines 1399–1506 · score 0.89 · free water volume, diffusion tensor fitting, diffusion tensor mode, orientation dispersion, volume fraction, head motion
- [2] § Materials and methods › Brain MRI › MRI confounds ↔ 3_MRI_preprocessing/01_GetMRIData_dwMRI_IDP.ipynb, lines 1399–1506 · score 0.86 · median absolute, acquisition date, brain position, head motion, volumetric scaling, intensity scaling
- [3] § Materials and methods › Brain MRI › MRI confounds ↔ 3_MRI_preprocessing/04_GetMRIData_rsMRI_IDP_FullPartCorr_Confounds.ipynb, lines 1129–1315 · score 0.86 · median absolute, acquisition date, head motion, volumetric scaling, intensity scaling, UK Biobank
- [4] § Materials and methods › Brain MRI › Structural MRI (sMRI) ↔ 3_MRI_preprocessing/03_GetMRIData_sMRI.ipynb, lines 16–48 · score 0.85 · a2009s, FreeSurfer ASEG, FreeSurfer Desikan, subcortical volumes, matter volumes, brain volume
- [5] § Materials and methods › Mental health ↔ 2_Mental_Health/01_GetMHData.ipynb, lines 1847–1989 · score 0.81 · nervous system, mental distress, Mental health, addictions, bipolar, mania
- [6] § Materials and methods › Data › Cognition › Transformations of cognitive scores ↔ 1_Cognitive_preprocessing/04_GetGFactor_SingleSplit.Rmd, lines 33–47 · score 0.79 · incorrect matches, Prospective Memory, Pairs Matching, complete numeric, Reaction, log
- [7] § Materials and methods › Data › Cognition › Transformations of cognitive scores ↔ 1_Cognitive_preprocessing/02_CogData_Descriptive_5Folds.ipynb, lines 23–34 · score 0.78 · incorrect matches, Prospective Memory, Pairs Matching, complete numeric, Reaction, log
- [8] § Materials and methods › Mental health › Description of composite measures ↔ 2_Mental_Health/01_GetMHData.ipynb, lines 1847–1989 · score 0.77 · Hazardous alcohol, drinking alcohol, Alcohol dependence, moderate, AUDIT, log
- [9] § Materials and methods › Brain MRI › Diffusion-weighted MRI (dwMRI) ↔ 3_MRI_preprocessing/01_GetMRIData_dwMRI_IDP.ipynb, lines 1384–1397 · score 0.65 · FA skeleton, tracts common, white matter tracts, DTI, TBSS, voxel
- [10] § Materials and methods › Mental health › Description of composite measures ↔ 4_PLS/02_1_PLS_MH_SingleSplit.ipynb, lines 199–296 · score 0.64 · recurrent depression, depression triggered, GAD, loss, lifetime, harm
- [11] § Materials and methods › Data › Cognition › Transformations of cognitive scores ↔ 1_Cognitive_preprocessing/03_GetGFactor_5Folds.Rmd, lines 268–296 · score 0.62 · Fluid Intelligence score, Picture Vocabulary, trail, cognitive
- [12] § Materials and methods › Data › Cognition › Transformations of cognitive scores ↔ 1_Cognitive_preprocessing/04_GetGFactor_SingleSplit.Rmd, lines 92–115 · score 0.62 · Fluid Intelligence score, Picture Vocabulary, trail, cognitive
- [13] § Materials and methods › Data analysis › Machine learning ↔ 4_PLS/02_1_PLS_MH_SingleSplit.ipynb, lines 661–713 · score 0.59 · absolute error, squared error, MSE, MAE, R2, Pearson
- [14] § Materials and methods › Data analysis › Machine learning ↔ 4_PLS/01_PLS_MH_5Folds.ipynb, lines 74–137 · score 0.59 · absolute error, squared error, MSE, MAE, R2, fold
- [15] § Materials and methods › Mental health › Description of composite measures ↔ 2_Mental_Health/01_GetMHData.ipynb, lines 1475–1509 · score 0.57 · Probable Depression Status, PDS, Anxiety, Health, scores
- [16] § Results › Predictive modeling › Mental health ↔ 2_Mental_Health/01_GetMHData.ipynb, lines 1548–1691 · score 0.55 · mental distress, mental health, wellbeing, cannabis, happiness, unusual
- [17] § Materials and methods › Feature importance ↔ 4_PLS/01_PLS_MH_5Folds.ipynb, lines 190–232 · score 0.51 · Pearson correlations, predicting cognition, mental health, fold, transformation
- [18] § Materials and methods › Brain MRI › Resting-state functional MRI (rsMRI) ↔ 3_MRI_preprocessing/04_GetMRIData_rsMRI_IDP_FullPartCorr_Confounds.ipynb, lines 1400–1462 · score 0.50 · intensity scaling, artefact, echo, temporal, motion, Preprocessing
Paper
Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
Jupyter notebook · 1,989 lines · 81 KB · MIT · 4 matches
- # %%
- import pandas as pd
- import ukbiobank.utils.utils
- from ukbiobank.utils import loadCsv
- from ukbiobank.utils import addFields
- from ukbiobank.utils.utils import fieldIdsToNames
- import matplotlib.pyplot as plt
- import numpy as np
- # %%
- csv_path = '/UK_BB/ukbbdata/ukbb_oct23/ukb.csv'
- ukb = ukbiobank.ukbio(ukb_csv=csv_path)
- # %%
- # Diagnoses main ICD10
- diagnoses_df = ukbiobank.utils.utils.loadCsv(ukbio=ukb, fields=['eid', 41202])
- diagnoses_main_ukb = addFields(ukbio=ukb, df=diagnoses_df, fields=['eid', 41202])
- diagnoses_main_icd = ukbiobank.utils.utils.fieldIdsToNames(ukbio=ukb, df=diagnoses_main_ukb)
- diagnoses_main_icd.to_csv('/UK_BB/diagnoses/diagnoses_main_icd[ukb].csv', index=False)
- # %%
- # Diagnoses ICD10
- diagnoses_df = ukbiobank.utils.utils.loadCsv(ukbio=ukb, fields=['eid', 41270])
- diagnoses_ukb = addFields(ukbio=ukb, df=diagnoses_df, fields=['eid', 41270])
- diagnoses_icd = ukbiobank.utils.utils.fieldIdsToNames(ukbio=ukb, df=diagnoses_ukb)
- diagnoses_icd.to_csv('/UK_BB/diagnoses/diagnoses_icd.csv', index=False)
- # %%
- # Mental Health Instance 2 and Online
- # Instance 2
- dfmh_2 = ukbiobank.utils.utils.loadCsv(ukbio=ukb, fields=['eid',
- 20002,
- 20126,
- 20122,
- 20127,
- 20124,
- 20125,
- 20123,
- 1920,
- 1930,
- 1940,
- 1950,
- 1960,
- 1970,
- 1980,
- 1990,
- 2000,
- 2010,
- 2020,
- 2030,
- 2040,
- 4526,
- 4537,
- 4548,
- 4559,
- 4570,
- 4581,
- 2050,
- 2060,
- 2070,
- 2080,
- 2090,
- 2100,
- 4598,
- 4609,
- 4620,
- 4631,
- 5375,
- 5386,
- 4642,
- 4653,
- 6156,
- 5663,
- 5674,
- 6145,
- 1031,
- 6160,
- 2110,
- 1031,
- 6160,
- 2110], instance=2)
- # Online
- dfmh_online = ukbiobank.utils.utils.loadCsv(ukbio=ukb, fields=['eid',
- 20002,
- 20499,
- 20500,
- 20544,
- 20446,
- 20441,
- 20547,
- 20433,
- 20434,
- 20445,
- 20447,
- 20532,
- 20435,
- 20438,
- 20449,
- 20450,
- 20436,
- 20439,
- 20440,
- 20442,
- 20448,
- 20518,
- 20510,
- 20507,
- 20519,
- 20514,
- 20511,
- 20513,
- 20508,
- 20534,
- 20546,
- 20437,
- 20533,
- 20517,
- 20535,
- 20536,
- 20502,
- 20501,
- 20492,
- 20548,
- 20493,
- 20550,
- 20419,
- 20541,
- 20429,
- 20421,
- 20425,
- 20537,
- 20539,
- 20427,
- 20418,
- 20423,
- 20420,
- 20422,
- 20540,
- 20543,
- 20428,
- 20505,
- 20512,
- 20506,
- 20509,
- 20516,
- 20515,
- 20520,
- 20426,
- 20542,
- 20549,
- 20417,
- 20538,
- 20552,
- 20431,
- 20406,
- 20401,
- 20456,
- 20457,
- 20503,
- 20504,
- 20551,
- 20404,
- 20415,
- 20432,
- 20414,
- 20403,
- 20416,
- 20413,
- 20407,
- 20412,
- 20409,
- 20408,
- 20411,
- 20405,
- 20410,
- 20455,
- 20453,
- 20454,
- 20461,
- 20462,
- 20468,
- 20474,
- 20463,
- 20466,
- 20471,
- 20477,
- 20467,
- 20470,
- 20476,
- 20465,
- 20473,
- 20489,
- 20488,
- 20487,
- 20490,
- 20491,
- 20522,
- 20523,
- 20521,
- 20524,
- 20525,
- 20531,
- 20529,
- 20526,
- 20530,
- 20528,
- 20527,
- 20497,
- 20498,
- 20495,
- 20496,
- 20494,
- 20479,
- 20485,
- 20486,
- 20480,
- 20482,
- 20481,
- 20553,
- 20554,
- 20483,
- 20484,
- 20458,
- 20459,
- 20460,
- 1031,
- 6160,
- 2110
- ])
- # %%
- # Add fields
- # Instance 2
- mh_i2 = addFields(ukbio=ukb, df=dfmh_2, fields=['eid',
- 20002,
- 20126,
- 20122,
- 20127,
- 20124,
- 20125,
- 20123,
- 1920,
- 1930,
- 1940,
- 1950,
- 1960,
- 1970,
- 1980,
- 1990,
- 2000,
- 2010,
- 2020,
- 2030,
- 2040,
- 4526,
- 4537,
- 4548,
- 4559,
- 4570,
- 4581,
- 2050,
- 2060,
- 2070,
- 2080,
- 2090,
- 2100,
- 4598,
- 4609,
- 4620,
- 4631,
- 5375,
- 5386,
- 4642,
- 4653,
- 6156,
- 5663,
- 5674,
- 6145,
- 1031,
- 6160,
- 2110,
- 1031,
- 6160,
- 2110], instances=2)
- # Online
- mh_online = addFields(ukbio=ukb, df=dfmh_online, fields=['eid',
- 20002,
- 20499,
- 20500,
- 20544,
- 20446,
- 20441,
- 20547,
- 20433,
- 20434,
- 20445,
- 20447,
- 20532,
- 20435,
- 20438,
- 20449,
- 20450,
- 20436,
- 20439,
- 20440,
- 20442,
- 20448,
- 20518,
- 20510,
- 20507,
- 20519,
- 20514,
- 20511,
- 20513,
- 20508,
- 20534,
- 20546,
- 20437,
- 20533,
- 20517,
- 20535,
- 20536,
- 20502,
- 20501,
- 20492,
- 20548,
- 20493,
- 20550,
- 20419,
- 20541,
- 20429,
- 20421,
- 20425,
- 20537,
- 20539,
- 20427,
- 20418,
- 20423,
- 20420,
- 20422,
- 20540,
- 20543,
- 20428,
- 20505,
- 20512,
- 20506,
- 20509,
- 20516,
- 20515,
- 20520,
- 20426,
- 20542,
- 20549,
- 20417,
- 20538,
- 20552,
- 20431,
- 20406,
- 20401,
- 20456,
- 20457,
- 20503,
- 20504,
- 20551,
- 20404,
- 20415,
- 20432,
- 20414,
- 20403,
- 20416,
- 20413,
- 20407,
- 20412,
- 20409,
- 20408,
- 20411,
- 20405,
- 20410,
- 20455,
- 20453,
- 20454,
- 20461,
- 20462,
- 20468,
- 20474,
- 20463,
- 20466,
- 20471,
- 20477,
- 20467,
- 20470,
- 20476,
- 20465,
- 20473,
- 20489,
- 20488,
- 20487,
- 20490,
- 20491,
- 20522,
- 20523,
- 20521,
- 20524,
- 20525,
- 20531,
- 20529,
- 20526,
- 20530,
- 20528,
- 20527,
- 20497,
- 20498,
- 20495,
- 20496,
- 20494,
- 20479,
- 20485,
- 20486,
- 20480,
- 20482,
- 20481,
- 20553,
- 20554,
- 20483,
- 20484,
- 20458,
- 20459,
- 20460,
- 1031,
- 6160,
- 2110])
- # %%
- # Convert Field IDs to Field Names
- # Instance 2
- mh_i2_names = ukbiobank.utils.utils.fieldIdsToNames(ukbio=ukb, df=mh_i2)
- # Online
- mh_online_names = ukbiobank.utils.utils.fieldIdsToNames(ukbio=ukb, df=mh_online)
- # Merge Mental Health Instance 2 and Mental Health Online
- mh_i2_online = pd.merge(mh_i2_names, mh_online_names, on="eid", suffixes=('', '_drop'))
- mh_i2_online.columns.to_list()
- mh_i2_online = mh_i2_online.loc[:, ~mh_i2_online.columns.str.endswith('_drop')]
- mh_i2_online.to_csv('/UK_BB/mental_health/mh_instance2_online.csv', index=False)
- # %% [markdown]
- # ## Manage NaNs
- # %%
- # Drop NAs
- mh_diagnoses_drop_na = mh_i2_online.dropna(subset=[
- "Ever manic/hyper for 2 days-2.0",
- "Worry too long after embarrassment-2.0",
- "Loneliness, isolation-2.0",
- "Risk taking-2.0",
- "Happiness-2.0",
- "Guilty feelings-2.0",
- "Mood swings-2.0",
- "Sensitivity / hurt feelings-2.0",
- "Suffer from 'nerves'-2.0",
- "Frequency of depressed mood in last 2 weeks-2.0",
- "Seen doctor (GP) for nerves, anxiety, tension or depression-2.0",
- "Frequency of unenthusiasm / disinterest in last 2 weeks-2.0",
- "Work/job satisfaction-2.0",
- "Family relationship satisfaction-2.0",
- "Frequency of tenseness / restlessness in last 2 weeks-2.0",
- "Miserableness-2.0",
- "Ever highly irritable/argumentative for 2 days-2.0",
- "Ever depressed for a whole week-2.0",
- "Ever unenthusiastic/disinterested for a whole week-2.0",
- "Seen a psychiatrist for nerves, anxiety, tension or depression-2.0",
- "Fed-up feelings-2.0",
- "Friendships satisfaction-2.0",
- "Illness, injury, bereavement, stress in last 2 years-2.0",
- "Worrier / anxious feelings-2.0",
- "Financial situation satisfaction-2.0",
- "Health satisfaction-2.0",
- "Frequency of tiredness / lethargy in last 2 weeks-2.0",
- "Nervous feelings-2.0",
- "Irritability-2.0",
- "Tense / 'highly strung'-2.0",
- "Able to pay rent/mortgage as an adult-0.0",
- "Sexual interference by partner or ex-partner without consent as an adult-0.0",
- "Recent worrying too much about different things-0.0",
- "Belittlement by partner or ex-partner as an adult-0.0",
- "Ever taken cannabis-0.0",
- "Physical violence by partner or ex-partner as an adult-0.0",
- "Been in a confiding relationship as an adult-0.0",
- "Recent feelings of tiredness or low energy-0.0",
- "Recent changes in speed/amount of moving or speaking-0.0",
- "Ever worried more than most people would in similar situation-0.0",
- "Diagnosed with life-threatening illness-0.0",
- "Victim of physically violent crime-0.0",
- "Witnessed sudden violent death-0.0",
- "Victim of sexual assault-0.0",
- "Trouble falling or staying asleep, or sleeping too much-0.0",
- "Ever felt worried, tense, or anxious for most of a month or longer-0.0",
- "Frequency of drinking alcohol-0.0",
- "Ever been injured or injured someone else through drinking alcohol-0.0",
- "Ever had known person concerned about, or recommend reduction of, alcohol consumption-0.0",
- "Ever addicted to any substance or behaviour-0.0",
- "Been involved in combat or exposed to war-zone-0.0",
- "Recent restlessness-0.0",
- "Been in serious accident believed to be life-threatening-0.0",
- "Recent lack of interest or pleasure in doing things-0.0",
- "Sexually molested as a child-0.0",
- "Physically abused by family as a child-0.0",
- "Felt hated by family member as a child-0.0",
- "Ever contemplated self-harm-0.0",
- "Ever had prolonged feelings of sadness or depression-0.0",
- "Ever self-harmed-0.0",
- "Someone to take to doctor when needed as a child-0.0",
- "Ever thought that life not worth living-0.0",
- "Recent trouble relaxing-0.0",
- "Ever believed in an un-real conspiracy against self-0.0",
- "Ever heard an un-real voice-0.0",
- "Belief that own life is meaningful-0.0",
- "General happiness with own health-0.0",
- "General happiness-0.0",
- "Ever believed in un-real communications or signs-0.0",
- "Ever had prolonged loss of interest in normal activities-0.0",
- "Ever seen an un-real vision-0.0",
- "Repeated disturbing thoughts of stressful experience in past month-0.0",
- "Recent thoughts of suicide or self-harm-0.0",
- "Recent feelings of foreboding-0.0",
- "Recent poor appetite or overeating-0.0",
- "Recent feelings of depression-0.0",
- "Avoided activities or situations because of previous stressful experience in past month-0.0",
- "Recent inability to stop or control worrying-0.0",
- "Recent trouble concentrating on things-0.0",
- "Recent feelings of inadequacy-0.0",
- "Recent feelings or nervousness or anxiety-0.0",
- "Felt loved as a child-0.0",
- "Felt very upset when reminded of stressful experience in past month-0.0",
- "Ever sought or received professional help for mental distress-0.0",
- "Ever had period of mania / excitability-0.0",
- "Ever had period extreme irritability-0.0",
- "Recent easy annoyance or irritability-0.0",
- "Ever suffered mental distress preventing usual activities-0.0"], axis=0).reset_index(drop=True)
- mh_diagnoses_drop_na.to_csv('/UK_BB/mental_health/mh_diagnoses_drop_na.csv', index=False)
- # %% [markdown]
- # ## Extract diagnoses
- # %%
- targets = pd.read_csv('/UK_BB/cognitive/target.csv')
- mh = pd.merge(mh_diagnoses_drop_na, targets['eid'], on = 'eid')
- mh.to_csv('/UK_BB/mental_health/mh_instance2_online_matched_to_targets.csv', index=False)
- # %%
- mh = pd.read_csv('/Cog-Ment/CSVs/2024/mental_health/mh_instance2_online_matched_to_targets.csv')
- # %%
- # Extract and combine noncncer diagnoses
- mh_diagnoses = mh.copy()
- # Set a 'noncaner' column: Filter columns that start with 'Non-cancer illness code, self-reported'
- noncancer_cols = mh_diagnoses.filter(like='Non-cancer illness code, self-reported-').columns
- # Concatenate the values in the columns into a single string, separated by ';'
- mh_diagnoses["noncancer"] = mh_diagnoses[noncancer_cols].astype(str).apply(lambda x: x.str.cat(sep=";"), axis=1)
- # Extract diagnoses
- mh_diagnoses["Epilepsy"] = mh_diagnoses["noncancer"].str.contains("1264").astype(int)
- mh_diagnoses["Migraine"] = mh_diagnoses["noncancer"].str.contains("1265").astype(int)
- mh_diagnoses["Depression"] = mh_diagnoses["noncancer"].str.contains("1286").astype(int)
- mh_diagnoses["Anxiety/panic attacks"] = mh_diagnoses["noncancer"].str.contains("1287").astype(int)
- mh_diagnoses["Chronic/degenerative neurological problem & other neurological problem"] = mh_diagnoses["noncancer"].str.contains("|".join(["1258","1434"])).astype(int)
- mh_diagnoses["Head & spinal & peripheral nerve injury, Spinal cord & peripheral nerve disorder & cranial nerve problem/palsy & infection of NS & Cerebral palsy"] = mh_diagnoses["noncancer"].str.contains("|".join(["1254",
- "1251","1249","1244", "1433", "1267","1394","1266"])).astype(int)
- mh_diagnoses["Nervous breakdown, Schizophrenia, self-harm/suicide attempt, mania/bipolar, alcohol/substance abuse/dependency, PTSD, eating disorder, OCD"] = mh_diagnoses["noncancer"].str.contains("|".join(["1289","1288","1289",
- "1290","1291","1408", "1410", "1409", "1469", "1470", "1615"])).astype(int)
- mh_diagnoses["Stress, insomnia"] = mh_diagnoses["noncancer"].str.contains("|".join(["1614", "1616"])).astype(int)
- # Merge them into bigger groups
- mh_diagnoses["Neurological problem, NS injury, epilepsy"] = mh_diagnoses[["Epilepsy", "Head & spinal & peripheral nerve injury, Spinal cord & peripheral nerve disorder & cranial nerve problem/palsy & infection of NS & Cerebral palsy", "Chronic/degenerative neurological problem & other neurological problem"]].any(axis=1).astype(int) #.sum(axis=1).astype(int)
- mh_diagnoses["Stress, insomnia, migraine, nervous/mental problems"] = mh_diagnoses[["Stress, insomnia", "Migraine", "Nervous breakdown, Schizophrenia, self-harm/suicide attempt, mania/bipolar, alcohol/substance abuse/dependency, PTSD, eating disorder, OCD"]].any(axis=1).astype(int)
- # Drop 'Non-cancer illness' and other columns
- mh_diagnoses = mh_diagnoses.drop(columns=[col for col in mh_diagnoses.columns if 'Non-cancer illness' in col])
- mh_diagnoses = mh_diagnoses.drop(columns=["Epilepsy", "Head & spinal & peripheral nerve injury, Spinal cord & peripheral nerve disorder & cranial nerve problem/palsy & infection of NS & Cerebral palsy", "Chronic/degenerative neurological problem & other neurological problem"])
- mh_diagnoses = mh_diagnoses.drop(columns=["Stress, insomnia", "Migraine", "Nervous breakdown, Schizophrenia, self-harm/suicide attempt, mania/bipolar, alcohol/substance abuse/dependency, PTSD, eating disorder, OCD"])
- mh_diagnoses.to_csv('/UK_BB/mental_health/mh_noncancer_diagnoses.csv', index=False)
- # %%
- mh = mh_diagnoses.copy()
- # %% [markdown]
- # ## PHQ9
- # %%
- # PHQ9
- # Calculate the score ingonoring -818
- # PHQ: 20514, 20510, 20517, 20519, 20511, 20507, 20508, 20518, 20513: sum and subtract 9 to get the score
- # Recent lack of interest or pleasure in doing things-0.0
- # Recent feelings of depression
- # Trouble falling or staying asleep, or sleeping too much
- # Recent feelings of tiredness or low energy
- # Recent poor appetite or overeating
- # Recent feelings of inadequacy
- # Recent trouble concentrating on things
- # Recent changes in speed/amount of moving or speaking
- # Recent thoughts of suicide or self-harm
- # -818 Prefer not to answer
- # 1 Not at all
- # 2 Several days
- # 3 More than half the days
- # 4 Nearly every day
- # Replace -818 with 1 only for PHQ!
- mh[["Recent lack of interest or pleasure in doing things-0.0", "Recent feelings of depression-0.0", "Trouble falling or staying asleep, or sleeping too much-0.0",
- "Recent feelings of tiredness or low energy-0.0", "Recent poor appetite or overeating-0.0", "Recent feelings of inadequacy-0.0",
- "Recent trouble concentrating on things-0.0", "Recent changes in speed/amount of moving or speaking-0.0", "Recent thoughts of suicide or self-harm-0.0"]] = mh[["Recent lack of interest or pleasure in doing things-0.0", "Recent feelings of depression-0.0", "Trouble falling or staying asleep, or sleeping too much-0.0",
- "Recent feelings of tiredness or low energy-0.0", "Recent poor appetite or overeating-0.0", "Recent feelings of inadequacy-0.0",
- "Recent trouble concentrating on things-0.0", "Recent changes in speed/amount of moving or speaking-0.0", "Recent thoughts of suicide or self-harm-0.0"]].replace({-818: 1})
- # Check if replaced correctly
- print((mh[["Recent lack of interest or pleasure in doing things-0.0", "Recent feelings of depression-0.0", "Trouble falling or staying asleep, or sleeping too much-0.0",
- "Recent feelings of tiredness or low energy-0.0", "Recent poor appetite or overeating-0.0", "Recent feelings of inadequacy-0.0",
- "Recent trouble concentrating on things-0.0", "Recent changes in speed/amount of moving or speaking-0.0", "Recent thoughts of suicide or self-harm-0.0"]] == -818).sum())
- mh[["Recent lack of interest or pleasure in doing things-0.0", "Recent feelings of depression-0.0", "Trouble falling or staying asleep, or sleeping too much-0.0",
- "Recent feelings of tiredness or low energy-0.0", "Recent poor appetite or overeating-0.0", "Recent feelings of inadequacy-0.0",
- "Recent trouble concentrating on things-0.0", "Recent changes in speed/amount of moving or speaking-0.0", "Recent thoughts of suicide or self-harm-0.0"]].min()
- # %%
- # Calculate PHQ9 for after replacing -818 with 1
- mh["PHQ9"] = mh[[
- "Recent lack of interest or pleasure in doing things-0.0",
- "Recent feelings of depression-0.0",
- "Trouble falling or staying asleep, or sleeping too much-0.0",
- "Recent feelings of tiredness or low energy-0.0",
- "Recent poor appetite or overeating-0.0",
- "Recent feelings of inadequacy-0.0",
- "Recent trouble concentrating on things-0.0",
- "Recent changes in speed/amount of moving or speaking-0.0",
- "Recent thoughts of suicide or self-harm-0.0"
- ]].sum(axis=1, skipna=True).astype(int)
- # Standardize PHQ to 0-27
- mh["PHQ9"] = mh["PHQ9"].subtract(9)
- print('PHQ9 MIN:', mh["PHQ9"].min())
- print('PHQ9 MAX:', mh["PHQ9"].max())
- # %% [markdown]
- # ## Depression ever
- # %% [markdown]
- # At least one core symptom of depression, most or all of the day on most or all days for a two week period, with at least five depressive symptoms that represent a change from usual occurring over the same time-scale, with some or a lot of impairment.
- #
- # - Persistent sadness (20446) = Yes OR Loss of interest (20441) = Yes - CORE
- # - AND How much of day (20436) = Most of day or All day long
- # - AND Did you feel this way (20439) = Almost every day or Every day
- # - AND Impairment (20440) = Somewhat or A lot
- # - AND Total number of symptoms endorsed (core and others) >= 5:
- #
- # - Persistent sadness (core) 20446; Loss of interest (core) 20441; PLUS
- # - Tired or low energy 20449;
- # - Gain or loss of weight 20536 = Gain, Loss or Gain and loss;
- # - Sleep change 20532;
- # - Trouble concentrating 20435;
- # - Feeling worthless 20450;
- # - Thinking about death 20437
- # %%
- depr_ever_scores = []
- # Loop through each participant's variables
- for i in range(len(mh)):
- if (mh['Ever had prolonged feelings of sadness or depression-0.0'].iloc[i] > 0 or mh['Ever had prolonged loss of interest in normal activities-0.0'].iloc[i] > 0) and mh['Fraction of day affected during worst episode of depression-0.0'].iloc[i] > 2 and mh['Frequency of depressed days during worst episode of depression-0.0'].iloc[i] > 1 and mh['Impact on normal roles during worst period of depression-0.0'].iloc[i] > 1:
- num_symptoms = sum(j > 0 for j in [
- mh['Feelings of tiredness during worst episode of depression-0.0'].iloc[i],
- mh['Weight change during worst episode of depression-0.0'].iloc[i],
- mh['Did your sleep change?-0.0'].iloc[i],
- mh['Difficulty concentrating during worst depression-0.0'].iloc[i],
- mh['Feelings of worthlessness during worst period of depression-0.0'].iloc[i],
- mh['Thoughts of death during worst depression-0.0'].iloc[i],
- mh['Ever had prolonged feelings of sadness or depression-0.0'].iloc[i],
- mh['Ever had prolonged loss of interest in normal activities-0.0'].iloc[i]
- ])
- if num_symptoms >= 5:
- depr_ever_score = 1
- else:
- depr_ever_score = 0
- else:
- depr_ever_score = 0
- depr_ever_scores.append(depr_ever_score)
- mh = mh.assign(Depression_ever=depr_ever_scores)
- # %% [markdown]
- # ## Subthreshol depression
- # %%
- # Replace non-responders
- print(mh["Ever had prolonged feelings of sadness or depression-0.0"].median())
- mh["Ever had prolonged feelings of sadness or depression-0.0"] = mh["Ever had prolonged feelings of sadness or depression-0.0"].replace({-818:1, -121:1})
- # %%
- depr_sub_scores = []
- for i in range(len(mh)):
- diagnosed_with_depression = any(mh[f'Mental health problems ever diagnosed by a professional-0.{j}'].iloc[i] == 11 for j in range(1, 17))
- if mh['Depression_ever'].iloc[i] == 0 and (diagnosed_with_depression or mh['Depression'].iloc[i] == 1 or mh['Ever had prolonged feelings of sadness or depression-0.0'].iloc[i] > 0 or mh['Ever had prolonged loss of interest in normal activities-0.0'].iloc[i] > 0 or mh['PHQ9'].iloc[i] > 5):
- depr_sub_score = 1
- else:
- depr_sub_score = 0
- depr_sub_scores.append(depr_sub_score)
- mh = mh.assign(Depression_subthreshold=depr_sub_scores)
- # %% [markdown]
- # ## Bipolar I
- # %%
- bipolar_1_scores = []
- for i in range(len(mh)):
- if mh['Depression_ever'].iloc[i] == 1 and (mh['Ever had period of mania / excitability-0.0'].iloc[i] > 0 or mh['Ever had period extreme irritability-0.0'].iloc[i] > 0) and mh['Longest period of mania or irritability-0.0'].iloc[i] == 3 and mh['Severity of problems due to mania or irritability-0.0'].iloc[i] == 1:
- num_symptoms = sum(j > 0 for j in [
- mh['Manifestations of mania or irritability-0.1'].iloc[i], mh['Manifestations of mania or irritability-0.2'].iloc[i],
- mh['Manifestations of mania or irritability-0.3'].iloc[i], mh['Manifestations of mania or irritability-0.4'].iloc[i],
- mh['Manifestations of mania or irritability-0.5'].iloc[i], mh['Manifestations of mania or irritability-0.6'].iloc[i],
- mh['Manifestations of mania or irritability-0.7'].iloc[i], mh['Manifestations of mania or irritability-0.8'].iloc[i]])
- if (mh['Ever had period of mania / excitability-0.0'].iloc[i] == 0 and num_symptoms >= 4) or (mh['Ever had period of mania / excitability-0.0'].iloc[i] == 1 and num_symptoms >= 3):
- bipolar_1_score = 1
- else:
- bipolar_1_score = 0
- else:
- bipolar_1_score = 0
- bipolar_1_scores.append(bipolar_1_score)
- mh = mh.assign(Bipolar_1=bipolar_1_scores)
- # %% [markdown]
- # ## Bipolar II
- # %%
- bipolar_2_scores = []
- for i in range(len(mh)):
- if mh['Depression_ever'].iloc[i] == 1 and (mh['Ever had period of mania / excitability-0.0'].iloc[i] > 0 or mh['Ever had period extreme irritability-0.0'].iloc[i] > 0) and mh['Longest period of mania or irritability-0.0'].iloc[i] == 3:
- num_symptoms = sum(j > 0 for j in [
- mh['Manifestations of mania or irritability-0.1'].iloc[i], mh['Manifestations of mania or irritability-0.2'].iloc[i],
- mh['Manifestations of mania or irritability-0.3'].iloc[i], mh['Manifestations of mania or irritability-0.4'].iloc[i],
- mh['Manifestations of mania or irritability-0.5'].iloc[i], mh['Manifestations of mania or irritability-0.6'].iloc[i],
- mh['Manifestations of mania or irritability-0.7'].iloc[i], mh['Manifestations of mania or irritability-0.8'].iloc[i]])
- if (mh['Ever had period of mania / excitability-0.0'].iloc[i] == 0 and num_symptoms >= 4) or (mh['Ever had period of mania / excitability-0.0'].iloc[i] == 1 and num_symptoms >= 3):
- bipolar_2_score = 1
- else:
- bipolar_2_score = 0
- else:
- bipolar_2_score = 0
- bipolar_2_scores.append(bipolar_2_score)
- mh = mh.assign(Bipolar_2=bipolar_2_scores)
- # %% [markdown]
- # ## Depression single episode
- # %%
- depression_single = [1 if (mh['Depression_ever'].iloc[i] == 1 and mh['Bipolar_1'].iloc[i] == 0 and mh['Lifetime number of depressed periods-0.0'].iloc[i] == 1) else 0 for i in range(len(mh))]
- mh = mh.assign(Depression_single=depression_single)
- # %% [markdown]
- # ## Recurrent depression
- # %%
- depression_recurrent= [1 if (mh['Depression_ever'].iloc[i] == 1 and mh['Bipolar_1'].iloc[i] == 0 and (mh['Lifetime number of depressed periods-0.0'].iloc[i] > 1 or mh['Lifetime number of depressed periods-0.0'].iloc[i] == -999)) else 0 for i in range(len(mh))]
- mh = mh.assign(Depression_recurrent=depression_recurrent)
- # %% [markdown]
- # ## Depression single episode triggered by loss
- # %%
- depression_by_loss= [1 if (mh['Depression_single'].iloc[i] == 1 and mh['Depression possibly related to stressful or traumatic event-0.0'].iloc[i] == 1) else 0 for i in range(len(mh))]
- mh = mh.assign(Depression_triggered_by_loss=depression_by_loss)
- # %% [markdown]
- # ## Current depression
- # %%
- depr_current = []
- for i in range(len(mh)):
- if mh['Depression_ever'].iloc[i] == 1:
- num_sumptoms_main = sum(1 for j in [
- mh['Recent lack of interest or pleasure in doing things-0.0'].iloc[i],
- mh['Recent feelings of depression-0.0'].iloc[i],
- mh['Trouble falling or staying asleep, or sleeping too much-0.0'].iloc[i],
- mh['Recent feelings of tiredness or low energy-0.0'].iloc[i],
- mh['Recent poor appetite or overeating-0.0'].iloc[i],
- mh['Recent feelings of inadequacy-0.0'].iloc[i],
- mh['Recent trouble concentrating on things-0.0'].iloc[i],
- mh['Recent changes in speed/amount of moving or speaking-0.0'].iloc[i]
- ] if j > 2)
- num_sumptoms_sui = sum(1 for m in [mh['Recent thoughts of suicide or self-harm-0.0'].iloc[i]] if m > 1)
- num_symptoms_all = num_sumptoms_main + num_sumptoms_sui
- if num_symptoms_all >= 5:
- deprcurr_score = 1
- else:
- deprcurr_score = 0
- else:
- deprcurr_score = 0
- depr_current.append(deprcurr_score)
- mh = mh.assign(Depression_current=depr_current)
- # %% [markdown]
- # ## Current severe depression
- # %%
- depr_current_severe = [1 if (mh['Depression_current'].iloc[i] == 1 and mh['PHQ9'].iloc[i] > 15) else 0 for i in range(len(mh))]
- mh = mh.assign(Depression_current_severe=depr_current_severe)
- # %% [markdown]
- # ## Mania
- # %%
- mania_scores = []
- for i in range(len(mh)):
- if (mh['Ever had period of mania / excitability-0.0'].iloc[i] == 1 or mh['Ever had period extreme irritability-0.0'].iloc[i] == 1) and mh['Longest period of mania or irritability-0.0'].iloc[i] == 3:
- num_symptoms = sum(j > 0 for j in [
- mh['Manifestations of mania or irritability-0.1'].iloc[i], mh['Manifestations of mania or irritability-0.2'].iloc[i],
- mh['Manifestations of mania or irritability-0.3'].iloc[i], mh['Manifestations of mania or irritability-0.4'].iloc[i],
- mh['Manifestations of mania or irritability-0.5'].iloc[i], mh['Manifestations of mania or irritability-0.6'].iloc[i],
- mh['Manifestations of mania or irritability-0.7'].iloc[i], mh['Manifestations of mania or irritability-0.8'].iloc[i]])
- if (mh['Ever had period of mania / excitability-0.0'].iloc[i] == 1 and num_symptoms >= 3) or (mh['Ever had period of mania / excitability-0.0'].iloc[i] == 0 and num_symptoms >= 4):
- mania_score = 1
- else:
- mania_score = 0
- else:
- mania_score = 0
- mania_scores.append(mania_score)
- mh = mh.assign(Mania=bipolar_1_scores)
- # %%
- # Replace non-respondes with median
- mh[["Ever had prolonged loss of interest in normal activities-0.0", "Ever had period extreme irritability-0.0",
- "Ever had period of mania / excitability-0.0", "Ever felt worried, tense, or anxious for most of a month or longer-0.0",
- "Ever worried more than most people would in similar situation-0.0", "Ever taken cannabis-0.0", "Ever had prolonged feelings of sadness or depression-0.0"]].median()
- mh[["Ever had prolonged loss of interest in normal activities-0.0", "Ever had period extreme irritability-0.0",
- "Ever had period of mania / excitability-0.0", "Ever felt worried, tense, or anxious for most of a month or longer-0.0",
- "Ever worried more than most people would in similar situation-0.0", "Ever taken cannabis-0.0"]] = mh[[
- "Ever had prolonged loss of interest in normal activities-0.0", "Ever had period extreme irritability-0.0",
- "Ever had period of mania / excitability-0.0", "Ever felt worried, tense, or anxious for most of a month or longer-0.0",
- "Ever worried more than most people would in similar situation-0.0", "Ever taken cannabis-0.0"]].replace({-818:0, -121:0})
- # %% [markdown]
- # ## GAD-7 Score
- # %%
- print(mh[["Recent feelings or nervousness or anxiety-0.0", "Recent inability to stop or control worrying-0.0",
- "Recent worrying too much about different things-0.0", "Recent trouble relaxing-0.0", "Recent restlessness-0.0",
- "Recent easy annoyance or irritability-0.0", "Recent feelings of foreboding-0.0"]].median())
- mh[["Recent feelings or nervousness or anxiety-0.0", "Recent inability to stop or control worrying-0.0",
- "Recent worrying too much about different things-0.0", "Recent trouble relaxing-0.0", "Recent restlessness-0.0",
- "Recent easy annoyance or irritability-0.0", "Recent feelings of foreboding-0.0"]] = mh[["Recent feelings or nervousness or anxiety-0.0", "Recent inability to stop or control worrying-0.0",
- "Recent worrying too much about different things-0.0", "Recent trouble relaxing-0.0", "Recent restlessness-0.0",
- "Recent easy annoyance or irritability-0.0", "Recent feelings of foreboding-0.0"]].replace({-818: 1})
- mh["GAD7"] = mh[["Recent feelings or nervousness or anxiety-0.0", "Recent inability to stop or control worrying-0.0",
- "Recent worrying too much about different things-0.0", "Recent trouble relaxing-0.0", "Recent restlessness-0.0",
- "Recent easy annoyance or irritability-0.0", "Recent feelings of foreboding-0.0"]].sum(axis=1).astype(int).subtract(7)
- print('GAD7 MIN',mh["GAD7"].min())
- print('GAD7 MAX',mh["GAD7"].max())
- # %% [markdown]
- # ## GAD ever
- # %%
- gad_ever_scores = []
- for i in range(len(mh)):
- worried_tense = mh['Ever felt worried, tense, or anxious for most of a month or longer-0.0'].iloc[i] # yes == 1
- duration = mh['Longest period spent worried or anxious-0.0'].iloc[i] # >=6 / == -999
- most_days = mh['Worried most days during period of worst anxiety-0.0'].iloc[i] #yes == 1
- more_than_most = mh['Ever worried more than most people would in similar situation-0.0'].iloc[i]
- stronger_than_most = mh['Stronger worrying (than other people) during period of worst anxiety-0.0'].iloc[i] #yes == 1
- more_than_one = mh['Number of things worried about during worst period of anxiety-0.0'].iloc[i] # >1 (2More than one thing)
- diff_worries = mh['Multiple worries during worst period of anxiety-0.0'].iloc[i] #yes == 1
- diff_stop = mh['Difficulty stopping worrying during worst period of anxiety-0.0'].iloc[i] #yes == 1
- freq_stop= mh['Frequency of inability to stop worrying during worst period of anxiety-0.0'].iloc[i] #often
- freq_control = mh['Frequency of difficulty controlling worry during worst period of anxiety-0.0'].iloc[i] #often
- interference = mh['Impact on normal roles during worst period of anxiety-0.0'].iloc[i] # Some or A lot
- if worried_tense == 1 and (duration >= 6 or duration == -999) and most_days ==1 and (more_than_most == 1 or stronger_than_most == 1) and (more_than_one == 2 or diff_worries == 1) and (diff_stop==1 or freq_stop==3 or freq_control==3) and interference > 1:
- num_symptoms = sum(g > 0 for g in [
- mh['Restless during period of worst anxiety-0.0'].iloc[i],
- mh['Keyed up or on edge during worst period of anxiety-0.0'].iloc[i],
- mh['Easily tired during worst period of anxiety-0.0'].iloc[i],
- mh['Difficulty concentrating during worst period of anxiety-0.0'].iloc[i],
- mh['More irritable than usual during worst period of anxiety-0.0'].iloc[i],
- mh['Tense, sore, or aching muscles during worst period of anxiety-0.0'].iloc[i],
- mh['Frequent trouble falling or staying asleep during worst period of anxiety-0.0'].iloc[i]
- ])
- if num_symptoms >= 3:
- gad_ever_score = 1
- else:
- gad_ever_score = 0
- else:
- gad_ever_score = 0
- gad_ever_scores.append(gad_ever_score)
- mh = mh.assign(GAD_ever = gad_ever_scores)
- # %% [markdown]
- # ## Current anxiety
- # %%
- gad_current = [1 if (mh['GAD_ever'].iloc[i] == 1 and mh['GAD7'].iloc[i] >= 10) else 0 for i in range(len(mh))]
- mh = mh.assign(GAD_current = gad_current)
- # %% [markdown]
- # ## Current mild anxiety
- # %%
- gad_current_mild = [1 if (mh['GAD_ever'].iloc[i] == 1 and mh['GAD7'].iloc[i] >= 5 and mh['GAD7'].iloc[i] < 10) else 0 for i in range(len(mh))] # [5,10)
- mh = mh.assign(GAD_current_mild = gad_current_mild)
- # %% [markdown]
- # ## Current moderate anxiety
- # %%
- gad_current_moderate = [1 if (mh['GAD_ever'].iloc[i] == 1 and mh['GAD7'].iloc[i] >= 10 and mh['GAD7'].iloc[i] < 15) else 0 for i in range(len(mh))] # [10,15)
- mh = mh.assign(GAD_current_moderate = gad_current_moderate)
- # %% [markdown]
- # ## Current severe anxiety
- # %%
- gad_current_severe = [1 if (mh['GAD_ever'].iloc[i] == 1 and mh['GAD7'].iloc[i] >= 15) else 0 for i in range(len(mh))]# [15]
- mh = mh.assign(GAD_current_severe = gad_current_severe)
- # %% [markdown]
- # ## PCL
- # %% [markdown]
- # Sum of scores on questions representing the core symptoms of PTSD (subtract 5 to adjust)
- #
- #
- # Score 1-5 and sum
- # - 20497 Repeated disturbing thoughts of stressful experience in past month
- # - 20498 Felt very upset when reminded of stressful experience in past month
- # - 20495 Avoided activities or situations because of previous stressful experience in past month
- # - 20496 Felt distant from other people in past month
- # - 20494 Felt irritable or had angry outbursts in past month
- #
- #
- # -818 Prefer not to answer / 0 Not at all / 1 A little bit / 2 Moderately / 3 Quite a bit / 4 Extremely
- #
- # - 20508 Trouble concentrating (scored 1-4)
- #
- # -818 Prefer not to answer / 1 Not at all / 2 Several days / 3 More than half the days / 4 Nearly every day
- #
- #
- # Sum {
- # - 20497 Repeated disturbing thoughts of stressful experience in past month,
- # - 20498 Felt very upset when reminded of stressful experience in past month,
- # - 20495 Avoided activities or situations because of previous stressful experience in past month,
- # - 20496 Felt distant from other people in past month,
- # - 20494 Felt irritable or had angry outbursts in past month}
- #
- # - initially scored 0 to 4, replace -818 with 0 (median)
- #
- # - -818 Prefer not to answer / 1 Not at all / 2 Several days / 3 More than half the days / 4 Nearly every day
- #
- # - {20508 Trouble concentrating}
- # - scored 1,2,3,4
- # %%
- # PCL6
- # Medians
- print(mh[['Repeated disturbing thoughts of stressful experience in past month-0.0', 'Felt very upset when reminded of stressful experience in past month-0.0',
- 'Avoided activities or situations because of previous stressful experience in past month-0.0', 'Felt distant from other people in past month-0.0',
- 'Felt irritable or had angry outbursts in past month-0.0']].median())
- print(mh["Recent trouble concentrating on things-0.0"].median())
- mh[['Repeated disturbing thoughts of stressful experience in past month-0.0',
- 'Felt very upset when reminded of stressful experience in past month-0.0',
- 'Avoided activities or situations because of previous stressful experience in past month-0.0',
- 'Felt distant from other people in past month-0.0',
- 'Felt irritable or had angry outbursts in past month-0.0']] = mh[['Repeated disturbing thoughts of stressful experience in past month-0.0',
- 'Felt very upset when reminded of stressful experience in past month-0.0',
- 'Avoided activities or situations because of previous stressful experience in past month-0.0', 'Felt distant from other people in past month-0.0',
- 'Felt irritable or had angry outbursts in past month-0.0']].replace({-818: 0})
- mh["Recent trouble concentrating on things-0.0"] = mh["Recent trouble concentrating on things-0.0"].replace(-818,1)
- mh["PCL5"] = mh[['Repeated disturbing thoughts of stressful experience in past month-0.0', 'Felt very upset when reminded of stressful experience in past month-0.0',
- 'Avoided activities or situations because of previous stressful experience in past month-0.0', 'Felt distant from other people in past month-0.0',
- 'Felt irritable or had angry outbursts in past month-0.0']].sum(axis=1).astype(int)
- mh["PCL5"] = mh["PCL5"].add(5)
- # Calculate PCL6
- mh["PCL6"] = mh[['PCL5', 'Recent trouble concentrating on things-0.0']].sum(axis=1).astype(int)
- print('PCL6 MIN', mh["PCL6"].min())
- print('PCL6 MAX', mh["PCL6"].max())
- # %% [markdown]
- # ## PTSD
- # %%
- mh["PTSD"] = [1 if (mh["PCL6"].iloc[i] >=14) else 0 for i in range(len(mh))]
- mh = mh.rename(columns={'Self-harm: Life not worth living': 'Self-harm: Ever thought life not worth living', 'Ever thought that life not worth living': 'Frequency of "life not worth living" thoughts'})
- # %% [markdown]
- # ## AUDIT
- # %% [markdown]
- # AUDIT total score was created by taking the sum of items 1–10 for all participants, including those who endorsed currently never drinking alcohol (as they could still endorse past alcohol harm on items 9 and 10). We also created AUDIT subdomain scores by aggregating the scores from items 1–3, which include the information pertaining to alcohol consumption (AUDIT-C, N = 121,604), and from items 4–10, which indexes the information pertaining to alcohol problems (AUDIT-P, N = 121,604).
- # %%
- # Replace -818 with median
- # scored 0 to 4
- mh["Frequency of drinking alcohol-0.0"] = mh["Frequency of drinking alcohol-0.0"].replace(-818, mh["Frequency of drinking alcohol-0.0"].median())
- # scored 1 to 5 / 0-2
- columns_to_replace = [
- 'Amount of alcohol drunk on a typical drinking day-0.0',
- 'Frequency of consuming six or more units of alcohol-0.0',
- 'Frequency of inability to cease drinking in last year-0.0',
- 'Frequency of failure to fulfil normal expectations due to drinking alcohol in last year-0.0',
- 'Frequency of needing morning drink of alcohol after heavy drinking session in last year-0.0',
- 'Frequency of feeling guilt or remorse after drinking alcohol in last year-0.0',
- 'Frequency of memory loss due to drinking alcohol in last year-0.0',
- 'Ever been injured or injured someone else through drinking alcohol-0.0',
- 'Ever had known person concerned about, or recommend reduction of, alcohol consumption-0.0'
- ]
- for column in columns_to_replace:
- column_median = mh[column].median()
- mh[column] = mh[column].replace(-818, column_median)
- mh[[
- 'Amount of alcohol drunk on a typical drinking day-0.0',
- 'Frequency of consuming six or more units of alcohol-0.0',
- 'Frequency of inability to cease drinking in last year-0.0',
- 'Frequency of failure to fulfil normal expectations due to drinking alcohol in last year-0.0',
- 'Frequency of needing morning drink of alcohol after heavy drinking session in last year-0.0',
- 'Frequency of feeling guilt or remorse after drinking alcohol in last year-0.0',
- 'Frequency of memory loss due to drinking alcohol in last year-0.0',
- 'Ever been injured or injured someone else through drinking alcohol-0.0',
- 'Ever had known person concerned about, or recommend reduction of, alcohol consumption-0.0'
- ]].min()
- # %%
- # Recode 0,1,2 to 0,2,4
- mh[[
- "Ever been injured or injured someone else through drinking alcohol-0.0",
- "Ever had known person concerned about, or recommend reduction of, alcohol consumption-0.0"]] = mh[[
- "Ever been injured or injured someone else through drinking alcohol-0.0",
- "Ever had known person concerned about, or recommend reduction of, alcohol consumption-0.0"]].replace(1, 2)
- mh[[
- "Ever been injured or injured someone else through drinking alcohol-0.0",
- "Ever had known person concerned about, or recommend reduction of, alcohol consumption-0.0"]] = mh[[
- "Ever been injured or injured someone else through drinking alcohol-0.0",
- "Ever had known person concerned about, or recommend reduction of, alcohol consumption-0.0"]].replace(2, 4)
- # %%
- # Replace NaN with 0
- mh[['Amount of alcohol drunk on a typical drinking day-0.0',
- 'Frequency of consuming six or more units of alcohol-0.0',
- 'Frequency of inability to cease drinking in last year-0.0',
- 'Frequency of failure to fulfil normal expectations due to drinking alcohol in last year-0.0',
- 'Frequency of needing morning drink of alcohol after heavy drinking session in last year-0.0',
- 'Frequency of feeling guilt or remorse after drinking alcohol in last year-0.0',
- 'Frequency of memory loss due to drinking alcohol in last year-0.0']] = mh[['Amount of alcohol drunk on a typical drinking day-0.0',
- 'Frequency of consuming six or more units of alcohol-0.0',
- 'Frequency of inability to cease drinking in last year-0.0',
- 'Frequency of failure to fulfil normal expectations due to drinking alcohol in last year-0.0',
- 'Frequency of needing morning drink of alcohol after heavy drinking session in last year-0.0',
- 'Frequency of feeling guilt or remorse after drinking alcohol in last year-0.0',
- 'Frequency of memory loss due to drinking alcohol in last year-0.0']].replace(np.nan, 0)
- mh[mh["Frequency of drinking alcohol-0.0"] == 0][[
- 'Amount of alcohol drunk on a typical drinking day-0.0',
- 'Frequency of consuming six or more units of alcohol-0.0',
- 'Frequency of inability to cease drinking in last year-0.0',
- 'Frequency of failure to fulfil normal expectations due to drinking alcohol in last year-0.0',
- 'Frequency of needing morning drink of alcohol after heavy drinking session in last year-0.0',
- 'Frequency of feeling guilt or remorse after drinking alcohol in last year-0.0',
- 'Frequency of memory loss due to drinking alcohol in last year-0.0'
- ]].isna().sum()
- # %%
- # Recode 1-5 to 0-4
- mh[['Amount of alcohol drunk on a typical drinking day-0.0',
- 'Frequency of consuming six or more units of alcohol-0.0',
- 'Frequency of inability to cease drinking in last year-0.0',
- 'Frequency of failure to fulfil normal expectations due to drinking alcohol in last year-0.0',
- 'Frequency of needing morning drink of alcohol after heavy drinking session in last year-0.0',
- 'Frequency of feeling guilt or remorse after drinking alcohol in last year-0.0',
- 'Frequency of memory loss due to drinking alcohol in last year-0.0']] = mh[['Amount of alcohol drunk on a typical drinking day-0.0',
- 'Frequency of consuming six or more units of alcohol-0.0',
- 'Frequency of inability to cease drinking in last year-0.0',
- 'Frequency of failure to fulfil normal expectations due to drinking alcohol in last year-0.0',
- 'Frequency of needing morning drink of alcohol after heavy drinking session in last year-0.0',
- 'Frequency of feeling guilt or remorse after drinking alcohol in last year-0.0',
- 'Frequency of memory loss due to drinking alcohol in last year-0.0']].replace({1:0, 2:1, 3:2, 4:3, 5:4})
- # %%
- # AUDIT
- mh["AUDIT"] = mh[["Frequency of drinking alcohol-0.0",
- 'Amount of alcohol drunk on a typical drinking day-0.0',
- 'Frequency of consuming six or more units of alcohol-0.0',
- 'Frequency of inability to cease drinking in last year-0.0',
- 'Frequency of failure to fulfil normal expectations due to drinking alcohol in last year-0.0',
- 'Frequency of needing morning drink of alcohol after heavy drinking session in last year-0.0',
- 'Frequency of feeling guilt or remorse after drinking alcohol in last year-0.0',
- 'Frequency of memory loss due to drinking alcohol in last year-0.0',
- "Ever been injured or injured someone else through drinking alcohol-0.0",
- "Ever had known person concerned about, or recommend reduction of, alcohol consumption-0.0"]].sum(axis=1).astype(int)
- # (log)AUDIT
- mh["AUDIT_log"] = np.log1p(mh["AUDIT"])
- # %% [markdown]
- # ## AUDIT-C
- #
- # Scores from items 1–3, which include the information pertaining to alcohol consumption
- # %%
- mh["AUDIT_C"] = mh[["Frequency of drinking alcohol-0.0",
- 'Amount of alcohol drunk on a typical drinking day-0.0',
- 'Frequency of consuming six or more units of alcohol-0.0']].sum(axis=1).astype(int)
- mh["AUDIT_C_log"] = np.log1p(mh["AUDIT_C"])
- # %% [markdown]
- # ## AUDIT-P
- #
- # Items 4–10, which indexes the information pertaining to alcohol problems
- # %%
- mh["AUDIT_P"] = mh[['Frequency of inability to cease drinking in last year-0.0',
- 'Frequency of failure to fulfil normal expectations due to drinking alcohol in last year-0.0',
- 'Frequency of needing morning drink of alcohol after heavy drinking session in last year-0.0',
- 'Frequency of feeling guilt or remorse after drinking alcohol in last year-0.0',
- 'Frequency of memory loss due to drinking alcohol in last year-0.0',
- "Ever been injured or injured someone else through drinking alcohol-0.0",
- "Ever had known person concerned about, or recommend reduction of, alcohol consumption-0.0"]].sum(axis=1).astype(int)
- mh["AUDIT_P_log"] = np.log1p(mh["AUDIT_P"])
- # %% [markdown]
- # ## Hazardous / Harmful Alcohol Use
- # %%
- mh["Hazardous_Alcohol_Use"] = np.where(mh["AUDIT"] >= 8, 1, 0)
- # Alcohol dependence
- mh["Alcohol_Dependence"] = np.where(mh["AUDIT"] >= 15, 1, 0)
- mh["Alcohol_depencence_ever"] = np.where(mh["Ever physically dependent on alcohol-0.0"] == 1, 1, 0)
- # %% [markdown]
- # ## Cannabis
- # %%
- mh["Ever taken cannabis-0.0"] = mh["Ever taken cannabis-0.0"].replace(np.nan, mh["Ever taken cannabis-0.0"].median())
- mh["Cannabis ever"] = np.where(mh["Ever taken cannabis-0.0"] > 0, 1, 0)
- mh['Frequency of taking cannabis'] = mh["Ever taken cannabis-0.0"]
- #20454[Maximum frequency of taking cannabis] frequency = every day {4}
- mh["Cannabis daily"] = np.where(mh["Maximum frequency of taking cannabis-0.0"] == 4, 1, 0)
- # %% [markdown]
- # ## Childhood adverse events
- # %%
- # Replace -818 with median
- columns_to_replace = ['Felt loved as a child-0.0', 'Physically abused by family as a child-0.0', 'Felt hated by family member as a child-0.0',
- 'Sexually molested as a child-0.0', 'Someone to take to doctor when needed as a child-0.0']
- for column in columns_to_replace:
- column_median = mh[column].median()
- mh[column] = mh[column].replace(-818, column_median)
- # %%
- # Based on answers to the five questions of Childhood Trauma Screen (CTS), all scored 1-5. A score over the threshold on any question is screen positive
- mh[['Felt loved as a child-0.0', 'Physically abused by family as a child-0.0', 'Felt hated by family member as a child-0.0',
- 'Sexually molested as a child-0.0', 'Someone to take to doctor when needed as a child-0.0']] = mh[['Felt loved as a child-0.0',
- 'Physically abused by family as a child-0.0', 'Felt hated by family member as a child-0.0',
- 'Sexually molested as a child-0.0', 'Someone to take to doctor when needed as a child-0.0']].replace({0:1, 1:2, 2:3, 3:4, 4:5})
- # %%
- mh['Childhood_adverse_events'] = [1 if (mh['Felt loved as a child-0.0'].iloc[i] <= 3 or mh['Physically abused by family as a child-0.0'].iloc[i] >= 2 or
- mh['Felt hated by family member as a child-0.0'].iloc[i] >= 2 or mh['Sexually molested as a child-0.0'].iloc[i] >= 2 or mh['Someone to take to doctor when needed as a child-0.0'].iloc[i] <= 4) else 0 for i in range(len(mh))]
- # %% [markdown]
- # ## Adult adverse events
- # %%
- # Replace -818 with median
- columns_to_replace = ['Been in a confiding relationship as an adult-0.0',
- 'Physical violence by partner or ex-partner as an adult-0.0',
- 'Belittlement by partner or ex-partner as an adult-0.0',
- 'Sexual interference by partner or ex-partner without consent as an adult-0.0',
- 'Able to pay rent/mortgage as an adult-0.0']
- for column in columns_to_replace:
- column_median = mh[column].median()
- mh[column] = mh[column].replace(-818, column_median)
- # %%
- # Recode
- mh[['Been in a confiding relationship as an adult-0.0',
- 'Physical violence by partner or ex-partner as an adult-0.0',
- 'Belittlement by partner or ex-partner as an adult-0.0',
- 'Sexual interference by partner or ex-partner without consent as an adult-0.0',
- 'Able to pay rent/mortgage as an adult-0.0']] = mh[['Been in a confiding relationship as an adult-0.0',
- 'Physical violence by partner or ex-partner as an adult-0.0',
- 'Belittlement by partner or ex-partner as an adult-0.0',
- 'Sexual interference by partner or ex-partner without consent as an adult-0.0',
- 'Able to pay rent/mortgage as an adult-0.0']].replace({0:1, 1:2, 2:3, 3:4, 4:5})
- # %%
- mh['Adult_adverse_events'] = [1 if (mh['Been in a confiding relationship as an adult-0.0'].iloc[i] <= 3 or mh['Physical violence by partner or ex-partner as an adult-0.0'].iloc[i] >= 2 or
- mh['Belittlement by partner or ex-partner as an adult-0.0'].iloc[i] >= 2 or mh['Sexual interference by partner or ex-partner without consent as an adult-0.0'].iloc[i] >= 2 or mh['Able to pay rent/mortgage as an adult-0.0'].iloc[i] <= 4) else 0 for i in range(len(mh))]
- # %% [markdown]
- # ## Catastrophic trauma
- # %%
- # Replace -818 with median
- columns_to_replace = ['Victim of sexual assault-0.0',
- 'Victim of physically violent crime-0.0',
- 'Been in serious accident believed to be life-threatening-0.0',
- 'Witnessed sudden violent death-0.0',
- 'Diagnosed with life-threatening illness-0.0',
- 'Been involved in combat or exposed to war-zone-0.0']
- for column in columns_to_replace:
- column_median = mh[column].median()
- mh[column] = mh[column].replace(-818, column_median)
- # %%
- mh['Catastrophic_trauma'] = [1 if (mh['Victim of sexual assault-0.0'].iloc[i] > 0 or
- mh['Victim of physically violent crime-0.0'].iloc[i] > 0 or
- mh['Been in serious accident believed to be life-threatening-0.0'].iloc[i] > 0 or
- mh['Witnessed sudden violent death-0.0'].iloc[i] > 0 or
- mh['Diagnosed with life-threatening illness-0.0'].iloc[i] > 0 or
- mh['Been involved in combat or exposed to war-zone-0.0'].iloc[i] > 0) else 0 for i in range(len(mh))]
- # %% [markdown]
- # ## Wellbeing
- # %%
- # Replace -818 with median
- columns_to_replace = ["General happiness-0.0", "General happiness with own health-0.0", "Belief that own life is meaningful-0.0"]
- for column in columns_to_replace:
- column_median = mh[column].median()
- mh[column] = mh[column].replace(-818, column_median)
- mh[column] = mh[column].replace(-121, column_median)
- # %%
- mh[["General happiness-0.0",
- "General happiness with own health-0.0"]] = mh[["General happiness-0.0", "General happiness with own health-0.0"]].replace({1:6, 2:5, 3:4, 4:3, 5:2, 6:1})
- # %%
- # Was:
- #1Extremely happy
- #2Very happy
- #3Moderately happy
- #4Moderately unhappy
- #5Very unhappy
- #6Extremely unhappy
- #Become
- #1Extremely unhappy
- #2Very unhappy
- #3Moderately unhappy
- #4Moderately happy
- #5Very happy
- #6Extremely happy
- # %%
- # Wellbeing
- mh["Wellbeing"] = mh[["General happiness-0.0", "General happiness with own health-0.0", "Belief that own life is meaningful-0.0"]].sum(axis=1).astype(int)
- # %% [markdown]
- # ## Unusual experience
- # %%
- mh[["Ever believed in an un-real conspiracy against self-0.0",
- "Ever believed in un-real communications or signs-0.0",
- "Ever heard an un-real voice-0.0", "Ever seen an un-real vision-0.0"]] = mh[[
- "Ever believed in an un-real conspiracy against self-0.0",
- "Ever believed in un-real communications or signs-0.0",
- "Ever heard an un-real voice-0.0", "Ever seen an un-real vision-0.0"]].replace({-818:0, -121:0})
- # %%
- # Unusual experience
- # Heard unreal voice 20463 = yes
- # OR Saw unreal vision 20471 = yes
- # OR Believed unreal conspiracy 20468 = yes
- # OR Believed unreal communication or signs 20474 = yes
- unexp = [(mh['Ever heard an un-real voice-0.0'].iloc[i], mh['Ever seen an un-real vision-0.0'].iloc[i],
- mh['Ever believed in an un-real conspiracy against self-0.0'].iloc[i],
- mh['Ever believed in un-real communications or signs-0.0'].iloc[i]) for i in range(len(mh))]
- unusualexp = [1 if (u[0] > 0 or u[1] > 0 or u[2] > 0 or u[3] > 0) else 0 for u in unexp]
- #%% Add to the df
- mh = mh.assign(Unusual_exp=unusualexp)
- # Recent unusual experience
- # Frequency in last year 20467>0
- ususrec = [(mh['Frequency of unusual or psychotic experiences in past year-0.0'].iloc[i]) for i in range(len(mh))]
- unusualexprecent = [1 if (u>0) else 0 for u in ususrec]
- mh = mh.assign(Unusual_exp_recent=unusualexprecent)
- # Unusual_exp_recent
- Unusual_exp_recent = mh.loc[mh['Unusual_exp_recent'] == 1][['Frequency of unusual or psychotic experiences in past year-0.0']]
- # %% [markdown]
- # ## Self-harm
- # %%
- # Life not worth living
- # 20479 life NWL = yes (1 or 2)
- mh["Self-harm: Life not worth living"] = np.where(mh["Ever thought that life not worth living-0.0"] > 0, 1, 0)
- # NWL
- NWL = mh.loc[mh['Self-harm: Life not worth living'] == 1][["Ever thought that life not worth living-0.0"]]
- # Self harm
- # 20480 Self harmed = Yes
- mh["Self-harmed"] = np.where(mh["Ever self-harmed-0.0"] > 0, 1, 0)
- #%% SH
- SH = mh.loc[mh['Self-harmed'] == 1][["Ever self-harmed-0.0"]]
- # Non-suicidal self-harm
- # 20480 Self harmed = Yes
- # 20483 Attempted suicide = No
- # 51 said "prefer not to answer"
- nonsuish = [(mh['Ever self-harmed-0.0'].iloc[i], mh['Ever attempted suicide-0.0'].iloc[i]) for i in range(len(mh))]
- nonsuiselfharm = [1 if (s[0] > 0 and s[1] == 0) else 0 for s in nonsuish]
- mh = mh.assign(Non_suicidal_SH=nonsuiselfharm)
- # Non_suicidal self-harm
- Non_suicidal_SH = mh.loc[mh['Non_suicidal_SH'] == 1][['Ever self-harmed-0.0', 'Ever attempted suicide-0.0']]
- # Suicide attempt
- # 20483 Attempted suicide = Yes
- mh["Sui_attempt"] = np.where(mh["Ever attempted suicide-0.0"] > 0, 1, 0)
- Sui_attempt = mh.loc[mh['Sui_attempt'] == 1][["Ever attempted suicide-0.0"]]
- # Replace
- mh[["Ever thought that life not worth living-0.0",
- "Ever contemplated self-harm-0.0", "Ever self-harmed-0.0"]] = mh[["Ever thought that life not worth living-0.0",
- "Ever contemplated self-harm-0.0", "Ever self-harmed-0.0"]].replace({-818:0, -121:0})
- # %% [markdown]
- # ## Addictions
- # %%
- mh["Ever addicted to any substance or behaviour-0.0"] = mh["Ever addicted to any substance or behaviour-0.0"].replace({-818:0, -121:0})
- mh["Addiction_ever"] = np.where(mh["Ever addicted to any substance or behaviour-0.0"] == 1, 1, 0)
- mh['Substance_addiction'] = [1 if (sa[0] == 1 or sa[1] == 1 or sa[2] == 1) else 0 for sa in [(mh['Ever addicted to alcohol-0.0'].iloc[i], mh['Ever addicted to illicit or recreational drugs-0.0'].iloc[i],
- mh['Ever addicted to prescription or over-the-counter medication-0.0'].iloc[i]) for i in range(len(mh))]]
- mh['Current_addiction'] = [1 if (c[0] == 1 or c[1]== 1 or c[2] == 1 or c[3] == 1) else 0 for c in [(mh['Ongoing addiction or dependence on illicit or recreational drugs-0.0'].iloc[i], mh['Ongoing addiction or dependence to over-the-counter medication-0.0'].iloc[i],
- mh['Ongoing addiction to alcohol-0.0'].iloc[i], mh['Ongoing behavioural or miscellanous addiction-0.0'].iloc[i]) for i in range(len(mh))]]
- # %% [markdown]
- # ## Any distress
- # %%
- columns_to_replace = ["Ever sought or received professional help for mental distress-0.0", "Ever suffered mental distress preventing usual activities-0.0"]
- for column in columns_to_replace:
- column_median = mh[column].median()
- mh[column] = mh[column].replace(-818, column_median)
- mh[column] = mh[column].replace(-121, column_median)
- # %%
- any_distress = []
- for i in range(len(mh)):
- if mh['Ever sought or received professional help for mental distress-0.0'].iloc[i] == 1 or mh['Ever suffered mental distress preventing usual activities-0.0'].iloc[i] == 1 or mh['Depression_ever'].iloc[i] == 1 or mh['GAD_ever'].iloc[i] == 1 or mh['Ever addicted to any substance or behaviour-0.0'].iloc[i] == 1 or mh['Mania'].iloc[i] == 1 or mh['Bipolar_1'].iloc[i] == 1 or mh['Bipolar_2'].iloc[i] == 1 or mh['PTSD'].iloc[i] == 1 or mh['Unusual_exp'].iloc[i] == 1 or mh['Unusual_exp_recent'].iloc[i] == 1 or mh['Self-harmed'].iloc[i] or any(mh[f'Mental health problems ever diagnosed by a professional-0.{j}'].iloc[i] > 0 for j in range(1, 17)):
- any_distress_score = 1
- else:
- any_distress_score = 0
- any_distress.append(any_distress_score)
- mh = mh.assign(Any_distress=any_distress)
- #mh["Any_distress"] = [1 if mh['Ever sought or received professional help for mental distress-0.0'].iloc[i] == 1 or mh['Ever suffered mental distress preventing usual activities-0.0'].iloc[i] == 1 or mh['Depression_ever'].iloc[i] == 1 or mh['GAD_ever'].iloc[i] == 1 or mh['Addiction_ever'].iloc[i] == 1 or mh['Mania'].iloc[i] == 1 or mh['Bipolar_1'].iloc[i] == 1 or mh['Bipolar_2'].iloc[i] == 1 or mh['PTSD'].iloc[i] == 1 or mh['Unusual_exp'].iloc[i] == 1 or mh['Unusual_exp_recent'].iloc[i] == 1 or mh['Self-harmed'].iloc[i] or any(mh[f'Mental health problems ever diagnosed by a professional-0.{j}'].iloc[i] > 0 for j in range(1, 17)) else 0 for i in range(len(mh))]
- # %% [markdown]
- # ## Happiness
- # %%
- columns_to_replace = ["Happiness-2.0", "Family relationship satisfaction-2.0", "Financial situation satisfaction-2.0", "Friendships satisfaction-2.0", "Work/job satisfaction-2.0", "Health satisfaction-2.0"]
- for column in columns_to_replace:
- column_median = mh[column].median()
- mh[column] = mh[column].replace(-1, column_median)
- mh[column] = mh[column].replace(-3, column_median)
- mh[["Happiness-2.0",
- "Family relationship satisfaction-2.0",
- "Financial situation satisfaction-2.0",
- "Friendships satisfaction-2.0",
- "Work/job satisfaction-2.0",
- "Health satisfaction-2.0"]] = mh[["Happiness-2.0",
- "Family relationship satisfaction-2.0",
- "Financial situation satisfaction-2.0",
- "Friendships satisfaction-2.0",
- "Work/job satisfaction-2.0",
- "Health satisfaction-2.0"]].replace({1:6, 2:5, 3:4, 4:3, 5:2, 6:1, 7:0})
- # %%
- columns_to_replace = [
- 'Recent poor appetite or overeating-0.0',
- 'Recent trouble concentrating on things-0.0',
- 'Recent changes in speed/amount of moving or speaking-0.0',
- 'Frequency of taking cannabis',
- 'Trouble falling or staying asleep, or sleeping too much-0.0',
- 'Recent feelings of tiredness or low energy-0.0',
- 'Recent lack of interest or pleasure in doing things-0.0',
- 'Recent feelings of depression-0.0',
- 'Recent feelings of inadequacy-0.0',
- 'Ever had period of mania / excitability-0.0',
- 'Ever had period extreme irritability-0.0',
- 'Recent thoughts of suicide or self-harm-0.0'
- ]
- for column in columns_to_replace:
- column_median = mh[column].median()
- mh[column] = mh[column].replace(-818, column_median)
- mh[column] = mh[column].replace(-121, column_median)
- # %% [markdown]
- # ## NS-12
- # %% [markdown]
- # N-12 (0–12)
- #
- # - Mood swings
- # - Miserableness 1930
- # - Irritability 1940
- # - Sensitivity/hurt feelings 1950
- # - Fed-up feelings 1960
- # - Nervous feelings 1970
- # - Worrier/anxious feelings 1980
- # - Tense/“highly strung” 1990
- # - Worry too long after embarrassment 2000
- # - Suffer from “nerves” 2010
- # - Loneliness, isolation 2020
- # - Guilty feelings 2030
- # %%
- # N-12 (0–12)
- print(mh[["Mood swings-2.0", "Miserableness-2.0", "Irritability-2.0", "Sensitivity / hurt feelings-2.0",
- "Fed-up feelings-2.0", "Nervous feelings-2.0", "Worrier / anxious feelings-2.0", "Tense / 'highly strung'-2.0",
- "Worry too long after embarrassment-2.0", "Suffer from 'nerves'-2.0", "Loneliness, isolation-2.0", "Guilty feelings-2.0"]].median())
- # Replace - 1 / -3 with 0
- mh[["Mood swings-2.0", "Miserableness-2.0", "Irritability-2.0", "Sensitivity / hurt feelings-2.0",
- "Fed-up feelings-2.0", "Nervous feelings-2.0", "Worrier / anxious feelings-2.0", "Tense / 'highly strung'-2.0",
- "Worry too long after embarrassment-2.0", "Suffer from 'nerves'-2.0", "Loneliness, isolation-2.0", "Guilty feelings-2.0"]] = mh[["Mood swings-2.0", "Miserableness-2.0", "Irritability-2.0", "Sensitivity / hurt feelings-2.0",
- "Fed-up feelings-2.0", "Nervous feelings-2.0", "Worrier / anxious feelings-2.0", "Tense / 'highly strung'-2.0",
- "Worry too long after embarrassment-2.0", "Suffer from 'nerves'-2.0", "Loneliness, isolation-2.0", "Guilty feelings-2.0"]].replace({-1:0, -3:0})
- mh['NS12'] = mh[["Mood swings-2.0", "Miserableness-2.0", "Irritability-2.0", "Sensitivity / hurt feelings-2.0",
- "Fed-up feelings-2.0", "Nervous feelings-2.0", "Worrier / anxious feelings-2.0", "Tense / 'highly strung'-2.0",
- "Worry too long after embarrassment-2.0", "Suffer from 'nerves'-2.0", "Loneliness, isolation-2.0", "Guilty feelings-2.0"]].sum(axis=1).astype(int)
- print(mh['NS12'].min())
- print(mh['NS12'].max())
- # %% [markdown]
- # ## Probable depression status
- # %% [markdown]
- # Probable depression status
- #
- # - Ever depressed 4598 OR Ever unenthusiastic/disinterested 4631
- # - Duration of the longest period of depression 4609
- # - Duration of the longest period of unenthusiasm/disinterest 5375
- # - Seen doctor (GP) for nerves, anxiety, tension, and depression 2090
- # - Seen psychiatrist for nerves, anxiety, tension, and depression 2100
- #
- #
- # - Depression status was set to 1 if subjects responded
- # - yes to variable IDs 4598 OR 4631 (ever depressed ever unenthusiastic/disinterested),
- # - AND reported a duration of at least 1 week to variable IDs 4609 OR 5375 (depressionjunenthusiasm/disinterest)
- # - AND had seen either a GP or psychiatrist for nerves, anxiety, tension, depression (i.e., responded yes to variable IDs, 2090 or 2100)
- # %%
- # Probable depression status
- pdslist = [(mh['Ever depressed for a whole week-2.0'].iloc[i],
- mh['Ever unenthusiastic/disinterested for a whole week-2.0'].iloc[i],
- mh['Longest period of depression-2.0'].iloc[i],
- mh['Longest period of unenthusiasm / disinterest-2.0'].iloc[i],
- mh['Seen doctor (GP) for nerves, anxiety, tension or depression-2.0'].iloc[i],
- mh['Seen a psychiatrist for nerves, anxiety, tension or depression-2.0'].iloc[i]) for i in range(len(mh))]
- pds = []
- for p in pdslist:
- if (p[0] > 0 or p[1] > 0) and (p[2] >= 1 or p[3] >= 1) and (p[4] > 0 or p[5] > 0):
- pds_score = 1
- else:
- pds_score = 0
- pds.append(pds_score)
- mh = mh.assign(PDS=pds)
- # %%
- # Replace -1/-3 - 0
- mh[["Risk taking-2.0", "Seen a psychiatrist for nerves, anxiety, tension or depression-2.0", "Seen doctor (GP) for nerves, anxiety, tension or depression-2.0",
- "Ever unenthusiastic/disinterested for a whole week-2.0", "Ever highly irritable/argumentative for 2 days-2.0", "Ever manic/hyper for 2 days-2.0"]] = mh[["Risk taking-2.0",
- "Seen a psychiatrist for nerves, anxiety, tension or depression-2.0", "Seen doctor (GP) for nerves, anxiety, tension or depression-2.0",
- "Ever unenthusiastic/disinterested for a whole week-2.0", "Ever highly irritable/argumentative for 2 days-2.0", "Ever manic/hyper for 2 days-2.0"]].replace({-1:0, -3:0})
- # -1/-3 - 1
- mh["Ever depressed for a whole week-2.0"] = mh["Ever depressed for a whole week-2.0"].replace({-1:3, -3:3})
- # %% [markdown]
- # ## Recent depressive symptoms
- # %% [markdown]
- # RDS-4 (4-16):
- #
- # - Frequency of depressed mood in last 2 weeks 2050
- # - Frequency of unenthusiasm/disinterest in last 2 weeks 2060
- # - Frequency of tenseness/restlessness in last 2 weeks 2070
- # - Frequency of tiredness/lethargy in last 2 weeks 2080
- # %%
- # RDS-4 (4-16):
- print(mh[['Frequency of depressed mood in last 2 weeks-2.0','Frequency of unenthusiasm / disinterest in last 2 weeks-2.0',
- 'Frequency of tenseness / restlessness in last 2 weeks-2.0', 'Frequency of tiredness / lethargy in last 2 weeks-2.0']].median())
- # Replace -3 and -1
- mh[['Frequency of depressed mood in last 2 weeks-2.0','Frequency of unenthusiasm / disinterest in last 2 weeks-2.0',
- 'Frequency of tenseness / restlessness in last 2 weeks-2.0', 'Frequency of tiredness / lethargy in last 2 weeks-2.0']] = mh[['Frequency of depressed mood in last 2 weeks-2.0','Frequency of unenthusiasm / disinterest in last 2 weeks-2.0',
- 'Frequency of tenseness / restlessness in last 2 weeks-2.0', 'Frequency of tiredness / lethargy in last 2 weeks-2.0']].replace({-1:1, -3:1})
- # Calculate the score
- mh['RDS4'] = mh[['Frequency of depressed mood in last 2 weeks-2.0','Frequency of unenthusiasm / disinterest in last 2 weeks-2.0',
- 'Frequency of tenseness / restlessness in last 2 weeks-2.0', 'Frequency of tiredness / lethargy in last 2 weeks-2.0']].sum(axis=1).astype(int)
- print('RDS MIN', mh['RDS4'].min())
- print('RDS MAX', mh['RDS4'].max())
- # %% [markdown]
- # # Select scores
- # %%
- mh_main = mh[['eid',
- 'Anxiety/panic attacks',
- 'NS12',
- 'PCL6',
- 'PHQ9',
- 'PDS',
- 'RDS4',
- 'Depression',
- 'Self-harm: Life not worth living', #Self-harm: Ever thought life not worth living" yes/no
- 'Sui_attempt',
- 'Self-harmed',
- 'Non_suicidal_SH',
- 'Unusual_exp',
- 'Unusual_exp_recent',
- 'Repeated disturbing thoughts of stressful experience in past month-0.0',
- 'Felt very upset when reminded of stressful experience in past month-0.0',
- 'Avoided activities or situations because of previous stressful experience in past month-0.0',
- 'Ever thought that life not worth living-0.0', #'Frequency of "life not worth living" thoughts',
- 'Ever contemplated self-harm-0.0',
- 'Ever had prolonged feelings of sadness or depression-0.0',
- 'Ever had prolonged loss of interest in normal activities-0.0',
- 'Ever felt worried, tense, or anxious for most of a month or longer-0.0',
- 'Ever worried more than most people would in similar situation-0.0',
- 'Ever addicted to any substance or behaviour-0.0',
- 'Ever believed in an un-real conspiracy against self-0.0',
- 'Ever believed in un-real communications or signs-0.0',
- 'Ever heard an un-real voice-0.0',
- 'Ever seen an un-real vision-0.0',
- 'Mood swings-2.0',
- 'Miserableness-2.0',
- 'Irritability-2.0',
- 'Sensitivity / hurt feelings-2.0',
- 'Fed-up feelings-2.0',
- 'Nervous feelings-2.0',
- 'Worrier / anxious feelings-2.0',
- "Tense / 'highly strung'-2.0",
- 'Worry too long after embarrassment-2.0',
- "Suffer from 'nerves'-2.0",
- 'Loneliness, isolation-2.0',
- 'Guilty feelings-2.0',
- 'Risk taking-2.0',
- 'Frequency of depressed mood in last 2 weeks-2.0',
- 'Frequency of unenthusiasm / disinterest in last 2 weeks-2.0',
- 'Frequency of tenseness / restlessness in last 2 weeks-2.0',
- 'Frequency of tiredness / lethargy in last 2 weeks-2.0',
- 'Seen a psychiatrist for nerves, anxiety, tension or depression-2.0',
- 'Seen doctor (GP) for nerves, anxiety, tension or depression-2.0',
- 'Ever depressed for a whole week-2.0',
- 'Ever unenthusiastic/disinterested for a whole week-2.0',
- 'Ever highly irritable/argumentative for 2 days-2.0',
- 'Ever manic/hyper for 2 days-2.0',
- #"Diagnoses 'F'",
- #"Diagnoses 'G'",
- 'Neurological problem, NS injury, epilepsy',
- 'Stress, insomnia, migraine, nervous/mental problems',
- 'Ever had period of mania / excitability-0.0',
- 'Ever had period extreme irritability-0.0',
- 'Recent feelings of inadequacy-0.0',
- 'Recent trouble concentrating on things-0.0',
- 'Recent feelings of depression-0.0',
- 'Recent poor appetite or overeating-0.0',
- 'Recent thoughts of suicide or self-harm-0.0',
- 'Recent lack of interest or pleasure in doing things-0.0',
- 'Trouble falling or staying asleep, or sleeping too much-0.0',
- 'Recent changes in speed/amount of moving or speaking-0.0',
- 'Recent feelings of tiredness or low energy-0.0',
- 'Depression_ever',
- 'Depression_subthreshold',
- 'Bipolar_1',
- 'Bipolar_2',
- 'Depression_single',
- 'Depression_recurrent',
- 'Depression_triggered_by_loss',
- 'Depression_current',
- 'Depression_current_severe',
- #'Mania',
- 'Recent easy annoyance or irritability-0.0',
- 'Recent feelings or nervousness or anxiety-0.0',
- 'Recent inability to stop or control worrying-0.0',
- 'Recent feelings of foreboding-0.0',
- 'Recent trouble relaxing-0.0',
- 'Recent restlessness-0.0',
- 'Recent worrying too much about different things-0.0',
- 'GAD7',
- 'GAD_ever',
- 'GAD_current',
- 'GAD_current_mild',
- 'GAD_current_moderate',
- 'GAD_current_severe',
- 'PTSD',
- 'Amount of alcohol drunk on a typical drinking day-0.0',
- 'Frequency of drinking alcohol-0.0',
- 'Frequency of consuming six or more units of alcohol-0.0',
- 'AUDIT',
- 'AUDIT_log',
- 'AUDIT_C',
- 'AUDIT_P',
- 'AUDIT_C_log',
- 'AUDIT_P_log',
- 'Hazardous_Alcohol_Use',
- 'Alcohol_Dependence',
- 'General happiness-0.0',
- 'General happiness with own health-0.0',
- 'Belief that own life is meaningful-0.0',
- 'Felt hated by family member as a child-0.0',
- 'Physically abused by family as a child-0.0',
- 'Felt loved as a child-0.0',
- 'Sexually molested as a child-0.0',
- 'Someone to take to doctor when needed as a child-0.0',
- 'Ever sought or received professional help for mental distress-0.0',
- 'Ever suffered mental distress preventing usual activities-0.0',
- 'Belittlement by partner or ex-partner as an adult-0.0',
- 'Been in a confiding relationship as an adult-0.0',
- 'Physical violence by partner or ex-partner as an adult-0.0',
- 'Sexual interference by partner or ex-partner without consent as an adult-0.0',
- 'Able to pay rent/mortgage as an adult-0.0',
- 'Been in serious accident believed to be life-threatening-0.0',
- 'Been involved in combat or exposed to war-zone-0.0',
- 'Diagnosed with life-threatening illness-0.0',
- 'Victim of physically violent crime-0.0',
- 'Witnessed sudden violent death-0.0',
- 'Victim of sexual assault-0.0',
- #'Addiction_ever',
- 'Alcohol_depencence_ever',
- 'Substance_addiction',
- 'Current_addiction',
- 'Cannabis ever',
- 'Frequency of taking cannabis',
- 'Cannabis daily',
- 'Childhood_adverse_events',
- 'Adult_adverse_events',
- 'Catastrophic_trauma',
- 'Wellbeing',
- 'Any_distress',
- 'Friendships satisfaction-2.0',
- 'Financial situation satisfaction-2.0',
- 'Happiness-2.0',
- 'Family relationship satisfaction-2.0',
- 'Health satisfaction-2.0']]
- mh_main.to_csv('/Cog-Ment/CSVs/2024/mental_health/mental_health_no_diagnoses_all_scores.csv', index=False)
- # %% [markdown]
- # # ICD Diagnoses
- # %%
- # Work out ICD diagnoses
- diag_cols = ['Diagnoses - main ICD10-0.0',
- 'Diagnoses - main ICD10-0.1',
- 'Diagnoses - main ICD10-0.2',
- 'Diagnoses - main ICD10-0.3',
- 'Diagnoses - main ICD10-0.4',
- 'Diagnoses - main ICD10-0.5',
- 'Diagnoses - main ICD10-0.6',
- 'Diagnoses - main ICD10-0.7',
- 'Diagnoses - main ICD10-0.8',
- 'Diagnoses - main ICD10-0.9',
- 'Diagnoses - main ICD10-0.10',
- 'Diagnoses - main ICD10-0.11',
- 'Diagnoses - main ICD10-0.12',
- 'Diagnoses - main ICD10-0.13',
- 'Diagnoses - main ICD10-0.14',
- 'Diagnoses - main ICD10-0.15',
- 'Diagnoses - main ICD10-0.16',
- 'Diagnoses - main ICD10-0.17',
- 'Diagnoses - main ICD10-0.18',
- 'Diagnoses - main ICD10-0.19',
- 'Diagnoses - main ICD10-0.20',
- 'Diagnoses - main ICD10-0.21',
- 'Diagnoses - main ICD10-0.22',
- 'Diagnoses - main ICD10-0.23',
- 'Diagnoses - main ICD10-0.24',
- 'Diagnoses - main ICD10-0.25',
- 'Diagnoses - main ICD10-0.26',
- 'Diagnoses - main ICD10-0.27',
- 'Diagnoses - main ICD10-0.28',
- 'Diagnoses - main ICD10-0.29',
- 'Diagnoses - main ICD10-0.30',
- 'Diagnoses - main ICD10-0.31',
- 'Diagnoses - main ICD10-0.32',
- 'Diagnoses - main ICD10-0.33',
- 'Diagnoses - main ICD10-0.34',
- 'Diagnoses - main ICD10-0.35',
- 'Diagnoses - main ICD10-0.36',
- 'Diagnoses - main ICD10-0.37',
- 'Diagnoses - main ICD10-0.38',
- 'Diagnoses - main ICD10-0.39',
- 'Diagnoses - main ICD10-0.40',
- 'Diagnoses - main ICD10-0.41',
- 'Diagnoses - main ICD10-0.42',
- 'Diagnoses - main ICD10-0.43',
- 'Diagnoses - main ICD10-0.44',
- 'Diagnoses - main ICD10-0.45',
- 'Diagnoses - main ICD10-0.46',
- 'Diagnoses - main ICD10-0.47',
- 'Diagnoses - main ICD10-0.48',
- 'Diagnoses - main ICD10-0.49',
- 'Diagnoses - main ICD10-0.50',
- 'Diagnoses - main ICD10-0.51',
- 'Diagnoses - main ICD10-0.52',
- 'Diagnoses - main ICD10-0.53',
- 'Diagnoses - main ICD10-0.54',
- 'Diagnoses - main ICD10-0.55',
- 'Diagnoses - main ICD10-0.56',
- 'Diagnoses - main ICD10-0.57',
- 'Diagnoses - main ICD10-0.58',
- 'Diagnoses - main ICD10-0.59',
- 'Diagnoses - main ICD10-0.60',
- 'Diagnoses - main ICD10-0.61',
- 'Diagnoses - main ICD10-0.62',
- 'Diagnoses - main ICD10-0.63',
- 'Diagnoses - main ICD10-0.64',
- 'Diagnoses - main ICD10-0.65',
- 'Diagnoses - main ICD10-0.66',
- 'Diagnoses - main ICD10-0.67',
- 'Diagnoses - main ICD10-0.68',
- 'Diagnoses - main ICD10-0.69',
- 'Diagnoses - main ICD10-0.70',
- 'Diagnoses - main ICD10-0.71',
- 'Diagnoses - main ICD10-0.72',
- 'Diagnoses - main ICD10-0.73',
- 'Diagnoses - main ICD10-0.74',
- 'Diagnoses - main ICD10-0.75',
- 'Diagnoses - main ICD10-0.76',
- 'Diagnoses - main ICD10-0.77',
- 'Diagnoses - main ICD10-0.78',
- 'Diagnoses - main ICD10-0.79']
- # F
- diagnoses_main_icd["all_diag"] = diagnoses_main_icd[diag_cols].astype(str).apply(lambda x: x.str.cat(sep=","), axis=1)
- diagnoses_main_icd["F0 Organic (incl. symptomatic, mental disorders)"] = diagnoses_main_icd["all_diag"].str.contains("F0").astype(int)
- diagnoses_main_icd["F1 Mental and behavioural disorders due to psychoactive substance use"] = diagnoses_main_icd["all_diag"].str.contains("F1").astype(int)
- diagnoses_main_icd["F2 Schizophrenia, schizotypal and delusional disorders"] = diagnoses_main_icd["all_diag"].str.contains("F2").astype(int)
- diagnoses_main_icd["F3 Mood [affective] disorders"] = diagnoses_main_icd["all_diag"].str.contains("F3").astype(int)
- diagnoses_main_icd["F4 Neurotic, stress-related and somatoform disorders"] = diagnoses_main_icd["all_diag"].str.contains("F4").astype(int)
- diagnoses_main_icd["F5 Behavioural syndromes associated with physiological disturbances and physical factors"] = diagnoses_main_icd["all_diag"].str.contains("F5").astype(int)
- diagnoses_main_icd["F6 Disorders of adult personality and behaviour"] = diagnoses_main_icd["all_diag"].str.contains("F6").astype(int)
- diagnoses_main_icd["F7 Mental retardation"] = diagnoses_main_icd["all_diag"].str.contains("F7").astype(int)
- diagnoses_main_icd["F8 Disorders of psychological development"] = diagnoses_main_icd["all_diag"].str.contains("F8").astype(int)
- diagnoses_main_icd["F90-F98 Behavioural and emotional disorders with onset usually occurring in childhood and adolescence"] = diagnoses_main_icd["all_diag"].str.contains("F9[0-8]").astype(int)
- diagnoses_main_icd["F99 Unspecified mental disorder"] = diagnoses_main_icd["all_diag"].str.contains("F99").astype(int)
- # G
- diagnoses_main_icd["G0 Inflammatory diseases of the central nervous system"] = diagnoses_main_icd["all_diag"].str.contains("G0").astype(int)
- diagnoses_main_icd["G1 Systemic atrophies primarily affecting the central nervous system"] = diagnoses_main_icd["all_diag"].str.contains("G1").astype(int)
- diagnoses_main_icd["G2 Extrapyramidal and movement disorders"] = diagnoses_main_icd["all_diag"].str.contains("G2").astype(int)
- diagnoses_main_icd["G30-G32 Other degenerative diseases of the nervous system"] = diagnoses_main_icd["all_diag"].str.contains("G3[0-2]").astype(int)
- diagnoses_main_icd["G35-G37 Demyelinating diseases of the central nervous system"] = diagnoses_main_icd["all_diag"].str.contains("G3[5-7]").astype(int)
- diagnoses_main_icd["G4 Episodic and paroxysmal disorders"] = diagnoses_main_icd["all_diag"].str.contains("G4").astype(int)
- diagnoses_main_icd["G5 Nerve, nerve root and plexus disorders"] = diagnoses_main_icd["all_diag"].str.contains("G5").astype(int)
- diagnoses_main_icd["G6 Polyneuropathies and other disorders of the peripheral nervous system"] = diagnoses_main_icd["all_diag"].str.contains("G6").astype(int)
- diagnoses_main_icd["G7 Diseases of myoneural junction and muscle"] = diagnoses_main_icd["all_diag"].str.contains("G7").astype(int)
- diagnoses_main_icd["G8 Cerebral palsy and other paralytic syndromes"] = diagnoses_main_icd["all_diag"].str.contains("G8").astype(int)
- diagnoses_main_icd["G9 Other disorders of the nervous system"] = diagnoses_main_icd["all_diag"].str.contains("G9").astype(int)
- # Combine diagnoses
- diagnoses_main_icd["Diagnoses 'F'"] = diagnoses_main_icd[['F0 Organic (incl. symptomatic, mental disorders)',
- 'F1 Mental and behavioural disorders due to psychoactive substance use',
- 'F2 Schizophrenia, schizotypal and delusional disorders',
- 'F3 Mood [affective] disorders',
- 'F4 Neurotic, stress-related and somatoform disorders',
- 'F5 Behavioural syndromes associated with physiological disturbances and physical factors',
- 'F6 Disorders of adult personality and behaviour',
- 'F7 Mental retardation',
- 'F8 Disorders of psychological development',
- 'F90-F98 Behavioural and emotional disorders with onset usually occurring in childhood and adolescence',
- 'F99 Unspecified mental disorder']].sum(axis=1).astype(int)
- diagnoses_main_icd["Diagnoses 'G'"] = diagnoses_main_icd[["G0 Inflammatory diseases of the central nervous system",
- "G1 Systemic atrophies primarily affecting the central nervous system",
- "G2 Extrapyramidal and movement disorders",
- "G30-G32 Other degenerative diseases of the nervous system",
- "G35-G37 Demyelinating diseases of the central nervous system",
- "G4 Episodic and paroxysmal disorders",
- "G5 Nerve, nerve root and plexus disorders",
- "G6 Polyneuropathies and other disorders of the peripheral nervous system",
- "G7 Diseases of myoneural junction and muscle",
- "G8 Cerebral palsy and other paralytic syndromes",
- "G9 Other disorders of the nervous system"]].sum(axis=1).astype(int)
- diagnoses_main_icd_FG = diagnoses_main_icd[['eid', "Diagnoses 'F'", "Diagnoses 'G'"]]
- diagnoses_main_icd_FG.to_csv('/UK_BB/diagnoses/diagnoses_main_icd_FG.csv', index=False)
- # %% [markdown]
- # # Merge Diagnoses with Scores and rename
- # %%
- mh_full = mh_main.drop(columns=['AUDIT','AUDIT_C','AUDIT_P'])
- mh_full = pd.merge(mh_full, diagnoses_main_icd_FG, on = 'eid')
- mh_full.to_csv('/UK_BB/mental_health/mental_health_full.csv')
- mh_full.shape
- # %%
- mh_full.columns.to_list()
- # %%
- # Rename columns
- new_names = ['eid',
- 'Diagnoses: Anxiety/panic attacks',
- 'NS-12',
- 'PCL-6',
- 'PHQ-9',
- 'PDS',
- 'RDS-4',
- 'Diagnoses: Depression',
- 'Self-harm: Ever thought life not worth living',
- 'Ever attempted suicide',
- 'Ever self-harmed',
- 'Ever self-harmed (non-suicidal)',
- 'Unusual experience',
- 'Recent unusual experience',
- 'Repeated disturbing thoughts of stressful experience in past month',
- 'Felt very upset when reminded of stressful experience in past month',
- 'Avoided activities or situations because of previous stressful experience in past month',
- "Frequency of 'life not worth living' thoughts",
- 'Lifetime frequency of contemplating self-harm',
- 'Ever had prolonged feelings of sadness or depression',
- 'Ever had prolonged loss of interest in normal activities',
- 'Ever felt worried, tense, or anxious for most of a month or longer',
- 'Ever worried more than most people would in similar situation',
- 'Ever addicted to any substance or behaviour',
- 'Ever believed in an un-real conspiracy against self',
- 'Ever believed in un-real communications or signs',
- 'Ever heard an un-real voice',
- 'Ever seen an un-real vision',
- 'Mood swings',
- 'Miserableness',
- 'Irritability',
- 'Sensitivity / hurt feelings',
- 'Fed-up feelings',
- 'Nervous feelings',
- 'Worrier / anxious feelings',
- "Tense / 'highly strung'",
- 'Worry too long after embarrassment',
- "Suffer from 'nerves'",
- 'Loneliness, isolation',
- 'Guilty feelings',
- 'Risk taking',
- 'Frequency of depressed mood in last 2 weeks',
- 'Frequency of unenthusiasm / disinterest in last 2 weeks',
- 'Frequency of tenseness / restlessness in last 2 weeks',
- 'Frequency of tiredness / lethargy in last 2 weeks',
- 'Seen a psychiatrist for nerves, anxiety, tension or depression',
- 'Seen doctor (GP) for nerves, anxiety, tension or depression',
- 'Ever depressed for a whole week',
- 'Ever unenthusiastic/disinterested for a whole week',
- 'Ever highly irritable/argumentative for 2 days',
- 'Ever manic/hyper for 2 days',
- 'Diagnoses: Neurological problem, NS injury, epilepsy',
- 'Diagnoses: Stress, insomnia, migraine, nervous/mental problems',
- 'Ever had period of mania / excitability',
- 'Ever had period extreme irritability',
- 'Recent feelings of inadequacy',
- 'Recent trouble concentrating on things',
- 'Recent feelings of depression',
- 'Recent poor appetite or overeating',
- 'Recent thoughts of suicide or self-harm',
- 'Recent lack of interest or pleasure in doing things',
- 'Trouble falling or staying asleep, or sleeping too much',
- 'Recent changes in speed/amount of moving or speaking',
- 'Recent feelings of tiredness or low energy',
- 'Depression ever',
- 'Subthreshold depression',
- 'Bipolar I',
- 'Bipolar II',
- 'Depression single episode',
- 'Recurrent depression',
- 'Depression triggered by loss',
- 'Current depression',
- 'Current severe depression',
- # Mania score
- 'Recent easy annoyance or irritability',
- 'Recent feelings or nervousness or anxiety',
- 'Recent inability to stop or control worrying',
- 'Recent feelings of foreboding',
- 'Recent trouble relaxing',
- 'Recent restlessness',
- 'Recent worrying too much about different things',
- 'GAD-7',
- 'GAD ever',
- 'Current GAD',
- 'Current GAD mild',
- 'Current GAD moderate',
- 'Current GAD severe',
- 'PTSD',
- 'Amount of alcohol drunk on a typical drinking day',
- 'Frequency of drinking alcohol',
- 'Frequency of consuming six or more units of alcohol',
- '(log)AUDIT',
- '(log)AUDIT-C',
- '(log)AUDIT-P',
- 'Hazardous alcohol use (AUDIT≥8)',
- 'Alcohol dependence (AUDIT≥15)',
- 'General happiness',
- 'General happiness with own health',
- 'Belief that own life is meaningful',
- 'Felt hated by family member as a child',
- 'Physically abused by family as a child',
- 'Felt loved as a child',
- 'Sexually molested as a child',
- 'Someone to take to doctor when needed as a child',
- 'Ever sought or received professional help for mental distress',
- 'Ever suffered mental distress preventing usual activities',
- 'Belittlement by partner or ex-partner as an adult',
- 'Been in a confiding relationship as an adult',
- 'Physical violence by partner or ex-partner as an adult',
- 'Sexual interference by partner or ex-partner without consent as an adult',
- 'Able to pay rent/mortgage as an adult',
- 'Been in serious accident believed to be life-threatening',
- 'Been involved in combat or exposed to war-zone',
- 'Diagnosed with life-threatening illness',
- 'Victim of physically violent crime',
- 'Witnessed sudden violent death',
- 'Victim of sexual assault',
- # Addiction ever
- 'Physical alcohol dependence ever',
- 'Substance addiction',
- 'Current addiction',
- 'Cannabis ever',
- 'Lifertime frequency of taking cannabis',
- 'Cannabis daily',
- 'Childhood adverse events',
- 'Adult adverse events',
- 'Catastrophic trauma',
- 'Wellbeing',
- 'Any distress',
- 'Friendships satisfaction',
- 'Financial situation satisfaction',
- 'Happiness',
- 'Family relationship satisfaction',
- 'Health satisfaction',
- 'Mental and behavioural disorders',
- 'Diseases of the nervous system'
- ]
- mh_rename = mh_full.copy()
- mh_rename.columns = new_names
- mh_rename.to_csv('/Cog-Ment/CSVs/2024/mental_health/mental_health_full_renamed.csv', index=False)
01_GetMHData.ipynb at commit 633419e, under MIT · at the source
Overview
- Department of Psychology, University of Otago Dunedin New Zealand
- Federal University of the São Francisco Valley Petrolina Brazil
- National Institute of Social and Affective Neuroscience Petrolina Brazil
- School of Computing, University of Otago Dunedin New Zealand
Abstract
Cognitive dysfunction often co-occurs with psychopathology. Advances in neuroimaging and machine learning have led to neural indicators that predict individual differences in cognition with reasonable performance. We examined whether these indicators explain the relationship between cognition and mental health in the UK Biobank (n>14,000). Using machine learning, we quantified the covariation between cognition and 133 mental health indices and derived neural indicators of cognition from 72 neuroimaging phenotypes across diffusion-weighted MRI (dwMRI), resting-state functional MRI (rsMRI), and structural MRI (sMRI). With commonality analyses, we investigated how much of the cognition–mental health covariation is captured by each indicator and neural indicators combined within and across MRI modalities. The predictive association between mental health and cognition was at r=
Reproduced under the paper's license (CC BY), from the paper cited above.
Repository
Its files are read in the Code ↔ Paper reader above, with 18 matches between paragraphs and lines of code.
HAM-lab-Otago-University/UKBiobank
633419e8593d3d768c719f0e81d58dd6e345ce7c, 20 May 2026Availability: 1 check, the latest on 28 September 2026: the link answers
- 28 September 2026: the link answers
14 files
- 1_Cognitive_preprocessin
g/ , Jupyter, 207 lines01_GetCogData.ipynb - 1_Cognitive_preprocessin
g/ , Jupyter, 272 lines, 1 match02_CogData_Descriptive_5 Folds.ipynb - 1_Cognitive_preprocessin
g/ , R, 336 lines, 1 match03_GetGFactor_5Folds.Rmd - 1_Cognitive_preprocessin
g/ , R, 135 lines, 2 matches04_GetGFactor_SingleSpli t.Rmd - 2_Mental_Health/
01_GetMHData.ipynb , Jupyter, 1,989 lines, 4 matches - 2_Mental_Health/
02_MHData_Descriptives.R , R, 50 linesmd - 3_MRI_preprocessing/
01_GetMRIData_dwMRI_IDP. , Jupyter, 1,627 lines, 3 matchesipynb - 3_MRI_preprocessing/
02_GetMRIData_dwMRI_Parc , Jupyter, 2,683 linesellations.ipynb - 3_MRI_preprocessing/
03_GetMRIData_sMRI.ipynb , Jupyter, 2,942 lines, 1 match - 3_MRI_preprocessing/
04_GetMRIData_rsMRI_IDP_ , Jupyter, 1,539 lines, 2 matchesFullPartCorr_Confounds.i pynb - 3_MRI_preprocessing/
05_GetMRIData_rsMRI_Parc , Jupyter, 1,228 linesellations.ipynb - 3_MRI_preprocessing/
06_GetMRI_rsMRI_Parcella , Jupyter, 178 linestions_Get2DMatrix.ipynb - 4_PLS/
01_PLS_MH_5Folds.ipynb , Jupyter, 329 lines, 2 matches - 4_PLS/
02_1_PLS_MH_SingleSplit. , Jupyter, 984 lines, 2 matchesipynb - repository limit reached (2,000 files or 30 MB): the rest is at the source (18 files)
The paper's code and data availability statement is in the Data section.
Tracing map
Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.
What the map holds:
- 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 14 scripts, each with its path and the digest of its content;
- 18 matches between paragraphs of the paper and lines of the code (method lexical-v1);
- neither the text of the paper nor the code itself.
Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.
Data
Datasets cited
- ukbiobank.ac.uk/
enable-your-research/ , at UK Biobank; found in “Data availability”apply-for-access
Data availability
This study used data from the UK Biobank resource (Application No. 70132). These data cannot be publicly shared by the authors due to legal and ethical restrictions imposed by UK Biobank. Access to individual-level data is governed by UK Biobank's data access policies, which are designed to protect participant confidentiality. Researchers can access the data by submitting an application directly to UK Biobank (https://
Reproduced under the paper's license (CC BY), from the paper cited above.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 1, 28 September 2026: the first record
Recorded: type, language, journal, volume, pages, dates, 4 authors, 6 keywords, 12 MeSH terms, 4 funders, 228 references.
Cite
This paper
Buianova, I., Silvestrin, M., Deng, J. D., & Pat, N. (2026). Multimodal MRI marker of cognition explains the association between cognition and mental health in the UK Biobank. eLife, 14, RP108109. https://
BibTeX
@article{buianova2026mul
author = {Buianova, Irina and Silvestrin, Mateus and Deng, Jeremiah D and Pat, Narun},
title = {{Multimodal MRI marker of cognition explains the association between cognition and mental health in the UK Biobank}},
journal = {eLife},
year = {2026},
month = may,
volume = {14},
pages = {RP108109},
publisher = {eLife Sciences Publications, Ltd},
issn = {2050-084X},
doi = {10.7554/
url = {https://
pmid = {42160203},
pmcid = {PMC13189626}
}
RIS
TY - JOUR
AU - Buianova, Irina
AU - Silvestrin, Mateus
AU - Deng, Jeremiah D
AU - Pat, Narun
TI - Multimodal MRI marker of cognition explains the association between cognition and mental health in the UK Biobank
T2 - eLife
J2 - Elife
PY - 2026
DA - 2026/
VL - 14
SP - RP108109
SN - 2050-084X
PB - eLife Sciences Publications, Ltd
DO - 10.7554/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.7554/
"type": "article-journal",
"title": "Multimodal MRI marker of cognition explains the association between cognition and mental health in the UK Biobank",
"container-title": "eLife",
"author": [
{
"family": "Buianova",
"given": "Irina"
},
{
"family": "Silvestrin",
"given": "Mateus"
},
{
"family": "Deng",
"given": "Jeremiah D"
},
{
"family": "Pat",
"given": "Narun"
}
],
"container-title-short":
"volume": "14",
"page": "RP108109",
"DOI": "10.7554/
"PMID": "42160203",
"PMCID": "PMC13189626",
"ISSN": "2050-084X",
"publisher": "eLife Sciences Publications, Ltd",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
5,
20
]
]
}
}
The tracing map gets a citation of its own once an author has validated it and it has a DOI.
Similar papers
The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.
- [1] doi:10.1038/s41514-026-00456-9 [code]
- Exploring the link between body physiology and cognition: the role of the brain and aging.Journal: npj agingIn common: lavaan, psych, data.table, 7 other tools, cognitive, 34 references
- [2] doi:10.1038/s44220-026-00680-y [code]
- The neuroimaging correlates of depression established across six large-scale population datasets.Journal: Nature. Mental healthIn common: ggplot2, seaborn, scikit-learn, 4 other tools, ukbiobank.ac.uk/enable-your-research/apply-for-access, 9 references
- [3] doi:10.1162/imag.a.1325 [code]
- Decoding everyday levels of musical training from subcortical white-matter architecture.Journal: Imaging neuroscience (Cambridge, Mass.)In common: lavaan, psych, ggplot2, 5 other tools, structural MRI / diffusion, 8 references
- [4] doi:10.1038/s41467-026-75661-x [code]
- A neural signature of sleep deprivation in the human brain.Journal: Nature communicationsIn common: seaborn, scikit-learn, pandas, 3 other tools, ukbiobank.ac.uk/enable-your-research/apply-for-access, cognitive, 7 references
- [5] doi:10.1126/sciadv.aec2348 [code]
- Congenital blindness reduces myelination in human visual cortex.Journal: Science advancesIn common: lavaan, data.table, ggplot2, 2 other tools, structural MRI / diffusion, 8 references
- [6] doi:10.1162/imag.a.1308 [code]
- Functional connectome signature of general psychopathology in middle-aged and older adults: Evidence from multi-cohort, multi-ethnic analyses.Journal: Imaging neuroscience (Cambridge, Mass.)In common: ggplot2, 10 references
- [7] doi:10.1038/s41467-026-73668-y [code]
- Convergent and divergent brain-cognition development in early adolescence.Journal: Nature communicationsIn common: ggplot2, seaborn, scikit-learn, 4 other tools, 7 references
- [8] doi:10.1038/s41467-026-73072-6 [code]
- Mapping the spatiotemporal continuum of structural connectivity development across the human connectome in youth.Journal: Nature communicationsIn common: psych, ggplot2, pandas, 1 other tool, structural MRI / diffusion, 9 references
- [9] doi:10.1038/s42003-026-09956-6 [code]
- Linking changes in sulcal morphometry to cognitive development from childhood to adolescence.Journal: Communications biologyIn common: psych, ggplot2, seaborn, 5 other tools, structural MRI / diffusion, 5 references
- [10] doi:10.7554/elife.103097 [code]
- Canonical neurodevelopmental trajectories of structural and functional manifolds.Journal: eLifeIn common: data.table, ggplot2, scikit-learn, 3 other tools, structural MRI / diffusion, 7 references
Contribute
The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.
Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 14 scripts, and 18 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:ad83627fe1839896…
Add the badge to its README
The badge links the code to this page. Copy one of these into the README of the paper's code: only you decide where it goes, and nothing is changed for you.
Markdown
[, paste the snippet at the top, then “Commit changes…” and, to review it first, “Create a new branch and start a pull request”. You open the pull request; OSCR asks for no permission.
Request its removal
To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).
Discussion, reproductions, activity
Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.
Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
