OSCR

Neural Responses to Affective Sentences Reveal Signatures of Depression.

Code ↔ Paper

The paper beside its authors' code: matches between them have not been computed for this paper yet.

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

Python · 176 lines · 8.4 KB · no license

  1. import torch
  2. import json, os, sys, glob, pickle, csv, tqdm
  3. import numpy as np
  4. from sklearn.metrics import balanced_accuracy_score, f1_score, precision_score, recall_score, roc_auc_score, confusion_matrix, roc_curve
  5. from src.models.eegnet import eegnet, eegnet_late_fusion
  6. from src.models.rcnn import rcnn, rcnn_late_fusion, eegTransformer, eegTransformerLateFusion
  7. device = "cuda" if torch.cuda.is_available() else "cpu"
  8. label_map = {
  9. 0: "control",
  10. 1: "clinical"
  11. }
  12. def get_sensitivity_at_specificity(y_true, y_scores, target_specificity: float=0.7):
  13. fpr, tpr, thresholds = roc_curve(y_true, y_scores)
  14. specificity = 1 - fpr
  15. idx = np.argmin(np.abs(specificity - target_specificity))
  16. return tpr[idx]
  17. def load_model(model, checkpoint_path):
  18. checkpoint_dict = torch.load(checkpoint_path)
  19. model.load_state_dict(checkpoint_dict["model_state_dict"])
  20. model.to(device)
  21. model.eval()
  22. return model
  23. def inference_subjects(config_path,
  24. checkpoint_path,
  25. mode: str="test",
  26. custom_subject_path: str=None,
  27. test_all: bool=False):
  28. config = json.load(open(config_path, "r"))
  29. analytical_pipeline_list = list()
  30. conditions_list = []
  31. for condition in config["conditions"]:
  32. prefix = ""
  33. for k, values in condition.items():
  34. prefix += f"{k}-" + "-".join(values) + "_"
  35. prefix = prefix.strip("_")
  36. conditions_list.append(prefix)
  37. if config["model_type"] == "eegnet":
  38. if config["feature_type"] == "subtract":
  39. model = eegnet(**config["model_params"])
  40. elif config["feature_type"] == "late_fusion":
  41. model = eegnet_late_fusion(**config["model_params"])
  42. elif config["model_type"] == "rcnn":
  43. if config["feature_type"] == "subtract":
  44. model = rcnn(**config["model_params"])
  45. elif config["feature_type"] == "late_fusion":
  46. model = rcnn_late_fusion()
  47. elif config["model_type"] == "transformer":
  48. if config["feature_type"] == "subtract":
  49. model = eegTransformer(**config["model_params"])
  50. elif config["feature_type"] == "late_fusion":
  51. model = eegTransformerLateFusion(**config["model_params"])
  52. model = load_model(model, checkpoint_path)
  53. if mode == "test":
  54. if custom_subject_path is None:
  55. subjects_info_path = config["test_subjects_info_path"]
  56. else:
  57. subjects_info_path = custom_subject_path
  58. elif mode == "train":
  59. subjects_info_path = config["train_subjects_info_path"]
  60. subjects_info = json.load(open(subjects_info_path, "r"))
  61. labels_list, preds_list = list(), list()
  62. preds_conf_list = list()
  63. for subid, subject_info in subjects_info.items():
  64. if not test_all and str(subject_info["label"]) not in config["classification_groups"].keys():
  65. continue
  66. subject_files = []
  67. for condition in conditions_list:
  68. datadir_condition = os.path.join(config["datadir"], config["task"], f"{config['subdir']}-{config['percent_data_use']:.2f}", condition, subid)
  69. if "resample_rate" in config.keys():
  70. datadir_condition = os.path.join(config["datadir"], config["task"], f"{config['subdir']}-{config['percent_data_use']:.2f}-rate{config['resample_rate']}", condition, subid)
  71. if "n_trials_gen" in config.keys() and "n_trials_mean" in config.keys():
  72. datadir_condition = os.path.join(config["datadir"], config["task"], f"{config['subdir']}-{config['percent_data_use']:.2f}-ntrials-{config['n_trials_gen']}-nmean-{config['n_trials_mean']}-rate{config['resample_rate']}", condition, subid)
  73. condition_sub_files = glob.glob(datadir_condition + "/*.pkl")
  74. condition_sub_files.sort()
  75. subject_files.append(condition_sub_files)
  76. subject_files = list(zip(*subject_files))
  77. if len(subject_files) == 0:
  78. continue
  79. data_subject = []
  80. for subject_file in subject_files:
  81. if len(conditions_list) == 1:
  82. data_subject.append(pickle.load(open(subject_file[0], "rb"))["data"])
  83. elif len(conditions_list) == 2:
  84. if config["feature_type"] == "subtract":
  85. data_subject.append(pickle.load(open(subject_file[0], "rb"))["data"] - pickle.load(open(subject_file[1], "rb"))["data"])
  86. elif config["feature_type"] == "late_fusion":
  87. data_subject.append([pickle.load(open(subject_file[0], "rb"))["data"], pickle.load(open(subject_file[1], "rb"))["data"]])
  88. with torch.no_grad():
  89. if config["feature_type"] == "late_fusion":
  90. data_subject_tensor = list()
  91. data_subject_tensor.append(torch.tensor(np.array([d[0] for d in data_subject]), dtype=torch.float32).to(device))
  92. data_subject_tensor.append(torch.tensor(np.array([d[1] for d in data_subject]), dtype=torch.float32).to(device))
  93. outputs = model(data_subject_tensor)
  94. else:
  95. if "spatial_region" not in config.keys():
  96. data_subject = np.array(data_subject, dtype=np.float32)[:, :, :int((200 + config.get("max_time", 1000))/5)]
  97. else:
  98. channels_dict = json.load(open(config["spatial_info_path"], "r"))
  99. channel_picks = channels_dict[config["spatial_region"]]
  100. data_subject = np.array(data_subject, dtype=np.float32)[:, channel_picks, :int((200 + config.get("max_time", 1000))/5)]
  101. outputs = model(torch.tensor(data_subject).to(device))
  102. preds = torch.argmax(outputs, dim=-1).detach().cpu().numpy()
  103. outputs_conf = outputs.detach().cpu().numpy()
  104. outputs_conf = outputs_conf[np.where(np.abs(outputs_conf[:, 0] - outputs_conf[:, 1]) > 0.2)]
  105. labels_list.append(config["classification_groups"][str(subject_info["label"])] if str(subject_info["label"]) in config["classification_groups"].keys() else 1)
  106. preds_list.append(np.sum(preds)/len(data_subject))
  107. preds_conf_list.append(np.sum(np.argmax(outputs_conf, axis=-1))/outputs_conf.shape[0])
  108. analytical_pipeline_list.append({
  109. "subID": subid,
  110. "Task": "sen",
  111. "Probability": np.sum(preds)/len(data_subject),
  112. "Prediction": int(np.sum(preds)/len(data_subject)> 0.5),
  113. "label": str(subject_info["label"]),
  114. "Ground Truth": config["classification_groups"][str(subject_info["label"])] if str(subject_info["label"]) in config["classification_groups"].keys() else 1,
  115. "Score": int(np.sum(preds)/len(data_subject)> 0.5) == int(config["classification_groups"][str(subject_info["label"])] if str(subject_info["label"]) in config["classification_groups"].keys() else 1)
  116. })
  117. rocauc = roc_auc_score(np.array(labels_list), np.array(preds_list))
  118. tn, fp, fn, tp = confusion_matrix(np.array(labels_list), np.array(preds_list)>0.5).ravel()
  119. sensitivity_05 = tp / (tp + fn)
  120. specificity = tn / (tn + fp)
  121. bac = balanced_accuracy_score(np.array(labels_list), np.array(preds_list)>0.5)
  122. f1 = f1_score(np.array(labels_list), np.array(preds_list)>0.5)
  123. sensitivity = get_sensitivity_at_specificity(np.array(labels_list), np.array(preds_list), 0.7)
  124. results_dict = {
  125. "BAC": bac,
  126. "AUC": rocauc,
  127. "sensitivity": sensitivity_05,
  128. "specificity": specificity,
  129. "f1": f1
  130. }
  131. if not test_all:
  132. json.dump(results_dict, open(os.path.join(os.path.dirname(checkpoint_path), "results.json"), "w"), indent=4)
  133. if test_all:
  134. csv_file_path = os.path.join(os.path.dirname(checkpoint_path), "analytical_pipeline_all.csv")
  135. else:
  136. csv_file_path = os.path.join(os.path.dirname(checkpoint_path), "analytical_pipeline.csv")
  137. header = analytical_pipeline_list[0].keys()
  138. with open(csv_file_path, mode='w', newline='') as file:
  139. writer = csv.DictWriter(file, fieldnames=header)
  140. writer.writeheader()
  141. writer.writerows(analytical_pipeline_list)
  142. if __name__ == "__main__":
  143. checkpoint_dir = sys.argv[1]
  144. checkpoint_paths = glob.glob(checkpoint_dir + "/*/*/best.pt")
  145. checkpoint_paths.sort()
  146. for checkpoint_path in tqdm.tqdm(checkpoint_paths):
  147. config_path = os.path.join(os.path.dirname(checkpoint_path), "config.json")
  148. # get the inference on the test subjects
  149. inference_subjects(config_path, checkpoint_path, test_all=False)

get_inference_subjects.py at commit 680c06b, no license · at the source

Overview

Authors: Aditya Kommineni1, Woojae Jeong1,2, Kleanthis Avramidis3, Colin McDaniel4, Myzelle Hughes4, Thomas McGee5, Elsi Kaiser6, Kristina Lerman3, Idan A. Blank5, Dani Byrd6, Assal Habibi4, B. Rael Cahn4,7, Sudarsana Kadiri1, Takfarinas Medani1, Richard M. Leahy1, Shrikanth Narayanan1,3,6,8
  1. Ming Hsieh Department of Electrical and Computer Engineering, University of Southern California,Los Angeles, USA
  2. Alfred E. Mann Department of Biomedical Engineering, University of Southern California,Los Angeles, USA
  3. Thomas Lord Department of Computer Science, University of Southern California,Los Angeles, USA
  4. Brain and Creativity Institute, University of Southern California,Los Angeles, USA
  5. Department of Psychology, University of California Los Angeles,Los Angeles, USA
  6. Department of Linguistics, University of Southern California,Los Angeles, USA
  7. Department of Psychiatry and Behavioral Sciences, University of Southern California,Los Angeles, USA
  8. Department of Psychology, University of Southern California,Los Angeles, USA
Institutions: University of Southern California (United States); University of California, Los Angeles (United States)
Journal: Translational psychiatry, volume 16, issue 1, article 347
Dates: received 27 June 2025; accepted 30 April 2026; published online 15 May 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1038/s41398-026-04079-2 · PMID 42140957 · PMCID PMC13346668 · OpenAlex W4417097885
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: EEG (modality), human (organism), depression (population)
Methods: Machine learning, Evoked potentials, Statistics
Keywords: Depression, Diagnostic markers
MeSH: Affect*, Brain*, Emotions*, Major Depressive Disorder*, Adult, Deep Learning, Electroencephalography, Female, Humans, Male, Semantics, Suicidal Ideation, Young Adult (* major topic)
Topic: Mental Health via Writing (Social Psychology, Psychology), according to OpenAlex
Citations: cited by 1 paper (Europe PMC); 53 references in the paper

Abstract

The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.

Repository

Its files are read in the Code ↔ Paper reader above.

Uncertain-Quark/eeg_depression_classification_tpsych

License: none: the authors keep all their rights
State: the link answers, verified on 28 September 2026
Evidence: files inventoried
Commit: 680c06bf3ea8190044b8c8b31faef0abdcfd84e1, 24 November 2025
Languages: Python (15), Shell (1)
Size: 19 files, 16 scripts
Software Heritage: not archived
Found in: “Code availability”
Holds: README
Not found: license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: NumPy (8 files), PyTorch (7 files), pandas (5 files), scikit-learn (5 files), SciPy (3 files), Matplotlib (1 file), seaborn (1 file), statsmodels (1 file)
Availability: 1 check, the latest on 28 September 2026: the link answers
  • 28 September 2026: the link answers
17 files

Code availability statement

The paper has a code availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

Read it in the paper: doi.org/10.1038/s41398-026-04079-2.

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;
  • 16 scripts, each with its path and the digest of its content;
  • no match between paragraphs and code yet;
  • 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

No dataset and no data link were found in the paper.

Data availability statement

The paper has a data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

  • it says that the data are available on request

Read it in the paper: doi.org/10.1038/s41398-026-04079-2.

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, issue, pages, dates, 16 authors, 2 keywords, 13 MeSH terms, 1 funder, 50 references.

Cite

This paper

Kommineni, A., Jeong, W., Avramidis, K., McDaniel, C., Hughes, M., McGee, T., Kaiser, E., Lerman, K., Blank, I. A., Byrd, D., Habibi, A., Cahn, B. R., Kadiri, S., Medani, T., Leahy, R. M., & Narayanan, S. (2026). Neural Responses to Affective Sentences Reveal Signatures of Depression. Translational psychiatry, 16(1), 347. https://doi.org/10.1038/s41398-026-04079-2

BibTeX

@article{kommineni2026neural,
author = {Kommineni, Aditya and Jeong, Woojae and Avramidis, Kleanthis and McDaniel, Colin and Hughes, Myzelle and McGee, Thomas and Kaiser, Elsi and Lerman, Kristina and Blank, Idan A. and Byrd, Dani and Habibi, Assal and Cahn, B. Rael and Kadiri, Sudarsana and Medani, Takfarinas and Leahy, Richard M. and Narayanan, Shrikanth},
title = {{Neural Responses to Affective Sentences Reveal Signatures of Depression}},
journal = {Translational psychiatry},
year = {2026},
month = may,
volume = {16},
number = {1},
pages = {347},
publisher = {Nature Publishing Group},
issn = {2158-3188},
doi = {10.1038/s41398-026-04079-2},
url = {https://doi.org/10.1038/s41398-026-04079-2},
pmid = {42140957},
pmcid = {PMC13346668}
}

RIS

TY - JOUR
AU - Kommineni, Aditya
AU - Jeong, Woojae
AU - Avramidis, Kleanthis
AU - McDaniel, Colin
AU - Hughes, Myzelle
AU - McGee, Thomas
AU - Kaiser, Elsi
AU - Lerman, Kristina
AU - Blank, Idan A.
AU - Byrd, Dani
AU - Habibi, Assal
AU - Cahn, B. Rael
AU - Kadiri, Sudarsana
AU - Medani, Takfarinas
AU - Leahy, Richard M.
AU - Narayanan, Shrikanth
TI - Neural Responses to Affective Sentences Reveal Signatures of Depression
T2 - Translational psychiatry
J2 - Transl Psychiatry
PY - 2026
DA - 2026/05/15
VL - 16
IS - 1
SP - 347
SN - 2158-3188
PB - Nature Publishing Group
DO - 10.1038/s41398-026-04079-2
UR - https://doi.org/10.1038/s41398-026-04079-2
LA - en
ER -

CSL-JSON

{
"id": "10.1038/s41398-026-04079-2",
"type": "article-journal",
"title": "Neural Responses to Affective Sentences Reveal Signatures of Depression",
"container-title": "Translational psychiatry",
"author": [
{
"family": "Kommineni",
"given": "Aditya"
},
{
"family": "Jeong",
"given": "Woojae"
},
{
"family": "Avramidis",
"given": "Kleanthis"
},
{
"family": "McDaniel",
"given": "Colin"
},
{
"family": "Hughes",
"given": "Myzelle"
},
{
"family": "McGee",
"given": "Thomas"
},
{
"family": "Kaiser",
"given": "Elsi"
},
{
"family": "Lerman",
"given": "Kristina"
},
{
"family": "Blank",
"given": "Idan A."
},
{
"family": "Byrd",
"given": "Dani"
},
{
"family": "Habibi",
"given": "Assal"
},
{
"family": "Cahn",
"given": "B. Rael"
},
{
"family": "Kadiri",
"given": "Sudarsana"
},
{
"family": "Medani",
"given": "Takfarinas"
},
{
"family": "Leahy",
"given": "Richard M."
},
{
"family": "Narayanan",
"given": "Shrikanth"
}
],
"container-title-short": "Transl Psychiatry",
"volume": "16",
"issue": "1",
"page": "347",
"DOI": "10.1038/s41398-026-04079-2",
"PMID": "42140957",
"PMCID": "PMC13346668",
"ISSN": "2158-3188",
"publisher": "Nature Publishing Group",
"URL": "https://doi.org/10.1038/s41398-026-04079-2",
"language": "en",
"issued": {
"date-parts": [
[
2026,
5,
15
]
]
}
}

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/s42003-026-10108-z [code]
Time-resolved EEG decoding reveals altered neural dynamics of affective semantic evaluation in depression and suicidality.
Journal: Communications biology
In common: statsmodels, seaborn, scikit-learn, 4 other tools, depression, EEG, 23 references, 4 authors
[2] doi:10.1038/s41467-026-72253-7 [code]
Spurious alignment between large language models and brains can emerge from non-robust methods and overlooked confounds.
Journal: Nature communications
In common: PyTorch, seaborn, scikit-learn, 4 other tools, author Idan Blank
[3] doi:10.1038/s41597-025-05174-7 [code]
A large-scale MEG and EEG dataset for object recognition in naturalistic scenes
Journal: n/a
In common: PyTorch, seaborn, scikit-learn, 4 other tools, EEG, 2 references
[4] doi:10.1038/s41380-026-03691-4 [code]
Breaking the norm: population-scale deviations of brain structure in depression and anxiety.
Journal: Molecular psychiatry
In common: statsmodels, PyTorch, seaborn, 5 other tools, depression, 1 reference
[5] doi:10.1523/eneuro.0254-25.2026 [code]
Spatiotemporal Dynamics in Prespeech Semantic Category Decoding: An Intracranial EEG Study.
Journal: eNeuro
In common: statsmodels, seaborn, scikit-learn, 4 other tools, 2 references
[6] doi:10.1038/s41598-026-56688-y [code]
On the value of radiomics in addition to clinical measures in emotional conflict fMRI for predicting sertraline response in major depressive disorder.
Journal: Scientific reports
In common: statsmodels, seaborn, scikit-learn, 4 other tools, depression, 1 reference
[7] doi:10.7554/elife.107933 [code]
Modality-agnostic decoding of vision and language from fMRI.
Journal: eLife
In common: statsmodels, PyTorch, seaborn, 5 other tools, 1 reference
[8] doi:10.1038/s43856-026-01395-y [code]
Enhancing depression diagnosis with augmented brain signal driven decorrelated graph neural networks.
Journal: Communications medicine
In common: PyTorch, scikit-learn, pandas, 2 other tools, depression, 2 references
[9] doi:10.1016/j.isci.2026.116825 [code]
Social hierarchy shapes behavioral and transcriptional responses to chronic stress and ketamine in male mice.
Journal: iScience
In common: statsmodels, PyTorch, seaborn, 5 other tools, depression
[10] doi:10.3390/s26103065 [code]
Subject-Wise Depression Screening from Eight-Channel Resting-State EEG Using Asymmetry-Aware Spectral Features and Connectivity Ablation.
Journal: Sensors (Basel, Switzerland)
In common: PyTorch, scikit-learn, pandas, 3 other tools, depression, EEG, 1 reference

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.

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.