OSCR

Multimodal multicentre investigation of diagnostic and prognostic markers in disorders of consciousness.

Code ↔ Paper

4 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 4 matches
  1. [1] § Results › Feature importance differs in diagnostic and prognostic models ↔ modeling/01_efm_model-results.py, lines 108–165 · score 0.82 · symbolic mutual information, permutation entropy, Kolmogorov complexity, half brain, EEG RS, beta
  2. [2] § Results › Feature importance differs in diagnostic and prognostic models ↔ modeling/07_auc_ci_per_feature.py, lines 209–245 · score 0.77 · symbolic mutual information, permutation entropy, Kolmogorov complexity, EEG RS, beta, evoked
  3. [3] § Results › Feature importance differs in diagnostic and prognostic models ↔ fmri_markers/fmri_functions.py, lines 217–324 · score 0.64 · connectivity features, subcortical areas, subcortical regions, limbic, volume, network
  4. [4] § Results › Multimodal integration improves predictive accuracy ↔ modeling/06_efm_model_outputs_and_surrogates_plots_generalization.py, lines 60–113 · score 0.53 · Mann Whitney, Bonferroni corrected, Balanced accuracy, model, modalities

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 · 1,276 lines · 58 KB · no license · 1 match

  1. #%%
  2. import seaborn as sns
  3. import pandas as pd
  4. import matplotlib.pyplot as plt
  5. import numpy as np
  6. import os
  7. import seaborn as sns
  8. import nibabel as nib
  9. from nilearn import datasets
  10. from nilearn.datasets import fetch_atlas_harvard_oxford
  11. from nilearn import plotting
  12. from pdf2image import convert_from_path
  13. # %%
  14. base_path = '/home/Documents/codes/permed'
  15. efm_figs_dir = os.path.join(base_path, '00_derivatives/model_outputs/EarlyFusionMultimodal/figs')
  16. surrogates_analysis = False
  17. clinical_prediction = 'diagnosis' # '6m1y2y-prognosis' # 'diagnosis'
  18. name_ext=f'single-mods_allmod-per-patient_norfe_rskf_{clinical_prediction}_RandomForestClassifier'
  19. if clinical_prediction == '6m1y2y-prognosis': name_ext = name_ext + '_no-lata'
  20. if surrogates_analysis: name_ext = f'{name_ext}_surrogates'
  21. metric = 'balanced_accuracy'
  22. df_efm= pd.read_csv(os.path.join(base_path,
  23. f'00_derivatives/model_outputs/EarlyFusionMultimodal/csvs/efm_{name_ext}_folds-500.csv'))
  24. df_efm_fi = pd.read_csv(os.path.join(base_path,
  25. f'00_derivatives/model_outputs/EarlyFusionMultimodal/csvs/efm_feat-importances_{name_ext}_folds-500.csv'))
  26. df_efm_fi.set_index('Unnamed: 0', inplace=True)
  27. # %%
  28. eeg_rs_features = list(np.load(os.path.join(base_path, '00_derivatives/intermediate/eeg_rs_features.npy'), allow_pickle=True))
  29. eeg_lg_features = list(np.load(os.path.join(base_path, '00_derivatives/intermediate/eeg_lg_features.npy'), allow_pickle=True))
  30. anat_features = list(np.load(os.path.join(base_path, '00_derivatives/intermediate/anat_features.npy'), allow_pickle=True))[1:]
  31. func_rs_features = list(np.load(os.path.join(base_path, '00_derivatives/intermediate/func_rs_features.npy'), allow_pickle=True))[1:]
  32. dti_features = list(np.load(os.path.join(base_path, '00_derivatives/intermediate/dti_features.npy'), allow_pickle=True))
  33. pet_features = list(np.load(os.path.join(base_path, '00_derivatives/intermediate/pet_features.npy'), allow_pickle=True))
  34. # %%
  35. df_efm
  36. # in df_efm create a column with the difference between the accuracy and balanced accuracy and plot the violin plot
  37. df_efm['diff_acc_bal_acc'] = df_efm['accuracy'] - df_efm['balanced_accuracy']
  38. df_efm['diff_acc_bal_acc'].describe()
  39. # %%
  40. sns.set_theme()
  41. sns.set_context("paper")
  42. sns.set_style("white")
  43. metric = 'auc' # 'auc' 'balanced_accuracy'
  44. # %%
  45. # Separate the feature importances per modality
  46. # From df_efm_fi keep only the rows that have /rs/ in the index name, and eeg_rs in the column name
  47. fi_eeg_rs = df_efm_fi[df_efm_fi.index.str.contains('/rs/')]
  48. fi_eeg_rs = fi_eeg_rs[fi_eeg_rs.columns[fi_eeg_rs.columns.str.contains('eeg_rs')]]
  49. fi_eeg_lg = df_efm_fi[df_efm_fi.index.str.contains('/lg/')]
  50. fi_eeg_lg = fi_eeg_lg[fi_eeg_lg.columns[fi_eeg_lg.columns.str.contains('eeg_lg')]]
  51. fi_anat = df_efm_fi[df_efm_fi.index.str.contains('anat_')]
  52. fi_anat = fi_anat[fi_anat.columns[fi_anat.columns.str.contains('anat')]]
  53. fi_func = df_efm_fi[df_efm_fi.index.str.contains('func-')]
  54. fi_func = fi_func[fi_func.columns[fi_func.columns.str.contains('func')]]
  55. fi_dti = df_efm_fi[df_efm_fi.index.str.contains('maskJHU')]
  56. fi_dti = fi_dti.append(df_efm_fi[df_efm_fi.index.str.contains('fa_global')])
  57. fi_dti = fi_dti.append(df_efm_fi[df_efm_fi.index.str.contains('md_global')])
  58. fi_dti = fi_dti[fi_dti.columns[fi_dti.columns.str.contains('dti')]]
  59. fi_pet = df_efm_fi[df_efm_fi.index.str.contains('pet_')]
  60. fi_pet = fi_pet[fi_pet.columns[fi_pet.columns.str.contains('pet')]]
  61. # %%
  62. fi_eeg_rs_mean_std = fi_eeg_rs.copy().apply(lambda x: pd.Series({"mean":x.mean(),"std":x.std()}), axis = 1)
  63. fi_eeg_rs_mean_std_sorted = fi_eeg_rs_mean_std.sort_values(by='mean', ascending=False, inplace=False)
  64. fi_eeg_lg_mean_std = fi_eeg_lg.copy().apply(lambda x: pd.Series({"mean":x.mean(),"std":x.std()}), axis = 1)
  65. fi_eeg_lg_mean_std_sorted = fi_eeg_lg_mean_std.sort_values(by='mean', ascending=False, inplace=False)
  66. fi_anat_mean_std = fi_anat.copy().apply(lambda x: pd.Series({"mean":x.mean(),"std":x.std()}), axis = 1)
  67. fi_anat_mean_std_sorted = fi_anat_mean_std.sort_values(by='mean', ascending=False, inplace=False)
  68. fi_func_mean_std = fi_func.copy().apply(lambda x: pd.Series({"mean":x.mean(),"std":x.std()}), axis = 1)
  69. fi_func_mean_std_sorted = fi_func_mean_std.sort_values(by='mean', ascending=False, inplace=False)
  70. fi_dti_mean_std = fi_dti.copy().apply(lambda x: pd.Series({"mean":x.mean(),"std":x.std()}), axis = 1)
  71. fi_dti_mean_std_sorted = fi_dti_mean_std.sort_values(by='mean', ascending=False, inplace=False)
  72. fi_pet_mean_std = fi_pet.copy().apply(lambda x: pd.Series({"mean":x.mean(),"std":x.std()}), axis = 1)
  73. fi_pet_mean_std_sorted = fi_pet_mean_std.sort_values(by='mean', ascending=False, inplace=False)
  74. # Summarizing feat importances per cortical networks and subcortical
  75. # or by conceptual families etc
  76. sns.set_context("talk")
  77. plot_feature_groups = True
  78. if plot_feature_groups:
  79. nets = ['Cont', 'Default', 'DorsAttn', 'Limbic', 'SalVentAttn', 'SomMot', 'Vis']
  80. ###### DISTRIBUTIONS
  81. # aMRI
  82. anat = fi_anat_mean_std['mean'].to_frame()
  83. # Add the 'region_groups' column
  84. anat['region_groups'] = anat.index.to_series().apply(
  85. lambda x: next((net for net in nets if net in x), 'Subcortical' if any(sub in x for sub in ['stem', 'left', 'right']) else 'Other')
  86. )
  87. # pet
  88. pet = fi_pet_mean_std['mean'].to_frame()
  89. # Add the 'region_groups' column
  90. pet['region_groups'] = pet.index.to_series().apply(
  91. lambda x: next((net for net in nets if net in x), 'Subcortical' if any(sub in x for sub in ['Stem', 'Left', 'Right']) else 'Other')
  92. )
  93. # add the value 'Half Brain' in the column region_groups for the features that contain 'high_mi' or 'low_mi'
  94. pet.loc[pet.index.str.contains('high_mi|low_mi'), 'region_groups'] = 'Half Brain'
  95. # func
  96. func = fi_func_mean_std['mean'].to_frame()
  97. def assign_region_group(x):
  98. if any(sub in x for sub in ['subcortical', 'Left', 'Right', 'Stem']):
  99. return 'Subcortical'
  100. elif 'sub-to-cort' in x:
  101. return 'Subcortical to Cortical'
  102. else:
  103. return next((net for net in nets if net in x), 'Other')
  104. func['region_groups'] = func.index.to_series().apply(assign_region_group)
  105. # EEG RS
  106. # 3 divisions (code in the 021_efm_model-results.py)
  107. # 5 divisions
  108. eeg_rs = fi_eeg_rs_mean_std['mean'].to_frame()
  109. def assign_region_group(x):
  110. if 'PowerSpectralDensity' in x:
  111. if any(sub in x for sub in ['delta', 'theta', 'alpha']):
  112. return 'Spectral: Low'
  113. elif any(sub in x for sub in ['beta', 'gamma']):
  114. return 'Spectral: High'
  115. else:
  116. return 'Spectral: Other'
  117. elif 'SymbolicMutualInformation' in x:
  118. return 'Connectivity'
  119. elif any(sub in x for sub in ['KolmogorovComplexity', 'PermutationEntropy']):
  120. return 'Information theory'
  121. else:
  122. return 'Other'
  123. eeg_rs['region_groups'] = eeg_rs.index.to_series().apply(assign_region_group)
  124. # EEG LG
  125. eeg_lg = fi_eeg_lg_mean_std['mean'].to_frame()
  126. def assign_region_group(x):
  127. if 'PowerSpectralDensity' in x:
  128. if any(sub in x for sub in ['delta', 'theta', 'alpha']):
  129. return 'Spectral: Low'
  130. elif any(sub in x for sub in ['beta', 'gamma']):
  131. return 'Spectral: High'
  132. else:
  133. return 'Spectral: Other'
  134. elif 'SymbolicMutualInformation' in x:
  135. return 'Connectivity'
  136. elif any(sub in x for sub in ['KolmogorovComplexity', 'PermutationEntropy']):
  137. return 'Information theory'
  138. elif any(sub in x for sub in ['TimeLockedTopography', 'TimeLockedContrast', 'ContingentNegativeVariation', 'WindowDecoding']):
  139. return 'Evoked'
  140. else:
  141. return 'Other'
  142. eeg_lg['region_groups'] = eeg_lg.index.to_series().apply(assign_region_group)
  143. # DTI
  144. dti = fi_dti_mean_std['mean'].to_frame()
  145. region_dict = {
  146. "maskJHU_FA_1_MCP": "Brainstem",
  147. "maskJHU_FA_2_PCT": "Brainstem",
  148. "maskJHU_FA_3_gCC": "Commissural fibers",
  149. "maskJHU_FA_4_bCC": "Commissural fibers",
  150. "maskJHU_FA_5_sCC": "Commissural fibers",
  151. "maskJHU_FA_7_CST_R": "Brainstem",
  152. "maskJHU_FA_8_CST_L": "Brainstem",
  153. "maskJHU_FA_9_mLEM_R": "Brainstem",
  154. "maskJHU_FA_10_mLEM_L": "Brainstem",
  155. "maskJHU_FA_11_ICP_R": "Brainstem",
  156. "maskJHU_FA_12_ICP_L": "Brainstem",
  157. "maskJHU_FA_13_SCP_R": "Brainstem",
  158. "maskJHU_FA_14_SCP_L": "Brainstem",
  159. "maskJHU_FA_15_CP_R": "Projection fibers",
  160. "maskJHU_FA_16_CP_L": "Projection fibers",
  161. "maskJHU_FA_17_ALIC_R": "Projection fibers",
  162. "maskJHU_FA_18_ALIC_L": "Projection fibers",
  163. "maskJHU_FA_19_PLIC_R": "Projection fibers",
  164. "maskJHU_FA_20_PLIC_L": "Projection fibers",
  165. "maskJHU_FA_21_RLIC_R": "Projection fibers",
  166. "maskJHU_FA_22_RLIC_L": "Projection fibers",
  167. "maskJHU_FA_23_ACR_R": "Projection fibers",
  168. "maskJHU_FA_24_ACR_L": "Projection fibers",
  169. "maskJHU_FA_25_SCR_R": "Projection fibers",
  170. "maskJHU_FA_26_SCR_L": "Projection fibers",
  171. "maskJHU_FA_27_PCR_R": "Projection fibers",
  172. "maskJHU_FA_28_PCR_L": "Projection fibers",
  173. "maskJHU_FA_29_PTR_R": "Projection fibers",
  174. "maskJHU_FA_30_PTR_L": "Projection fibers",
  175. "maskJHU_FA_31_ILF_IFOF_R": "Associative fibers",
  176. "maskJHU_FA_32_ILF_IFOF_L": "Associative fibers",
  177. "maskJHU_FA_33_EC_R": "Associative fibers",
  178. "maskJHU_FA_34_EC_L": "Associative fibers",
  179. "maskJHU_FA_35_Cing_R": "Associative fibers",
  180. "maskJHU_FA_36_Cing_L": "Associative fibers",
  181. "maskJHU_FA_37_Cing_h_R": "Associative fibers",
  182. "maskJHU_FA_38_Cing_h_L": "Associative fibers",
  183. "maskJHU_FA_41_SLF_R": "Associative fibers",
  184. "maskJHU_FA_42_SLF_L": "Associative fibers",
  185. "maskJHU_FA_43_SFOF_R": "Associative fibers",
  186. "maskJHU_FA_44_SFOF_L": "Associative fibers",
  187. "maskJHU_FA_45_UNC_R": "Associative fibers",
  188. "maskJHU_FA_46_UNC_L": "Associative fibers",
  189. "maskJHU_MD_1_MCP": "Brainstem",
  190. "maskJHU_MD_2_PCT": "Brainstem",
  191. "maskJHU_MD_3_gCC": "Commissural fibers",
  192. "maskJHU_MD_4_bCC": "Commissural fibers",
  193. "maskJHU_MD_5_sCC": "Commissural fibers",
  194. "maskJHU_MD_7_CST_R": "Brainstem",
  195. "maskJHU_MD_8_CST_L": "Brainstem",
  196. "maskJHU_MD_9_mLEM_R": "Brainstem",
  197. "maskJHU_MD_10_mLEM_L": "Brainstem",
  198. "maskJHU_MD_11_ICP_R": "Brainstem",
  199. "maskJHU_MD_12_ICP_L": "Brainstem",
  200. "maskJHU_MD_13_SCP_R": "Brainstem",
  201. "maskJHU_MD_14_SCP_L": "Brainstem",
  202. "maskJHU_MD_15_CP_R": "Projection fibers",
  203. "maskJHU_MD_16_CP_L": "Projection fibers",
  204. "maskJHU_MD_17_ALIC_R": "Projection fibers",
  205. "maskJHU_MD_18_ALIC_L": "Projection fibers",
  206. "maskJHU_MD_19_PLIC_R": "Projection fibers",
  207. "maskJHU_MD_20_PLIC_L": "Projection fibers",
  208. "maskJHU_MD_21_RLIC_R": "Projection fibers",
  209. "maskJHU_MD_22_RLIC_L": "Projection fibers",
  210. "maskJHU_MD_23_ACR_R": "Projection fibers",
  211. "maskJHU_MD_24_ACR_L": "Projection fibers",
  212. "maskJHU_MD_25_SCR_R": "Projection fibers",
  213. "maskJHU_MD_26_SCR_L": "Projection fibers",
  214. "maskJHU_MD_27_PCR_R": "Projection fibers",
  215. "maskJHU_MD_28_PCR_L": "Projection fibers",
  216. "maskJHU_MD_29_PTR_R": "Projection fibers",
  217. "maskJHU_MD_30_PTR_L": "Projection fibers",
  218. "maskJHU_MD_31_ILF_IFOF_R": "Associative fibers",
  219. "maskJHU_MD_32_ILF_IFOF_L": "Associative fibers",
  220. "maskJHU_MD_33_EC_R": "Associative fibers",
  221. "maskJHU_MD_34_EC_L": "Associative fibers",
  222. "maskJHU_MD_35_Cing_R": "Associative fibers",
  223. "maskJHU_MD_36_Cing_L": "Associative fibers",
  224. "maskJHU_MD_37_Cing_h_R": "Associative fibers",
  225. "maskJHU_MD_38_Cing_h_L": "Associative fibers",
  226. "maskJHU_MD_41_SLF_R": "Associative fibers",
  227. "maskJHU_MD_42_SLF_L": "Associative fibers",
  228. "maskJHU_MD_43_SFOF_R": "Associative fibers",
  229. "maskJHU_MD_44_SFOF_L": "Associative fibers",
  230. "maskJHU_MD_45_UNC_R": "Associative fibers",
  231. "maskJHU_MD_46_UNC_L": "Associative fibers",
  232. "fa_global": "Global",
  233. "md_global": "Global"
  234. }
  235. region_dict_split = {
  236. "maskJHU_FA_1_MCP": "FA Brainstem",
  237. "maskJHU_FA_2_PCT": "FA Brainstem",
  238. "maskJHU_FA_3_gCC": "FA Commissural fibers",
  239. "maskJHU_FA_4_bCC": "FA Commissural fibers",
  240. "maskJHU_FA_5_sCC": "FA Commissural fibers",
  241. "maskJHU_FA_7_CST_R": "FA Brainstem",
  242. "maskJHU_FA_8_CST_L": "FA Brainstem",
  243. "maskJHU_FA_9_mLEM_R": "FA Brainstem",
  244. "maskJHU_FA_10_mLEM_L": "FA Brainstem",
  245. "maskJHU_FA_11_ICP_R": "FA Brainstem",
  246. "maskJHU_FA_12_ICP_L": "FA Brainstem",
  247. "maskJHU_FA_13_SCP_R": "FA Brainstem",
  248. "maskJHU_FA_14_SCP_L": "FA Brainstem",
  249. "maskJHU_FA_15_CP_R": "FA Projection fibers",
  250. "maskJHU_FA_16_CP_L": "FA Projection fibers",
  251. "maskJHU_FA_17_ALIC_R": "FA Projection fibers",
  252. "maskJHU_FA_18_ALIC_L": "FA Projection fibers",
  253. "maskJHU_FA_19_PLIC_R": "FA Projection fibers",
  254. "maskJHU_FA_20_PLIC_L": "FA Projection fibers",
  255. "maskJHU_FA_21_RLIC_R": "FA Projection fibers",
  256. "maskJHU_FA_22_RLIC_L": "FA Projection fibers",
  257. "maskJHU_FA_23_ACR_R": "FA Projection fibers",
  258. "maskJHU_FA_24_ACR_L": "FA Projection fibers",
  259. "maskJHU_FA_25_SCR_R": "FA Projection fibers",
  260. "maskJHU_FA_26_SCR_L": "FA Projection fibers",
  261. "maskJHU_FA_27_PCR_R": "FA Projection fibers",
  262. "maskJHU_FA_28_PCR_L": "FA Projection fibers",
  263. "maskJHU_FA_29_PTR_R": "FA Projection fibers",
  264. "maskJHU_FA_30_PTR_L": "FA Projection fibers",
  265. "maskJHU_FA_31_ILF_IFOF_R": "FA Associative fibers",
  266. "maskJHU_FA_32_ILF_IFOF_L": "FA Associative fibers",
  267. "maskJHU_FA_33_EC_R": "FA Associative fibers",
  268. "maskJHU_FA_34_EC_L": "FA Associative fibers",
  269. "maskJHU_FA_35_Cing_R": "FA Associative fibers",
  270. "maskJHU_FA_36_Cing_L": "FA Associative fibers",
  271. "maskJHU_FA_37_Cing_h_R": "FA Associative fibers",
  272. "maskJHU_FA_38_Cing_h_L": "FA Associative fibers",
  273. "maskJHU_FA_41_SLF_R": "FA Associative fibers",
  274. "maskJHU_FA_42_SLF_L": "FA Associative fibers",
  275. "maskJHU_FA_43_SFOF_R": "FA Associative fibers",
  276. "maskJHU_FA_44_SFOF_L": "FA Associative fibers",
  277. "maskJHU_FA_45_UNC_R": "FA Associative fibers",
  278. "maskJHU_FA_46_UNC_L": "FA Associative fibers",
  279. "maskJHU_MD_1_MCP": "MD Brainstem",
  280. "maskJHU_MD_2_PCT": "MD Brainstem",
  281. "maskJHU_MD_3_gCC": "MD Commissural fibers",
  282. "maskJHU_MD_4_bCC": "MD Commissural fibers",
  283. "maskJHU_MD_5_sCC": "MD Commissural fibers",
  284. "maskJHU_MD_7_CST_R": "MD Brainstem",
  285. "maskJHU_MD_8_CST_L": "MD Brainstem",
  286. "maskJHU_MD_9_mLEM_R": "MD Brainstem",
  287. "maskJHU_MD_10_mLEM_L": "MD Brainstem",
  288. "maskJHU_MD_11_ICP_R": "MD Brainstem",
  289. "maskJHU_MD_12_ICP_L": "MD Brainstem",
  290. "maskJHU_MD_13_SCP_R": "MD Brainstem",
  291. "maskJHU_MD_14_SCP_L": "MD Brainstem",
  292. "maskJHU_MD_15_CP_R": "MD Projection fibers",
  293. "maskJHU_MD_16_CP_L": "MD Projection fibers",
  294. "maskJHU_MD_17_ALIC_R": "MD Projection fibers",
  295. "maskJHU_MD_18_ALIC_L": "MD Projection fibers",
  296. "maskJHU_MD_19_PLIC_R": "MD Projection fibers",
  297. "maskJHU_MD_20_PLIC_L": "MD Projection fibers",
  298. "maskJHU_MD_21_RLIC_R": "MD Projection fibers",
  299. "maskJHU_MD_22_RLIC_L": "MD Projection fibers",
  300. "maskJHU_MD_23_ACR_R": "MD Projection fibers",
  301. "maskJHU_MD_24_ACR_L": "MD Projection fibers",
  302. "maskJHU_MD_25_SCR_R": "MD Projection fibers",
  303. "maskJHU_MD_26_SCR_L": "MD Projection fibers",
  304. "maskJHU_MD_27_PCR_R": "MD Projection fibers",
  305. "maskJHU_MD_28_PCR_L": "MD Projection fibers",
  306. "maskJHU_MD_29_PTR_R": "MD Projection fibers",
  307. "maskJHU_MD_30_PTR_L": "MD Projection fibers",
  308. "maskJHU_MD_31_ILF_IFOF_R": "MD Associative fibers",
  309. "maskJHU_MD_32_ILF_IFOF_L": "MD Associative fibers",
  310. "maskJHU_MD_33_EC_R": "MD Associative fibers",
  311. "maskJHU_MD_34_EC_L": "MD Associative fibers",
  312. "maskJHU_MD_35_Cing_R": "MD Associative fibers",
  313. "maskJHU_MD_36_Cing_L": "MD Associative fibers",
  314. "maskJHU_MD_37_Cing_h_R": "MD Associative fibers",
  315. "maskJHU_MD_38_Cing_h_L": "MD Associative fibers",
  316. "maskJHU_MD_41_SLF_R": "MD Associative fibers",
  317. "maskJHU_MD_42_SLF_L": "MD Associative fibers",
  318. "maskJHU_MD_43_SFOF_R": "MD Associative fibers",
  319. "maskJHU_MD_44_SFOF_L": "MD Associative fibers",
  320. "maskJHU_MD_45_UNC_R": "MD Associative fibers",
  321. "maskJHU_MD_46_UNC_L": "MD Associative fibers",
  322. "fa_global": "FA Global",
  323. "md_global": "MD Global"
  324. }
  325. dti['region_groups'] = dti.index.to_series().apply(lambda x: region_dict_split[x])
  326. #
  327. def plot_ordered_boxplot(df, modality_name, clin_pred, fig_name, arrows_plot=False, arrows_info=None,
  328. x_limits=None, x_ticks=None, x_tick_labels=None):
  329. """
  330. Plot a boxplot with the regions ordered by the mean of the feature importance.
  331. Parameters
  332. ----------
  333. df : DataFrame
  334. DataFrame with the feature importances.
  335. modality_name : str
  336. Name of the modality.
  337. clin_pred : str
  338. Clinical prediction.
  339. fig_name : str
  340. Name of the figure.
  341. arrows_plot : bool, optional
  342. If True, plot arrows in the plot. The default is False.
  343. arrows_info : list
  344. List of tuples with the number of arrows, color and location of the arrows in the plot.
  345. x_limits : tuple, optional
  346. Limits for the x-axis.
  347. x_ticks : list, optional
  348. Ticks for the x-axis.
  349. x_tick_labels : list, optional
  350. Labels for the x-axis ticks.
  351. """
  352. # Calculate the order
  353. order = df.groupby('region_groups')['mean'].mean().sort_values(ascending=False).index
  354. sns.boxplot(x='mean', y='region_groups', data=df, order=order, orient="h", color=".8")
  355. plt.xlabel("Mean Feature Importance")
  356. if clin_pred == 'diagnosis':
  357. plt.ylabel("Groups of Features")
  358. plt.title(f'Diagnosis: {modality_name}')
  359. else:
  360. plt.ylabel('')
  361. plt.title(f'Prognosis: {modality_name}')
  362. sns.despine(top=True, right=True)
  363. if x_limits:
  364. plt.xlim(x_limits)
  365. if x_ticks:
  366. plt.xticks(x_ticks)
  367. if x_tick_labels:
  368. plt.gca().set_xticklabels(x_tick_labels)
  369. if arrows_plot:
  370. # Add arrows to y-labels
  371. for i, (n_arrows, sign, location) in enumerate(arrows_info):
  372. color = 'green' if sign == '↑' else 'red'
  373. plt.text(location[0], location[1], str(n_arrows)+' x'+sign if n_arrows != 0 else '',
  374. color=color,
  375. va='center',
  376. ha='center',
  377. fontsize=12
  378. )
  379. plt.savefig(base_path+f'/00_derivatives/feature_importances_groups_{clin_pred}/{fig_name}.pdf',
  380. bbox_inches='tight')
  381. plt.show()
  382. if clinical_prediction == 'diagnosis':
  383. arrows_plot = False
  384. elif clinical_prediction == '6m1y2y-prognosis':
  385. arrows_plot = False # TODO changed
  386. fig_name = f'{clinical_prediction}_mean-groups'
  387. if arrows_plot:
  388. fig_name = fig_name + '_arrows-plot'
  389. # Define the tick limits, values, and labels based on the clinical prediction
  390. if clinical_prediction == 'diagnosis':
  391. eeg_rs_x_limits = (0, 0.05)
  392. eeg_rs_x_ticks = [0, 0.01, 0.02, 0.03, 0.04, 0.05]
  393. eeg_rs_x_tick_labels = ['0', '0.01', '0.02', '0.03', '0.04', '0.05']
  394. pet_x_limits = (0, 0.05)
  395. pet_x_ticks = [0, 0.01, 0.02, 0.03, 0.04, 0.05]
  396. pet_x_tick_labels = ['0', '0.01', '0.02', '0.03', '0.04', '0.05']
  397. elif clinical_prediction == '6m1y2y-prognosis':
  398. amri_x_limits = (0, 0.05)
  399. amri_x_ticks = [0, 0.01, 0.02, 0.03, 0.04, 0.05]
  400. amri_x_tick_labels = ['0', '0.01', '0.02', '0.03', '0.04', '0.05']
  401. # Plot the ordered boxplots with the specified tick limits, values, and labels
  402. plot_ordered_boxplot(anat, 'aMRI', clinical_prediction,
  403. f'{fig_name}_anat',
  404. arrows_plot=arrows_plot,
  405. arrows_info=[(7, '↑', (-0.0058, 0)), # Subcortical
  406. (1, '↑', (-0.006, 1)), # SalVentAttn
  407. (2, '↑', (-0.001, 2)), # Vis
  408. (3, '↑', (-0.003, 3)), # Limbic
  409. (1, '↑', (-0.002, 4)), # Cont
  410. (5, '↓', (-0.004, 5)), # SomMot
  411. (3, '↓', (-0.0045, 6)), # DorsAttn
  412. (6, '↓', (-0.0037, 7)) # Default
  413. ],
  414. x_limits=amri_x_limits if clinical_prediction == '6m1y2y-prognosis' else None,
  415. x_ticks=amri_x_ticks if clinical_prediction == '6m1y2y-prognosis' else None,
  416. x_tick_labels=amri_x_tick_labels if clinical_prediction == '6m1y2y-prognosis' else None)
  417. plot_ordered_boxplot(pet, 'PET', clinical_prediction,
  418. f'{fig_name}_pet',
  419. arrows_plot=arrows_plot,
  420. arrows_info=[(7, '↑', (-0.0075, 0)), # Subcortical
  421. (0, '', (-0.0008, 1)), # SomMot
  422. (4, '↑', (-0.004, 2)), # Cont
  423. (2, '↑', (-0.0065, 3)), # DorsAttn
  424. (1, '↓', (-0.0078, 4)), # SalVentAttn
  425. (3, '↑', (-0.005, 5)), # Limbic
  426. (2, '↓', (-0.0055, 6)), # Default
  427. (5, '↓', (-0.003, 7)), # Vis
  428. (8, '↓', (-0.007, 8)), # Half Brain
  429. ],
  430. x_limits=pet_x_limits if clinical_prediction == 'diagnosis' else None,
  431. x_ticks=pet_x_ticks if clinical_prediction == 'diagnosis' else None,
  432. x_tick_labels=pet_x_tick_labels if clinical_prediction == 'diagnosis' else None)
  433. plot_ordered_boxplot(func, 'fMRI', clinical_prediction,
  434. f'{fig_name}_func',
  435. arrows_plot=arrows_plot,
  436. arrows_info=[(2, '↑', (-0.0093, 0)), # SomMot
  437. (0, '', (-0.0075, 1)), # Subcortical
  438. (2, '↓', (-0.0182, 2)), # Subcortical to Cortical
  439. (3, '↑', (-0.0083, 3)), # Limbic
  440. (4, '↑', (-0.007, 4)), # Cont
  441. (0, '', (-0.0055, 5)), # Default
  442. (2, '↓', (-0.0115, 6)), # SalVentAttn
  443. (0, '', (-0.0065, 7)), # DorsAttn
  444. (5, '↓', (-0.006, 8)), # Vis
  445. ])
  446. plot_ordered_boxplot(eeg_rs, 'EEG RS', clinical_prediction,
  447. f'{fig_name}_eeg_rs',
  448. arrows_plot=arrows_plot,
  449. arrows_info=[(1, '↑', (-0.0001, 0)), # Spectral: High
  450. (1, '↓', (0.0003, 1)), # Spectral: Low
  451. (1, '↑', (0.0008, 2)), # Connectivity
  452. (1, '↑', (-0.0004, 3)), # Spectral: Other
  453. (2, '↓', (-0.002, 4)) # Information theory
  454. ],
  455. x_limits=eeg_rs_x_limits if clinical_prediction == 'diagnosis' else None,
  456. x_ticks=eeg_rs_x_ticks if clinical_prediction == 'diagnosis' else None,
  457. x_tick_labels=eeg_rs_x_tick_labels if clinical_prediction == 'diagnosis' else None)
  458. plot_ordered_boxplot(eeg_lg, 'EEG LG', clinical_prediction,
  459. f'{fig_name}_eeg_lg',
  460. arrows_plot=arrows_plot,
  461. arrows_info=[(3, '↑', (-0.0077, 0)), # Spectral: High
  462. (3, '↑', (-0.0082, 1)), # Spectral: Other
  463. (2, '↓', (-0.0074, 2)), # Spectral: Low
  464. (1, '↓', (-0.0095, 3)), # Information theory
  465. (3, '↓', (-0.007, 4)), # Connectivity
  466. (0, '', (-0.005, 5)) # Evoked
  467. ])
  468. plot_ordered_boxplot(dti, 'dMRI', clinical_prediction,
  469. f'{fig_name}_dti',
  470. arrows_plot=arrows_plot,
  471. arrows_info=[(0, '', (-0.015, 0)), # FA global
  472. (1, '↑', (-0.02, 1)), # FA brainstem
  473. (7, '↑', (-0.0325, 2)), # MD commissural fibers
  474. (2, '↓', (-0.0275, 3)), # FA projection fibers
  475. (0, '', (-0.03, 4)), # FA associative
  476. (2, '↓', (-0.031, 5)), # FA commissural
  477. (0, '', (-0.03, 6)), # MD projection
  478. (0, '', (-0.03, 7)), # MD associative
  479. (3, '↓', (-0.022, 8)), # MD brainstem
  480. (1, '↓', (-0.017, 9)) # MD global
  481. ])
  482. #%% Brain plots for aMRI, fMRI, PET
  483. ################################
  484. # CORTICAL PLOTS - 4 brains for supplementary material
  485. def plot_nice_surf(data, density='32k', cmap='coolwarm', dpi=250, template='inflated',
  486. atlas=None, cbar_label=None, vmin=None, vmax=None, threshold=None,
  487. organization='2x2', clin_pred=None, fig_name=None):
  488. """
  489. Plot nice plots in fsLR space.
  490. Parameters
  491. ----------
  492. data : array_like or tuple
  493. ROI-wise or vertex-wise data. If tuple, assumes (left, right) hemisphere.
  494. density : str
  495. Density of surface plot, can be '8k', '32k' or '164k'.
  496. cmap : str
  497. Colormap.
  498. template : str
  499. Type of surface plot. Can be 'inflated', 'veryinflated', 'sphere' or 'midthickness'
  500. dpi : int
  501. Resolution of plot.
  502. atlas : Path, optional
  503. Path to an atlas in .dlabel.nii format.
  504. cbar_label: str, optional
  505. Colorbar label.
  506. vmin/vmax : int, optional
  507. Minimun/ maximum value in the plot.
  508. threshold : float, optional
  509. Threshold for the data. If None, no thresholding is applied.
  510. organization : str, optional
  511. How to organize the plots. Can be '1x4' or '2x2'.
  512. # the orig threshold was -1e-14
  513. """
  514. from nilearn.plotting import plot_surf
  515. from neuromaps.datasets import fetch_fslr
  516. from neuromaps.parcellate import Parcellater
  517. from neuromaps.images import dlabel_to_gifti
  518. if atlas is not None:
  519. atlas = dlabel_to_gifti(atlas)
  520. surf_masker = Parcellater(atlas, "fslr")
  521. data = surf_masker.inverse_transform(data)
  522. l_data, r_data = data[0].agg_data(), data[1].agg_data()
  523. else:
  524. if not isinstance(data, tuple):
  525. raise ValueError("Data input must be tuple-of-arrays. Alternatively provide 'atlas' for ROI data.")
  526. l_data, r_data = data[0], data[1]
  527. if None in (vmin, vmax):
  528. # Handle NaNs in left hemisphere data
  529. l_min, l_max = np.nanmin(l_data), np.nanmax(l_data)
  530. l_data = np.nan_to_num(l_data, nan=l_min)
  531. # Handle NaNs in right hemisphere data
  532. r_min, r_max = np.nanmin(r_data), np.nanmax(r_data)
  533. r_data = np.nan_to_num(r_data, nan=r_min)
  534. # min/max values in the data
  535. vmin = np.min([l_min, r_min])
  536. vmax = np.max([l_max, r_max])
  537. print(f'vmin: {vmin}, vmax: {vmax}')
  538. # Fetch surface template for plot
  539. surfaces = fetch_fslr(density=density)
  540. lh, rh = surfaces[template]
  541. if organization == '1x4':
  542. # Plot both hemispheres
  543. fig, ax = plt.subplots(nrows=1,ncols=4,subplot_kw={'projection': '3d'}, figsize=(12, 4), dpi=dpi)
  544. plot_surf(lh, l_data, threshold=threshold, cmap=cmap, alpha=1, view='lateral',
  545. colorbar=False, axes=ax.flat[0],
  546. vmin=vmin, vmax=vmax)
  547. plot_surf(lh, l_data, threshold=threshold, cmap=cmap, alpha=1, view='medial',
  548. colorbar=False, axes=ax.flat[1],
  549. vmin=vmin, vmax=vmax)
  550. plot_surf(rh, r_data, threshold=threshold, cmap=cmap, alpha=1, view='lateral',
  551. colorbar=False, axes=ax.flat[2],
  552. vmin=vmin, vmax=vmax)
  553. p = plot_surf(rh, r_data, threshold=threshold, cmap=cmap, alpha=1, view='medial',
  554. colorbar=True, axes=ax.flat[3],
  555. vmin=vmin, vmax=vmax)
  556. p.axes[-1].set_ylabel(cbar_label, fontsize=14, labelpad=0.5)
  557. p.axes[-1].set_yticks([vmin, vmax])
  558. #p.axes[-1].set_yticklabels(['min', 'max'])
  559. p.axes[-1].tick_params(labelsize=12, width=0, pad=0.1)
  560. plt.subplots_adjust(wspace=-0.05)
  561. p.axes[-1].set_position(p.axes[-1].get_position().translated(0.08, 0))
  562. elif organization == '2x2':
  563. # Plot both hemispheres
  564. fig, ax = plt.subplots(nrows=2, ncols=2, subplot_kw={'projection': '3d'}, figsize=(8, 8), dpi=dpi)
  565. plot_surf(lh, l_data, threshold=threshold, cmap=cmap, alpha=1, view='lateral',
  566. colorbar=False, axes=ax[0, 0],
  567. vmin=vmin, vmax=vmax)
  568. plot_surf(rh, r_data, threshold=threshold, cmap=cmap, alpha=1, view='medial',
  569. colorbar=False, axes=ax[0, 1],
  570. vmin=vmin, vmax=vmax)
  571. plot_surf(lh, l_data, threshold=threshold, cmap=cmap, alpha=1, view='medial',
  572. colorbar=False, axes=ax[1, 0],
  573. vmin=vmin, vmax=vmax)
  574. p = plot_surf(rh, r_data, threshold=threshold, cmap=cmap, alpha=1, view='lateral',
  575. colorbar=True, axes=ax[1, 1],
  576. vmin=vmin, vmax=vmax)
  577. p.axes[-1].set_ylabel(cbar_label, fontsize=10, labelpad=0.5)
  578. p.axes[-1].set_yticks([vmin, vmax])
  579. p.axes[-1].tick_params(labelsize=7, width=0, pad=0.1)
  580. plt.subplots_adjust(wspace=-0.05, hspace=0.05)
  581. p.axes[-1].set_position(p.axes[-1].get_position().translated(0.08, 0))
  582. plt.savefig(base_path+f'/00_derivatives/feature_importances_{clin_pred}/{fig_name}.pdf',
  583. bbox_inches='tight')
  584. return p
  585. # aMRI
  586. # take the first 100 rows of the fi_anat_mean_std:
  587. fi_anat_mean_std_cortical = fi_anat_mean_std.iloc[:100]
  588. fi_anat_mean_std_cortical.index = fi_anat_mean_std_cortical.index.str.replace('anat_lh_', '')
  589. fi_anat_mean_std_cortical.index = fi_anat_mean_std_cortical.index.str.replace('anat_rh_', '')
  590. fi_anat_mean_std_cortical.index = fi_anat_mean_std_cortical.index.str.replace('_thickness', '')
  591. base_path = '/home/Documents/codes/permed'
  592. atlas_path = base_path+'/multimodal/Schaefer2018_100Parcels_7Networks_order.dlabel.nii'
  593. # plot the cortical features first for the fi_anat_mean_std_cortical.mean and the fi_anat_mean_std_cortical.std:
  594. anat_cort_img = plot_nice_surf(fi_anat_mean_std_cortical['mean'], density='32k', dpi=250, template='inflated',
  595. atlas=atlas_path,
  596. cbar_label='thickness (mean)', cmap='pink',
  597. vmin=0, vmax=0.22,
  598. # vmin=None, vmax=None,
  599. threshold=None,
  600. organization='1x4',
  601. clin_pred=clinical_prediction, fig_name=f'{clinical_prediction}_fi_mean_anat_cortical'
  602. )
  603. plot_nice_surf(fi_anat_mean_std_cortical['std'], density='32k', dpi=250, template='inflated',
  604. atlas=atlas_path,
  605. cbar_label='thickness (std)', cmap='pink',
  606. vmin=0, vmax=0.08,
  607. # vmin=None, vmax=None,
  608. threshold=None,
  609. organization='1x4',
  610. clin_pred=clinical_prediction, fig_name=f'{clinical_prediction}_fi_std_anat_cortical'
  611. )
  612. # fMRI
  613. fi_func_mean_std_cortical = fi_func_mean_std[fi_func_mean_std.index.str.contains('7Networks')]
  614. fi_func_mean_std_cortical.index = fi_func_mean_std_cortical.index.str.replace('func-connectivity_mean_', '')
  615. func_cort_img = plot_nice_surf(fi_func_mean_std_cortical['mean'], density='32k', dpi=250, template='inflated',
  616. atlas=atlas_path,
  617. cbar_label='functional correlation (mean)', cmap='pink',
  618. # vmin=-0.1, vmax=0.1,
  619. threshold=None,
  620. organization='1x4',
  621. clin_pred=clinical_prediction, fig_name=f'{clinical_prediction}_fi_mean_fmri_cortical'
  622. )
  623. plot_nice_surf(fi_func_mean_std_cortical['std'], density='32k', dpi=250, template='inflated',
  624. atlas=atlas_path,
  625. cbar_label='functional correlation (std)', cmap='pink',
  626. # vmin=0, vmax=0.08,
  627. threshold=None,
  628. organization='1x4',
  629. clin_pred=clinical_prediction, fig_name=f'{clinical_prediction}_fi_std_fmri_cortical'
  630. )
  631. #
  632. # PET
  633. # take the first 100 rows of the fi_pet_mean_std:
  634. fi_pet_mean_std_cortical = fi_pet_mean_std.iloc[:100]
  635. fi_pet_mean_std_cortical.index = fi_pet_mean_std_cortical.index.str.replace('pet_', '')
  636. pet_cort_img = plot_nice_surf(fi_pet_mean_std_cortical['mean'], density='32k', dpi=250, template='inflated',
  637. atlas=atlas_path,
  638. cbar_label='SUV (mean)', cmap='pink',
  639. # vmin=0, vmax=0.22,
  640. threshold=None,
  641. organization='1x4',
  642. clin_pred=clinical_prediction, fig_name=f'{clinical_prediction}_fi_mean_pet_cortical'
  643. )
  644. plot_nice_surf(fi_pet_mean_std_cortical['std'], density='32k', dpi=250, template='inflated',
  645. atlas=atlas_path,
  646. cbar_label='SUV (std)', cmap='pink',
  647. # vmin=0, vmax=0.08,
  648. threshold=None,
  649. organization='1x4',
  650. clin_pred=clinical_prediction, fig_name=f'{clinical_prediction}_fi_std_pet_cortical'
  651. )
  652. #%%
  653. ##############################
  654. # SUBCORTICAL PLOTS - 4 brains, for supplementary material
  655. def modify_atlas(atlas, atlas_roi_labels, marker_values, atlas_name=None):
  656. """
  657. Modify the values in an atlas image.
  658. marker_values is a dataframe with the following columns:
  659. - roi_label: the label of the ROI in the atlas
  660. - new_value: the new value to assign to the ROI
  661. """
  662. # Load the atlas image
  663. if atlas_name=='Schaefer2018':
  664. atlas_img = nib.load(atlas.maps)
  665. elif atlas_name=='HarvardOxfordSubcortical':
  666. atlas_img = atlas.maps
  667. # Initialize a matrix with the same shape as the atlas
  668. combined_matrix = np.zeros(atlas_img.shape)
  669. if atlas_name=='HarvardOxfordSubcortical':
  670. print('We have the following labels : ', atlas_roi_labels)
  671. roi_to_remove = ['Background',
  672. 'Left Cerebral White Matter',
  673. 'Left Cerebral Cortex ',
  674. 'Left Lateral Ventrical',
  675. 'Right Cerebral White Matter',
  676. 'Right Cerebral Cortex ',
  677. 'Right Lateral Ventricle']
  678. print('Removing the following labels : ', roi_to_remove)
  679. # From the list roi_labels, remove the elements in roi_to_remove
  680. atlas_roi_labels = [x for x in atlas_roi_labels if x not in roi_to_remove]
  681. print('We have the following labels : ', atlas_roi_labels)
  682. for label in atlas_roi_labels:
  683. # Check if the label exists in marker_values
  684. if label in marker_values['roi_label'].values:
  685. # From the dataframe marker_values, get the new_value which corresponds to the current label
  686. new_val = marker_values[marker_values['roi_label'] == label]['new_value'].values[0]
  687. else:
  688. print(f"Label {label} not found in marker_values")
  689. # Find the index of the label in the atlas
  690. if atlas_name=='Schaefer2018':
  691. roi_idx = np.where(atlas.labels == label.encode('UTF-8'))[0]+1
  692. elif atlas_name=='HarvardOxfordSubcortical':
  693. roi_idx = np.where(np.array(atlas.labels) == label)[0]
  694. print(f'Label {label} has index : {roi_idx} and new value : {new_val}.')
  695. # Create a binary mask for the current ROI using the atlas image
  696. from nilearn import image
  697. idx_map = image.math_img('img == %s' % roi_idx, img=atlas.maps)
  698. idx_map_data = idx_map.get_fdata()
  699. # Set the marker value for voxels within the current ROI
  700. idx_map_data[idx_map_data != 0] = new_val
  701. print(f'Unique values in idx_map : {np.unique(idx_map_data)}')
  702. # Add the current ROI mask to the combined matrix
  703. combined_matrix = np.add(combined_matrix, idx_map_data)
  704. # Create a new Nifti image with the modified data
  705. modified_atlas_img = nib.Nifti1Image(combined_matrix, atlas_img.affine, atlas_img.header)
  706. # or:
  707. # modified_atlas_img = new_img_like(atlas_img, combined_matrix)
  708. return modified_atlas_img
  709. def plot_subcortical_regions(atlas, atlas_roi_labels, marker_values, atlas_name=None,
  710. clinical_prediction=None, fig_name=None, savefig=False):
  711. """
  712. Plot the subcortical regions in an atlas image.
  713. marker_values is a dataframe with the following columns:
  714. - roi_label: the label of the ROI in the atlas
  715. - new_value: the new value to assign to the ROI
  716. """
  717. # Modify the atlas using the provided marker values
  718. modified_atlas_img = modify_atlas(atlas, atlas_roi_labels, marker_values, atlas_name)
  719. if savefig:
  720. # Plot the modified atlas
  721. display = plotting.plot_glass_brain(stat_map_img=modified_atlas_img,
  722. colorbar=True,
  723. cmap='twilight',
  724. alpha=1,
  725. display_mode="lyrz")
  726. display.add_contours(modified_atlas_img, filled=True)
  727. # save the plot
  728. display.savefig(base_path+f'/00_derivatives/feature_importances_{clinical_prediction}/{fig_name}.pdf')
  729. return modified_atlas_img
  730. # aMRI
  731. print('aMRI')
  732. # take the first 100 rows of the fi_anat_mean_std:
  733. fi_anat_mean_std_subcortical = fi_anat_mean_std.iloc[100:]
  734. fi_anat_mean_std_subcortical.index = fi_anat_mean_std_subcortical.index.str.replace('anat_', '')
  735. base_path = '/home/Documents/codes/permed'
  736. # create a dataframe for marker_values
  737. marker_values_mean = pd.DataFrame({
  738. 'roi_label': fi_anat_mean_std_subcortical.index,
  739. 'new_value': fi_anat_mean_std_subcortical['mean']
  740. })
  741. marker_values_std = pd.DataFrame({
  742. 'roi_label': fi_anat_mean_std_subcortical.index,
  743. 'new_value': fi_anat_mean_std_subcortical['std']
  744. })
  745. # rename the marker_values_mean roi_label values to match those of the Harvard-Oxford atlas by putting the first letters of the words in capital
  746. marker_values_mean['roi_label'] = marker_values_mean['roi_label'].str.title()
  747. marker_values_std['roi_label'] = marker_values_std['roi_label'].str.title()
  748. atlas = fetch_atlas_harvard_oxford('sub-maxprob-thr25-1mm')
  749. # load the atlas
  750. # atlas = nib.load(atlas_path)
  751. # plot the subcortical features first for the fi_anat_mean_std_subcortical.mean and the fi_anat_mean_std_subcortical.std:
  752. anat_img = plot_subcortical_regions(atlas, atlas.labels, marker_values_mean, atlas_name='HarvardOxfordSubcortical',
  753. clinical_prediction=clinical_prediction, fig_name=f'{clinical_prediction}_fi_mean_anat_subcortical')
  754. # do the same for fmri
  755. print('fMRI')
  756. fi_func_mean_std_subcortical = fi_func_mean_std.iloc[100:]
  757. fi_func_mean_std_subcortical.index = fi_func_mean_std_subcortical.index.str.replace('func-connectivity_mean_', '')
  758. # create a dataframe for marker_values
  759. marker_values_mean = pd.DataFrame({
  760. 'roi_label': fi_func_mean_std_subcortical.index,
  761. 'new_value': fi_func_mean_std_subcortical['mean']
  762. })
  763. marker_values_std = pd.DataFrame({
  764. 'roi_label': fi_func_mean_std_subcortical.index,
  765. 'new_value': fi_func_mean_std_subcortical['std']
  766. })
  767. # rename the marker_values_mean roi_label values to match those of the Harvard-Oxford atlas by putting the first letters of the words in capital
  768. marker_values_mean['roi_label'] = marker_values_mean['roi_label'].str.title()
  769. marker_values_std['roi_label'] = marker_values_std['roi_label'].str.title()
  770. func_img = plot_subcortical_regions(atlas, atlas.labels, marker_values_mean, atlas_name='HarvardOxfordSubcortical',
  771. clinical_prediction=clinical_prediction, fig_name=f'{clinical_prediction}_fi_mean_fmri_subcortical')
  772. # do the same for PET
  773. print('PET')
  774. fi_pet_mean_std_subcortical = fi_pet_mean_std.iloc[100:]
  775. fi_pet_mean_std_subcortical.index = fi_pet_mean_std_subcortical.index.str.replace('pet_', '')
  776. # create a dataframe for marker_values
  777. marker_values_mean = pd.DataFrame({
  778. 'roi_label': fi_pet_mean_std_subcortical.index,
  779. 'new_value': fi_pet_mean_std_subcortical['mean']
  780. })
  781. marker_values_std = pd.DataFrame({
  782. 'roi_label': fi_pet_mean_std_subcortical.index,
  783. 'new_value': fi_pet_mean_std_subcortical['std']
  784. })
  785. # rename the marker_values_mean roi_label values to match those of the Harvard-Oxford atlas by putting the first letters of the words in capital
  786. marker_values_mean['roi_label'] = marker_values_mean['roi_label'].str.title()
  787. marker_values_std['roi_label'] = marker_values_std['roi_label'].str.title()
  788. pet_img = plot_subcortical_regions(atlas, atlas.labels, marker_values_mean, atlas_name='HarvardOxfordSubcortical',
  789. clinical_prediction=clinical_prediction, fig_name=f'{clinical_prediction}_fi_mean_pet_subcortical')
  790. #%% FINAL FIGURE Supplementary Figure - 3x2 brain plots (cortical and subcortical) mean feature importances of aMRI, fMRI, PET
  791. clin_pred = clinical_prediction
  792. # Load the images
  793. anat_cort_img = convert_from_path(base_path+f'/00_derivatives/feature_importances_{clin_pred}/{clin_pred}_fi_mean_anat_cortical.pdf')[0]
  794. func_cort_img = convert_from_path(base_path+f'/00_derivatives/feature_importances_{clin_pred}/{clin_pred}_fi_mean_fmri_cortical.pdf')[0]
  795. pet_cort_img = convert_from_path(base_path+f'/00_derivatives/feature_importances_{clin_pred}/{clin_pred}_fi_mean_pet_cortical.pdf')[0]
  796. # Convert PIL Images to numpy arrays
  797. anat_cort_img = np.array(anat_cort_img)
  798. func_cort_img = np.array(func_cort_img)
  799. pet_cort_img = np.array(pet_cort_img)
  800. # Display the images in subplots
  801. fig, ax = plt.subplots(nrows=3, ncols=2, figsize=(16, 8), dpi=300)
  802. # Cortical plots
  803. # aMRI
  804. ax[0, 0].imshow(anat_cort_img)
  805. ax[0, 0].axis('off')
  806. ax[0, 0].set_title('aMRI cortical mean feature importances',
  807. color='black', bbox={'facecolor': 'white', 'alpha': 0.5, 'pad': 10},
  808. fontsize=14, y=1.2
  809. )
  810. # fMRI
  811. ax[1, 0].imshow(func_cort_img)
  812. ax[1, 0].axis('off')
  813. ax[1, 0].set_title('fMRI cortical mean feature importances',
  814. color='black', bbox={'facecolor': 'white', 'alpha': 0.5, 'pad': 10},
  815. fontsize=14, y=1.2
  816. )
  817. # PET
  818. ax[2, 0].imshow(pet_cort_img)
  819. ax[2, 0].axis('off')
  820. ax[2, 0].set_title('PET cortical mean feature importances',
  821. color='black', bbox={'facecolor': 'white', 'alpha': 0.5, 'pad': 10},
  822. fontsize=14, y=1.2
  823. )
  824. # Subcortical plots
  825. # aMRI
  826. display = plotting.plot_glass_brain(stat_map_img=anat_img, colorbar=True, cmap='twilight', alpha=1, display_mode="lyrz", axes=ax[0, 1])
  827. display.add_contours(anat_img, filled=True)
  828. ax[0, 1].set_title('aMRI subcortical mean feature importances',
  829. color='black', bbox={'facecolor': 'white', 'alpha': 0.5, 'pad': 10}, fontsize=14)
  830. # Get the colorbar object
  831. cbar = display._cbar
  832. # Change the tick location to right
  833. cbar.ax.yaxis.set_tick_params(left=False, right=True, labelleft=False, labelright=True)
  834. # fMRI
  835. display = plotting.plot_glass_brain(stat_map_img=func_img, colorbar=True, cmap='twilight', alpha=1, display_mode="lyrz", axes=ax[1, 1])
  836. display.add_contours(func_img, filled=True)
  837. ax[1, 1].set_title('fMRI subcortical mean feature importances',
  838. color='black', bbox={'facecolor': 'white', 'alpha': 0.5, 'pad': 10}, fontsize=14)
  839. cbar = display._cbar
  840. cbar.ax.yaxis.set_tick_params(left=False, right=True, labelleft=False, labelright=True)
  841. # PET
  842. display = plotting.plot_glass_brain(stat_map_img=pet_img, colorbar=True, cmap='twilight', alpha=1, display_mode="lyrz", axes=ax[2, 1])
  843. display.add_contours(pet_img, filled=True)
  844. ax[2, 1].set_title('PET subcortical mean feature importances',
  845. color='black', bbox={'facecolor': 'white', 'alpha': 0.5, 'pad': 10}, fontsize=14)
  846. cbar = display._cbar
  847. cbar.ax.yaxis.set_tick_params(left=False, right=True, labelleft=False, labelright=True)
  848. # save the figure
  849. plt.savefig(base_path+f'/00_derivatives/feature_importances_groups_diagnosis_6m1y2y-prognosis/{clinical_prediction}_fi_mean_cort-subcort.pdf',
  850. bbox_inches='tight')
  851. # Combination of Diagnosis and prognosis with lines how the feature groups ranking changes
  852. # diagnosis (glass brains, boxplots) -lines- prognosis (boxplots, glass brains)
  853. # The difference with the code above is that the code above has 4 brains
  854. # in the plots from all sides and the cortical plot is a different brain design.
  855. def plot_regions(atlas, atlas_roi_labels, marker_values, atlas_name=None,
  856. clinical_prediction=None, fig_name=None):
  857. """
  858. Plot the regions in an atlas image.
  859. marker_values is a dataframe with the following columns:
  860. - roi_label: the label of the ROI in the atlas
  861. - new_value: the new value to assign to the ROI
  862. """
  863. # Modify the atlas using the provided marker values
  864. modified_atlas_img = modify_atlas(atlas, atlas_roi_labels, marker_values, atlas_name)
  865. # Plot the modified atlas
  866. display = plotting.plot_glass_brain(stat_map_img=modified_atlas_img,
  867. colorbar=True,
  868. cmap='twilight',
  869. alpha=0.7,
  870. display_mode="z")
  871. display.add_contours(modified_atlas_img, filled=True)
  872. # save the plot
  873. display.savefig(base_path+
  874. f'/00_derivatives/feature_importances_groups_diagnosis_6m1y2y-prognosis/{fig_name}.pdf')
  875. return modified_atlas_img
  876. ############################# SUBCORTICAL #####################################
  877. # aMRI
  878. print('aMRI')
  879. # take the first 100 rows of the fi_anat_mean_std:
  880. fi_anat_mean_std_subcortical = fi_anat_mean_std.iloc[100:]
  881. fi_anat_mean_std_subcortical.index = fi_anat_mean_std_subcortical.index.str.replace('anat_', '')
  882. base_path = '/home/Documents/codes/permed'
  883. # create a dataframe for marker_values
  884. marker_values_mean = pd.DataFrame({
  885. 'roi_label': fi_anat_mean_std_subcortical.index,
  886. 'new_value': fi_anat_mean_std_subcortical['mean']
  887. })
  888. marker_values_std = pd.DataFrame({
  889. 'roi_label': fi_anat_mean_std_subcortical.index,
  890. 'new_value': fi_anat_mean_std_subcortical['std']
  891. })
  892. # rename the marker_values_mean roi_label values to match those of the Harvard-Oxford atlas by putting the first letters of the words in capital
  893. marker_values_mean['roi_label'] = marker_values_mean['roi_label'].str.title()
  894. marker_values_std['roi_label'] = marker_values_std['roi_label'].str.title()
  895. atlas = fetch_atlas_harvard_oxford('sub-maxprob-thr25-1mm')
  896. # load the atlas
  897. # atlas = nib.load(atlas_path)
  898. # plot the subcortical features first for the fi_anat_mean_std_subcortical.mean and the fi_anat_mean_std_subcortical.std:
  899. modified_atlas_img = plot_regions(atlas, atlas.labels, marker_values_mean, atlas_name='HarvardOxfordSubcortical',
  900. clinical_prediction=clinical_prediction, fig_name=f'{clinical_prediction}_fi_mean_anat_subcortical')
  901. plot_regions(atlas, atlas.labels, marker_values_std, atlas_name='HarvardOxfordSubcortical',
  902. clinical_prediction=clinical_prediction, fig_name=f'{clinical_prediction}_fi_std_anat_subcortical')
  903. # do the same for fmri
  904. print('fMRI')
  905. fi_func_mean_std_subcortical = fi_func_mean_std.iloc[100:]
  906. fi_func_mean_std_subcortical.index = fi_func_mean_std_subcortical.index.str.replace('func-connectivity_mean_', '')
  907. # create a dataframe for marker_values
  908. marker_values_mean = pd.DataFrame({
  909. 'roi_label': fi_func_mean_std_subcortical.index,
  910. 'new_value': fi_func_mean_std_subcortical['mean']
  911. })
  912. marker_values_std = pd.DataFrame({
  913. 'roi_label': fi_func_mean_std_subcortical.index,
  914. 'new_value': fi_func_mean_std_subcortical['std']
  915. })
  916. # rename the marker_values_mean roi_label values to match those of the Harvard-Oxford atlas by putting the first letters of the words in capital
  917. marker_values_mean['roi_label'] = marker_values_mean['roi_label'].str.title()
  918. marker_values_std['roi_label'] = marker_values_std['roi_label'].str.title()
  919. plot_regions(atlas, atlas.labels, marker_values_mean, atlas_name='HarvardOxfordSubcortical',
  920. clinical_prediction=clinical_prediction, fig_name=f'{clinical_prediction}_fi_mean_fmri_subcortical')
  921. plot_regions(atlas, atlas.labels, marker_values_std, atlas_name='HarvardOxfordSubcortical',
  922. clinical_prediction=clinical_prediction, fig_name=f'{clinical_prediction}_fi_std_fmri_subcortical')
  923. # do the same for PET
  924. print('PET')
  925. fi_pet_mean_std_subcortical = fi_pet_mean_std.iloc[100:]
  926. fi_pet_mean_std_subcortical.index = fi_pet_mean_std_subcortical.index.str.replace('pet_', '')
  927. # create a dataframe for marker_values
  928. marker_values_mean = pd.DataFrame({
  929. 'roi_label': fi_pet_mean_std_subcortical.index,
  930. 'new_value': fi_pet_mean_std_subcortical['mean']
  931. })
  932. marker_values_std = pd.DataFrame({
  933. 'roi_label': fi_pet_mean_std_subcortical.index,
  934. 'new_value': fi_pet_mean_std_subcortical['std']
  935. })
  936. # rename the marker_values_mean roi_label values to match those of the Harvard-Oxford atlas by putting the first letters of the words in capital
  937. marker_values_mean['roi_label'] = marker_values_mean['roi_label'].str.title()
  938. marker_values_std['roi_label'] = marker_values_std['roi_label'].str.title()
  939. plot_regions(atlas, atlas.labels, marker_values_mean, atlas_name='HarvardOxfordSubcortical',
  940. clinical_prediction=clinical_prediction, fig_name=f'{clinical_prediction}_fi_mean_pet_subcortical')
  941. plot_regions(atlas, atlas.labels, marker_values_std, atlas_name='HarvardOxfordSubcortical',
  942. clinical_prediction=clinical_prediction, fig_name=f'{clinical_prediction}_fi_std_pet_subcortical')
  943. ############################ CORTICAL ##########################################
  944. atlas_name = 'Schaefer2018'
  945. atlas = datasets.fetch_atlas_schaefer_2018(
  946. n_rois=100,
  947. yeo_networks=7,
  948. resolution_mm=1)
  949. roi_labels = atlas.labels
  950. roi_labels = [row.tobytes().decode('UTF-8') for row in roi_labels]
  951. # aMRI
  952. # take the first 100 rows of the fi_anat_mean_std:
  953. fi_anat_mean_std_cortical = fi_anat_mean_std.iloc[:100]
  954. fi_anat_mean_std_cortical.index = fi_anat_mean_std_cortical.index.str.replace('anat_lh_', '')
  955. fi_anat_mean_std_cortical.index = fi_anat_mean_std_cortical.index.str.replace('anat_rh_', '')
  956. fi_anat_mean_std_cortical.index = fi_anat_mean_std_cortical.index.str.replace('_thickness', '')
  957. marker_values_mean = pd.DataFrame({
  958. 'roi_label': fi_anat_mean_std_cortical.index,
  959. 'new_value': fi_anat_mean_std_cortical['mean']
  960. })
  961. marker_values_std = pd.DataFrame({
  962. 'roi_label': fi_anat_mean_std_cortical.index,
  963. 'new_value': fi_anat_mean_std_cortical['std']
  964. })
  965. # plot the aMRI plot_regions
  966. plot_regions(atlas, roi_labels, marker_values_mean, atlas_name=atlas_name,
  967. clinical_prediction=clinical_prediction, fig_name=f'{clinical_prediction}_fi_mean_anat_cortical')
  968. plot_regions(atlas, roi_labels, marker_values_std, atlas_name=atlas_name,
  969. clinical_prediction=clinical_prediction, fig_name=f'{clinical_prediction}_fi_std_anat_cortical')
  970. # fMRI
  971. fi_func_mean_std_cortical = fi_func_mean_std[fi_func_mean_std.index.str.contains('7Networks')]
  972. fi_func_mean_std_cortical.index = fi_func_mean_std_cortical.index.str.replace('func-connectivity_mean_', '')
  973. marker_values_mean = pd.DataFrame({
  974. 'roi_label': fi_func_mean_std_cortical.index,
  975. 'new_value': fi_func_mean_std_cortical['mean']
  976. })
  977. marker_values_std = pd.DataFrame({
  978. 'roi_label': fi_func_mean_std_cortical.index,
  979. 'new_value': fi_func_mean_std_cortical['std']
  980. })
  981. # plot the fMRI plot_regions
  982. plot_regions(atlas, roi_labels, marker_values_mean, atlas_name=atlas_name,
  983. clinical_prediction=clinical_prediction, fig_name=f'{clinical_prediction}_fi_mean_fmri_cortical')
  984. plot_regions(atlas, roi_labels, marker_values_std, atlas_name=atlas_name,
  985. clinical_prediction=clinical_prediction, fig_name=f'{clinical_prediction}_fi_std_fmri_cortical')
  986. # PET
  987. # take the first 100 rows of the fi_pet_mean_std:
  988. fi_pet_mean_std_cortical = fi_pet_mean_std.iloc[:100]
  989. fi_pet_mean_std_cortical.index = fi_pet_mean_std_cortical.index.str.replace('pet_', '')
  990. marker_values_mean = pd.DataFrame({
  991. 'roi_label': fi_pet_mean_std_cortical.index,
  992. 'new_value': fi_pet_mean_std_cortical['mean']
  993. })
  994. marker_values_std = pd.DataFrame({
  995. 'roi_label': fi_pet_mean_std_cortical.index,
  996. 'new_value': fi_pet_mean_std_cortical['std']
  997. })
  998. # plot the PET plot_regions
  999. plot_regions(atlas, roi_labels, marker_values_mean, atlas_name=atlas_name,
  1000. clinical_prediction=clinical_prediction, fig_name=f'{clinical_prediction}_fi_mean_pet_cortical')
  1001. plot_regions(atlas, roi_labels, marker_values_std, atlas_name=atlas_name,
  1002. clinical_prediction=clinical_prediction, fig_name=f'{clinical_prediction}_fi_std_pet_cortical')
  1003. #%%
  1004. # Correlations between the diagnostic and prognostic feature importances for: fMRI, EEG LG, dMRI
  1005. sns.set_theme()
  1006. sns.set_context("talk")
  1007. sns.set_style("white")
  1008. mean_feat_path = os.path.join(base_path, '00_derivatives/mean_feat_importances_with_feature-groups_splits')
  1009. # diagnosis
  1010. clinical_prediction = 'diagnosis' # '6m1y2y-prognosis' # 'diagnosis'
  1011. # fMRI
  1012. fmri_diag = pd.read_csv(os.path.join(mean_feat_path, f'{clinical_prediction}_mean_feature-groups_func.csv'), index_col=0)
  1013. # dMRI
  1014. dMRI_diag = pd.read_csv(os.path.join(mean_feat_path, f'{clinical_prediction}_mean_feature-groups_dti.csv'), index_col=0)
  1015. # EEG LG
  1016. eeg_lg_diag = pd.read_csv(os.path.join(mean_feat_path, f'{clinical_prediction}_mean_feature-groups_eeg_lg.csv'), index_col=0)
  1017. # prognosis
  1018. clinical_prediction = '6m1y2y-prognosis'
  1019. # fMRI
  1020. fmri_prog = pd.read_csv(os.path.join(mean_feat_path, f'{clinical_prediction}_mean_feature-groups_func.csv'), index_col=0)
  1021. # dMRI
  1022. dMRI_prog = pd.read_csv(os.path.join(mean_feat_path, f'{clinical_prediction}_mean_feature-groups_dti.csv'), index_col=0)
  1023. # EEG LG
  1024. eeg_lg_prog = pd.read_csv(os.path.join(mean_feat_path, f'{clinical_prediction}_mean_feature-groups_eeg_lg.csv'), index_col=0)
  1025. # in fmri_diag and fmri_prog change the values in the column region_groups from Subcortical to Cortical to Sub to Cort
  1026. fmri_diag['region_groups'] = fmri_diag['region_groups'].replace('Subcortical to Cortical', 'Sub to Cort')
  1027. fmri_prog['region_groups'] = fmri_prog['region_groups'].replace('Subcortical to Cortical', 'Sub to Cort') # ??? this was not included
  1028. #
  1029. fig, ax = plt.subplots(3, 1, figsize=(6, 16), dpi=300)
  1030. scatter_fmri = sns.scatterplot(x=fmri_diag['mean'], y=fmri_prog['mean'], hue=fmri_diag['region_groups'],
  1031. palette='deep', alpha=0.85, ax=ax[0])
  1032. scatter_dMRI = sns.scatterplot(x=dMRI_diag['mean'], y=dMRI_prog['mean'], hue=dMRI_diag['region_groups'],
  1033. palette='deep', alpha=0.85, ax=ax[1])
  1034. scatter_eeg_lg = sns.scatterplot(x=eeg_lg_diag['mean'], y=eeg_lg_prog['mean'], hue=eeg_lg_diag['region_groups'],
  1035. palette='deep', alpha=0.85, ax=ax[2])
  1036. ax[0].set_title('fMRI')
  1037. ax[1].set_title('dMRI')
  1038. ax[2].set_title('EEG LG')
  1039. ax[0].set_xlabel('Diagnosis mean FI')
  1040. ax[0].set_ylabel('Prognosis mean FI')
  1041. ax[1].set_xlabel('Diagnosis mean FI')
  1042. ax[1].set_ylabel('Prognosis mean FI')
  1043. ax[2].set_xlabel('Diagnosis mean FI')
  1044. ax[2].set_ylabel('Prognosis mean FI')
  1045. # set the limits of the first subplot to 0 to 0.04 on both x and y
  1046. ax[0].set_xlim(0, 0.04)
  1047. ax[0].set_ylim(0, 0.04)
  1048. ax[1].set_xlim(0, 0.075)
  1049. ax[1].set_ylim(0, 0.075)
  1050. ax[2].set_xlim(0, 0.03)
  1051. ax[2].set_ylim(0, 0.03)
  1052. # On all three plots but the same ticks on the x and y axes, and always put 4 ticks, two at the extremes and one in the middle:
  1053. ax[0].set_xticks([0, 0.02, 0.04])
  1054. ax[0].set_yticks([0, 0.02, 0.04])
  1055. ax[1].set_xticks([0, 0.04, 0.075])
  1056. ax[1].set_yticks([0, 0.04, 0.075])
  1057. ax[2].set_xticks([0, 0.015, 0.03])
  1058. ax[2].set_yticks([0, 0.015, 0.03])
  1059. # Set the tick labels to display 0 without commas
  1060. ax[0].set_xticklabels(['0', '0.02', '0.04'])
  1061. ax[0].set_yticklabels(['0', '0.02', '0.04'])
  1062. ax[1].set_xticklabels(['0', '0.04', '0.075'])
  1063. ax[1].set_yticklabels(['0', '0.04', '0.075'])
  1064. ax[2].set_xticklabels(['0', '0.015', '0.03'])
  1065. ax[2].set_yticklabels(['0', '0.015', '0.03'])
  1066. plt.tight_layout()
  1067. legend_fmri = scatter_fmri.legend(loc='upper right', bbox_to_anchor=(1, 1), fontsize=10)
  1068. for handle in legend_fmri.legendHandles:
  1069. handle._sizes = [35] # adjust as needed
  1070. legend_dmri = scatter_dMRI.legend(loc='upper right', bbox_to_anchor=(1, 1), fontsize=10)
  1071. for handle in legend_dmri.legendHandles:
  1072. handle._sizes = [35] # adjust as needed
  1073. legend_eeg_lg = scatter_eeg_lg.legend(loc='upper right', bbox_to_anchor=(1, 1), fontsize=10)
  1074. for handle in legend_eeg_lg.legendHandles:
  1075. handle._sizes = [35] # adjust as needed
  1076. plt.savefig(os.path.join(base_path, '00_derivatives/Figure_3_feat-imp/correlation_diag-prog_feature-importances.pdf'), bbox_inches='tight')

01_efm_model-results.py at commit 476e8bf, no license · at the source

Overview

Authors: Dragana Manasova1,2, Laouen Mayal Louan Belloli1,3,4, Martin Justinus Rosenfelder5,6,7, Lina Willacker5, Emilia Fló Rama1, Chiara Valota8,9, Bertrand Hermann10,11, Brigitte Charlotte Kaufmann1, Alice Pirastru9, Chiara Camilla Derchi9, Theresa Raiser5, Melanie Valente1, Aude Sangare1, Başak Türker1, Nadya Pyatigorskaya1, Benoît Béranger1, Michele Colombo8, Esteban Munoz-Musat1,12, Anira Escrichs13, Tiziana Atzori9
and 17 other authorsFrancesca Baglio9, Constantin Lapa14, Ansgar Berlis15, Kristina Krüger15, Tina Luther5,6, Vincent Perlbarg16, Gustavo Deco13,17, Yonathan Sanz-Perl1,17, Enzo Tagliazucchi4,18, Louis Puybasset16,19, Benjamin Rohaut1,20, Lionel Naccache1,21, Angela Comanducci9, Anat Arzi1,22,23, Mario Rosanova8, Andreas Bender5,6,24, Jacobo Diego Sitt1
24 affiliations
  1. Institut du Cerveau - Paris Brain Institute - ICM, Inserm, CNRS, Sorbonne Université, Paris 75013, France
  2. Université Paris Cité, Paris 75006, France
  3. Laboratorio de Inteligencia Artificial Aplicada, Instituto de Ciencias de la Computación, Universidad de Buenos Aires, Buenos Aires C1053, Argentina
  4. Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET), Ministry of Science, Technology and Innovation, Buenos Aires C1053, Argentina
  5. Department of Neurology, University Hospital of the Ludwig-Maximilians-Universität München, Munich 82152, Germany
  6. Therapiezentrum Burgau, Hospital for Neurological Rehabilitation, Burgau 89331, Germany
  7. Clinical and Biological Psychology, Institute of Psychology and Education, Ulm University, Ulm 89081, Germany
  8. Department of Biomedical and Clinical Sciences, University of Milano, Milan 20157, Italy
  9. IRCCS Fondazione Don Carlo Gnocchi ONLUS, Milan 20148, Italy
  10. Inserm 1266, Institute of Psychiatry and Neurosciences of Paris, Université Paris Cité, Paris F-75014, France
  11. Medical Intensive Care Unit, HEGP Hôpital, Assistance Publique - Hôpitaux de Paris-Centre (APHP-Centre), Paris 75014, France
  12. Centre Mémoire de Ressources et de Recherche, Paris Nord/Université Paris-Cité, Paris 75006, France
  13. Center for Brain and Cognition, Computational Neuroscience Group, Universitat Pompeu Fabra, Barcelona 08005, Spain
  14. Nuclear Medicine, Faculty of Medicine, University of Augsburg, Augsburg 86156, Germany
  15. Diagnostic and Interventional Neuroradiology, Faculty of Medicine, University of Augsburg, Augsburg 86156, Germany
  16. BRAINTALE SAS, Paris 75013, France
  17. Institució Catalana de la Recerca I Estudis Avançats (ICREA), Barcelona 08010, Spain
  18. Latin American Brain Health Institute (BrainLat), Universidad Adolfo Ibáñez, Santiago 7941169, Chile
  19. GRC 29, AP-HP, DMU DREAM, Department of Anaesthesiology and Critical Care Medicine, Pitié-Salpêtrière Hospital, Sorbonne University, Paris 75013, France
  20. AP-HP, Hôpital de la Pitié Salpêtrière, Neuro ICU, DMU Neurosciences, Paris 75013, France
  21. AP-HP, Hôpital Pitié - Salpêtrière, Service de Neurophysiologie Clinique, Paris 75013, France
  22. Department of Medical Neurobiology, Institute for Medical Research Israel-Canada, Faculty of Medicine, The Hebrew University of Jerusalem, Jerusalem 9112102, Israel
  23. Department of Cognitive and Brain Sciences, The Hebrew University of Jerusalem, Jerusalem 9112102, Israel
  24. Department of Neurorehabilitation, Medical Faculty, University of Augsburg, Augsburg 86156, Germany
Journal: Brain : a journal of neurology, volume 149, issue 4, pages 1381-1395
Dates: received 21 November 2024; accepted 3 September 2025; published online 7 January 2026; in print April 2026
Type: Research article · Language: English
License: CC BY-NC
Identifiers: DOI 10.1093/brain/awaf412 · PMID 41499248 · PMCID PMC13058464 · OpenAlex W7119468174
Open access: hybrid, a free copy (OpenAlex)
Status: code verified
Categories: structural MRI / diffusion (modality), EEG (modality), PET / SPECT (modality), human (organism), other condition (population)
Methods: Machine learning, fMRI & imaging, Preprocessing
Keywords: disorders of consciousness, electrophysiology, neuroimaging, multimodal, machine learning
MeSH: Brain*, Consciousness Disorders*, Multimodal Imaging*, Neuroimaging*, Adult, Electroencephalography, Female, Humans, Machine Learning, Magnetic Resonance Imaging, Male, Middle Aged, Positron-Emission Tomography, Prognosis (* major topic)
Topic: Traumatic Brain Injury Research (Epidemiology, Medicine), according to OpenAlex
Funding: Agence Nationale de la Recherche (ANR-19-PERM-0002); Fondazione Regionale per la Ricerca Biomedica (GA 77982); MODELDxConsciousness Consortium (JTC 2023); Paris Brain Institute; Ecole Doctorale Frontières de l'Innovation en Recherche et Education-Programme Bettencourt; Federal Ministry of Education and Research (01KU2003); Italian ministry of Health; European Research Council (101071900)
Citations: cited by 7 papers (Europe PMC); 77 references in the paper

Abstract

Severely brain-injured patients may enter a spectrum of conditions collectively known as disorders of consciousness. This spectrum includes clinical conditions such as unresponsive wakefulness syndrome or minimally conscious state, where the behavioural assessment of consciousness can often be deceptive.

To bridge this dissociation, neuroimaging techniques are employed to identify the residual brain functions. Each neuroimaging modality imperfectly captures distinct aspects of brain preservation—functional, anatomical, or both. In this study, we adopt a comprehensive approach by integrating the neurophysiology and neuroimaging modalities available from the standard and advanced clinical assessments through interpretable machine learning. The electrophysiological modalities included high-density EEG (resting state and task), whereas neuroimaging modalities included anatomical and resting-state functional MRI, diffusion MRI and 18F-fluorodeoxyglucose PET.

Our investigation reveals that specific modalities, such as functional assessments, provide comprehensive insights into the currently evaluated state of consciousness, the diagnosis of the patients. Conversely, structural modalities offer valuable information about the patient's evolution within the consciousness spectrum. We validate the proposed analysis with data coming from other centres with different acquisition parameters. Importantly, we demonstrate that model performance improves with an increase in the number of modalities. We observe a higher inter-modality disagreement for minimally conscious state patients and those patients who improve. Lastly, we observe a difference in feature importances between diagnosis and prognosis, with an interaction between modality and anatomical structures: some subcortical markers tend to contribute more to prognosis, while other cortical markers are more informative for diagnosis.

This integrative multimodal and machine learning methodology presents a promising avenue for a more nuanced understanding of disorders of consciousness, contributing to enhanced diagnostic precision, prognostic capabilities and the personalization of rehabilitative strategies in clinical practice.

Reproduced under the paper's license (CC BY-NC), from the paper cited above.

Repository

Its files are read in the Code ↔ Paper reader above, with 4 matches between paragraphs and lines of code.

DraganaMana/multimod_doc

License: none: the authors keep all their rights
State: the link answers, verified on 28 September 2026
Evidence: files inventoried
Commit: 476e8bf792c6258056bba25d82d73535edfc5379, 7 January 2026
Languages: Python (27), Shell (10)
Size: 41 files, 37 scripts
Software Heritage: not archived
Found in: “Data availability”
Holds: README
Not found: license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: pandas (24 files), NumPy (19 files), Matplotlib (17 files), Nilearn (9 files), seaborn (9 files), scikit-learn (8 files), PyBIDS (7 files), FreeSurfer (6 files), NiBabel (4 files), SciPy (4 files), fMRIPrep (1 file), MNE-Python (1 file), neuromaps (1 file), specparam (formerly FOOOF) (1 file), statannotations (1 file), XGBoost (1 file)
Availability: 1 check, the latest on 28 September 2026: the link answers
  • 28 September 2026: the link answers
38 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;
  • 37 scripts, each with its path and the digest of its content;
  • 4 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

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

Data availability

The data are not publicly available. Codes used in the analyses will be made publicly available upon publication at https://github.com/DraganaMana/multimod_doc.

Reproduced under the paper's license (CC BY-NC), 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, issue, pages, dates, 37 authors, 5 keywords, 14 MeSH terms, 8 funders, 73 references.

Cite

This paper

Manasova, D., Belloli, L. M. L., Rosenfelder, M. J., Willacker, L., Fló Rama, E., Valota, C., Hermann, B., Kaufmann, B. C., Pirastru, A., Derchi, C. C., Raiser, T., Valente, M., Sangare, A., Türker, B., Pyatigorskaya, N., Béranger, B., Colombo, M., Munoz-Musat, E., Escrichs, A., . . . Sitt, J. D. (2026). Multimodal multicentre investigation of diagnostic and prognostic markers in disorders of consciousness. Brain : a journal of neurology, 149(4), 1381-1395. https://doi.org/10.1093/brain/awaf412

BibTeX

@article{manasova2026multimodal,
author = {Manasova, Dragana and Belloli, Laouen Mayal Louan and Rosenfelder, Martin Justinus and Willacker, Lina and Fló Rama, Emilia and Valota, Chiara and Hermann, Bertrand and Kaufmann, Brigitte Charlotte and Pirastru, Alice and Derchi, Chiara Camilla and Raiser, Theresa and Valente, Melanie and Sangare, Aude and Türker, Başak and Pyatigorskaya, Nadya and Béranger, Benoît and Colombo, Michele and Munoz-Musat, Esteban and Escrichs, Anira and Atzori, Tiziana and Baglio, Francesca and Lapa, Constantin and Berlis, Ansgar and Krüger, Kristina and Luther, Tina and Perlbarg, Vincent and Deco, Gustavo and Sanz-Perl, Yonathan and Tagliazucchi, Enzo and Puybasset, Louis and Rohaut, Benjamin and Naccache, Lionel and Comanducci, Angela and Arzi, Anat and Rosanova, Mario and Bender, Andreas and Sitt, Jacobo Diego},
title = {{Multimodal multicentre investigation of diagnostic and prognostic markers in disorders of consciousness}},
journal = {Brain : a journal of neurology},
year = {2026},
month = apr,
volume = {149},
number = {4},
pages = {1381--1395},
publisher = {Oxford University Press},
issn = {0006-8950},
doi = {10.1093/brain/awaf412},
url = {https://doi.org/10.1093/brain/awaf412},
pmid = {41499248},
pmcid = {PMC13058464}
}

RIS

TY - JOUR
AU - Manasova, Dragana
AU - Belloli, Laouen Mayal Louan
AU - Rosenfelder, Martin Justinus
AU - Willacker, Lina
AU - Fló Rama, Emilia
AU - Valota, Chiara
AU - Hermann, Bertrand
AU - Kaufmann, Brigitte Charlotte
AU - Pirastru, Alice
AU - Derchi, Chiara Camilla
AU - Raiser, Theresa
AU - Valente, Melanie
AU - Sangare, Aude
AU - Türker, Başak
AU - Pyatigorskaya, Nadya
AU - Béranger, Benoît
AU - Colombo, Michele
AU - Munoz-Musat, Esteban
AU - Escrichs, Anira
AU - Atzori, Tiziana
AU - Baglio, Francesca
AU - Lapa, Constantin
AU - Berlis, Ansgar
AU - Krüger, Kristina
AU - Luther, Tina
AU - Perlbarg, Vincent
AU - Deco, Gustavo
AU - Sanz-Perl, Yonathan
AU - Tagliazucchi, Enzo
AU - Puybasset, Louis
AU - Rohaut, Benjamin
AU - Naccache, Lionel
AU - Comanducci, Angela
AU - Arzi, Anat
AU - Rosanova, Mario
AU - Bender, Andreas
AU - Sitt, Jacobo Diego
TI - Multimodal multicentre investigation of diagnostic and prognostic markers in disorders of consciousness
T2 - Brain : a journal of neurology
J2 - Brain
PY - 2026
DA - 2026/04/01
VL - 149
IS - 4
SP - 1381
EP - 1395
SN - 0006-8950
PB - Oxford University Press
DO - 10.1093/brain/awaf412
UR - https://doi.org/10.1093/brain/awaf412
LA - en
ER -

CSL-JSON

{
"id": "10.1093/brain/awaf412",
"type": "article-journal",
"title": "Multimodal multicentre investigation of diagnostic and prognostic markers in disorders of consciousness",
"container-title": "Brain : a journal of neurology",
"author": [
{
"family": "Manasova",
"given": "Dragana"
},
{
"family": "Belloli",
"given": "Laouen Mayal Louan"
},
{
"family": "Rosenfelder",
"given": "Martin Justinus"
},
{
"family": "Willacker",
"given": "Lina"
},
{
"family": "Fló Rama",
"given": "Emilia"
},
{
"family": "Valota",
"given": "Chiara"
},
{
"family": "Hermann",
"given": "Bertrand"
},
{
"family": "Kaufmann",
"given": "Brigitte Charlotte"
},
{
"family": "Pirastru",
"given": "Alice"
},
{
"family": "Derchi",
"given": "Chiara Camilla"
},
{
"family": "Raiser",
"given": "Theresa"
},
{
"family": "Valente",
"given": "Melanie"
},
{
"family": "Sangare",
"given": "Aude"
},
{
"family": "Türker",
"given": "Başak"
},
{
"family": "Pyatigorskaya",
"given": "Nadya"
},
{
"family": "Béranger",
"given": "Benoît"
},
{
"family": "Colombo",
"given": "Michele"
},
{
"family": "Munoz-Musat",
"given": "Esteban"
},
{
"family": "Escrichs",
"given": "Anira"
},
{
"family": "Atzori",
"given": "Tiziana"
},
{
"family": "Baglio",
"given": "Francesca"
},
{
"family": "Lapa",
"given": "Constantin"
},
{
"family": "Berlis",
"given": "Ansgar"
},
{
"family": "Krüger",
"given": "Kristina"
},
{
"family": "Luther",
"given": "Tina"
},
{
"family": "Perlbarg",
"given": "Vincent"
},
{
"family": "Deco",
"given": "Gustavo"
},
{
"family": "Sanz-Perl",
"given": "Yonathan"
},
{
"family": "Tagliazucchi",
"given": "Enzo"
},
{
"family": "Puybasset",
"given": "Louis"
},
{
"family": "Rohaut",
"given": "Benjamin"
},
{
"family": "Naccache",
"given": "Lionel"
},
{
"family": "Comanducci",
"given": "Angela"
},
{
"family": "Arzi",
"given": "Anat"
},
{
"family": "Rosanova",
"given": "Mario"
},
{
"family": "Bender",
"given": "Andreas"
},
{
"family": "Sitt",
"given": "Jacobo Diego"
}
],
"container-title-short": "Brain",
"volume": "149",
"issue": "4",
"page": "1381-1395",
"DOI": "10.1093/brain/awaf412",
"PMID": "41499248",
"PMCID": "PMC13058464",
"ISSN": "0006-8950",
"publisher": "Oxford University Press",
"URL": "https://doi.org/10.1093/brain/awaf412",
"language": "en",
"issued": {
"date-parts": [
[
2026,
4,
1
]
]
}
}

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.21203/rs.3.rs-9914920/v1 [code]
Prediction of cognitive performance by demographics, sleep, and brain morphometry: machine learning findings from ENIGMA-Sleep Working Group
Journal: Research Square (preprint)
In common: neuromaps, statannotations, XGBoost, 9 other tools, structural MRI / diffusion
[2] doi:10.1007/s00234-026-04103-8 [code]
Enhanced detection of subtle cortical abnormalities in focal epilepsy using 7 T MRI surface-based models and graph neural networks.
Journal: Neuroradiology
In common: PyBIDS, statannotations, FreeSurfer, 8 other tools, EEG, structural MRI / diffusion
[3] doi:10.1186/s12967-026-08108-y [code]
An explainable multimodal machine learning model for diagnosing disorders of consciousness: evidence from a large multicenter Chinese cohort.
Journal: Journal of translational medicine
In common: MNE-Python, pandas, SciPy, 1 other tool, EEG, other condition, 6 references
[4] doi:10.64898/2026.08.18.26360725 [code]
Temporal pole blurring in hippocampal sclerosis reflects seizure-disrupted myelination
Journal: medRxiv (preprint)
In common: PyBIDS, statannotations, FreeSurfer, 8 other tools, structural MRI / diffusion
[5] doi:10.1038/s41398-026-04157-5 [code]
Association of glymphatic function with 40-Hz neural oscillations, systemic metabolic markers, and cognitive performance in healthy aging adults: An EEG and MRI study.
Journal: Translational psychiatry
In common: fMRIPrep, PyBIDS, FreeSurfer, 7 other tools, EEG, structural MRI / diffusion
[6] doi:10.1093/nc/niag043 [code]
Demographics-robust spontaneous eye blinking slowing in patients with severe acquired brain injury.
Journal: Neuroscience of consciousness
In common: statannotations, MNE-Python, seaborn, 5 other tools, other condition, 3 references
[7] doi:10.21203/rs.3.rs-9326213/v1 [code]
Multi-task fMRI outperforms resting-state fMRI for revealing task-invariant organization of the human brain
Journal: Research Square (preprint)
In common: neuromaps, statannotations, FreeSurfer, 8 other tools
[8] doi:10.64898/2026.03.09.710558 [code]
Multi-task fMRI outperforms resting-state fMRI for revealing task-invariant organization of the human brain
Journal: bioRxiv (preprint)
In common: neuromaps, statannotations, FreeSurfer, 8 other tools
[9] doi:10.1162/imag.a.1347 [code]
Neural and behavioural correlates of theory of mind reasoning in five-year-old children born preterm.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: fMRIPrep, PyBIDS, FreeSurfer, 7 other tools, other condition
[10] doi:10.1162/imag.a.1269 [code]
From early to contemporary normative modeling: Mapping individual differences in neurophysiological signals.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: specparam (formerly FOOOF), FreeSurfer, MNE-Python, 8 other tools, EEG

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.