OSCR

Stable individual differences dominate adult brain volume variation until later life.

Code ↔ Paper

2 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 2 matches
  1. [1] § Results › Dynamical aging norm curves for brain structures ↔ scripts/create_mcmc_figures.ipynb, lines 42–48 · score 0.74 · brain stem volume, supratentorial volumes, lateral ventricles, Gray matter volume, hippocampal
  2. [2] § Methods › Data ↔ scripts/create_mcmc_figures.ipynb, lines 42–48 · score 0.64 · supratentorial volume, lateral ventricles, hippocampal volume

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

Jupyter notebook · 766 lines · 33 KB · no license · 2 matches

  1. # %%
  2. import torch
  3. import pyro
  4. import numpy as np
  5. import matplotlib.pyplot as plt
  6. import matplotlib as mpl
  7. import matplotlib.ticker as ticker
  8. import os
  9. import sys
  10. module_path = os.path.abspath(os.path.join('..'))
  11. if module_path not in sys.path:
  12. sys.path.append(module_path)
  13. from src.ghmm_mcmc import GaussianHMM as ghmm
  14. #import ghmm_mcmc.GaussianHMM as ghmm
  15. #/ess/p23/home/p23-edvardgr/Code/gaussian-hmm-mcmc-main/src/ghmm_mcmc/FastGaussianHMM.py
  16. from pyro.infer import MCMC, NUTS, Predictive
  17. from pathlib import Path
  18. import warnings
  19. warnings.filterwarnings("ignore")
  20. # %%
  21. #plt.style.use('ggplot')
  22. plt.style.use('seaborn-v0_8-whitegrid')
  23. torch.set_default_dtype(torch.float64)
  24. torch.autograd.set_grad_enabled(mode=False)
  25. #mpl.rcParams['font.family'] = 'sans-serif'
  26. #mpl.rcParams['font.sans-serif'] = ['DejaVu Sans']
  27. out_dir = Path('/tsd/p23/home/p23-edvardgr/file-export') / 'edvard_export'
  28. # %%
  29. pretty_names = {"TotalHippocampus": "Total Hippocampus Volume",
  30. "TotalGrayVol": "Gray Matter Volume",
  31. "TotalWhiteVol": "White Matter Volume",
  32. "SupraTentorialVolNotVent": "Supratentorial Volume",
  33. "TotalLateralVentricle": "Total Lateral Ventricles Volume",
  34. "Brain-Stem": "Brain Stem Volume"}
  35. # %%
  36. def plt_samplesd_line(y, ax, x=None, plot_method='samples', subsample_rate=10, **args):
  37. """
  38. Args:
  39. x - tensor (samples, time)
  40. type - string, 'CI': 95%, and 50% confidence interval with median or 'samples': plot the lines directly
  41. args - plt args
  42. """
  43. with torch.no_grad():
  44. y=y[::subsample_rate]
  45. n_timesteps = y.shape[1]
  46. n_samples = y.shape[0]
  47. if x is None:
  48. x = np.arange(n_timesteps)
  49. args_ci = {}
  50. for key, value in args.items():
  51. if not key in ['label', 'linestyle', 'ls']:
  52. args_ci[key] = value
  53. if plot_method == 'CI':
  54. q = torch.tensor([0.025, 0.25, 0.5, 0.75, 0.975])
  55. quantiles = torch.quantile(y, q, dim=0, keepdim=False)
  56. # Plot first the 95% CI
  57. ax.fill_between(x, quantiles[0], quantiles[4], alpha=0.25, lw=0, **args_ci)
  58. ax.fill_between(x, quantiles[1], quantiles[3], alpha=0.25, lw=0, **args_ci)
  59. ax.plot(x, quantiles[2], **args)
  60. return ax
  61. elif plot_method == 'samples':
  62. n_max = 1000
  63. if n_samples > n_max:
  64. perm = torch.randperm(n_samples)
  65. idx = perm[:n_max]
  66. y = y[idx]
  67. alpha = max(1 / y.shape[0], 0.003)
  68. ax.plot(x, y.T, alpha=alpha, **args_ci)
  69. return ax
  70. # %%
  71. age_interval = 1.0
  72. n_controlpoints=9
  73. n_states = 1
  74. #post_fix = '_years_final_run_uio_ucam' #'_years_final_run' #'_long_icv' # '_strong_priors_smooth_spline2'
  75. post_fix = '_years_final_run'
  76. #features=["prior", "TotalHippocampus", "TotalGrayVol", "TotalWhiteVol", "SupraTentorialVolNotVent", "TotalLateralVentricle", "Brain-Stem"]
  77. features=["TotalHippocampus", "TotalGrayVol", "TotalWhiteVol", "SupraTentorialVolNotVent", "TotalLateralVentricle", "Brain-Stem"]
  78. #features = ["TotalHippocampus", "TotalGrayVol"]
  79. #features=["TotalHippocampus", "TotalGrayVol"]
  80. #features=["TotalHippocampus", "TotalGrayVol", "SupraTentorialVolNotVent", "Brain-Stem"]
  81. #features = features[:2]
  82. #dataset_path = Path('/tsd/p23/home/p23-edvardgr/Storage/p23-edvardgr') /'Didac_Data/processed_data' / f'feature_age_interval_{age_interval}_uio_ucam.npy'
  83. dataset_path = Path('/tsd/p23/home/p23-edvardgr/Storage/p23-edvardgr') /'Didac_Data/processed_data' / f'feature_age_interval_{age_interval}.npy'
  84. dataset = np.load(dataset_path, allow_pickle=True).item()
  85. device = torch.device('cpu')
  86. plot_method = 'CI'
  87. # %%
  88. # Plot the std of the dataset as function of age
  89. fig, axs = plt.subplots(2, 3, figsize=(7, 4))
  90. axs = axs.flatten()
  91. for ax, feature in zip(axs, features):
  92. data = dataset['features'][feature]
  93. #sd = np.nanstd(np.log(data), axis=0) #/np.nanmean(data, axis=0)
  94. sd = np.nanstd(data, axis=0) #/np.nanmean(data, axis=0)
  95. #sd = np.nanmean(data, axis=0)
  96. ax.plot(sd)
  97. ages = np.array([20, 30, 40, 50, 60, 70, 80, 90])
  98. ages_normed = (ages - 18)/age_interval
  99. ax.set_xticks(ages_normed)
  100. ax.set_xticklabels(ages)
  101. ax.set_ylabel("mm\u00B3")
  102. ax.set_xlabel("Age")
  103. ax.set_xlim(((18 - 18)/age_interval, (90 - 18)/age_interval))
  104. ax.set_title(feature)
  105. ax.yaxis.set_major_locator(ticker.MaxNLocator(nbins=4))
  106. fig.suptitle("Standard Deviation of Brain Structure Volumes over the Adult Lifespan")
  107. fig.tight_layout()
  108. fig.savefig(out_dir / 'std_volumes.pdf', dpi=300, bbox_inches = 'tight')
  109. # %%
  110. fig, axs = plt.subplots(2, len(features)//2, figsize=(7, 4))
  111. axs = axs.flatten()
  112. for feature_idx, feature in enumerate(features):
  113. feature_name = feature
  114. if feature == "prior":
  115. feature_name = 'TotalHippocampus'
  116. print(feature, feature_name)
  117. results_dir = Path('/tsd/p23/home/p23-edvardgr/Code/gaussian-hmm-job-scripts/model_fitter_test/Results') / f'{feature_name}_age_int_{age_interval:.1f}{post_fix}'
  118. mcmc_samples_path = results_dir / 'mcmc_samples.pht'
  119. #meta_data_dict = torch.load(results_dir / 'meta_dict.pht', map_location=torch.device('cpu'), weights_only=False)
  120. y = torch.tensor(dataset['features'][feature_name][: ,:, np.newaxis], device=device, dtype=torch.float64)
  121. n_timesteps = dataset['features'][feature_name].shape[-1]
  122. priors = {}
  123. priors['R_sigma'] = {'loc': dataset['measurment_error'][feature_name]/dataset['norm_std'][feature_name],
  124. 'scale': 0.5*dataset['measurment_error'][feature_name] /dataset['norm_std'][feature_name]}
  125. priors['z0_corr_concentration'] = 1000.0
  126. z0_mu_covariates={'sex': {'type': 'c', 'dim': 2, 'priors': {'loc': torch.tensor([0., 0.]), 'scale': torch.tensor([0.2, 0.01])}},
  127. 'icv': {'type': 'r', 'dim': 1, 'priors': {'loc': torch.tensor([[0.], [0.]]), 'scale': torch.tensor([[1.], [0.01]])}} }
  128. n_sites = dataset['covariates']['site'].shape[-1]
  129. y_bias_covariates={'site': {'type': 'c', 'dim': n_sites, 'priors': {'loc': torch.tensor([0.]), 'scale': torch.tensor([0.1])}}}
  130. model = ghmm.GaussianStateModel(n_timesteps, n_controlpoints,
  131. n_states, device=device, priors=priors,
  132. z0_mu_covariates=z0_mu_covariates,
  133. y_bias_covariates=y_bias_covariates)
  134. mcmc_samples = torch.load(mcmc_samples_path, map_location=torch.device('cpu'), weights_only=False)
  135. # Subsample the mcmc_samples
  136. new_samples = {}
  137. for key, value in mcmc_samples.items():
  138. new_samples[key] = value[::10]
  139. colors = plt.rcParams['axes.prop_cycle'].by_key()['color']
  140. #for age_idx, start_age in enumerate([18, 35, 50, 60, 70]):
  141. # start_age_adjusted = int((start_age-18)/age_interval)
  142. # nac, nac_R = model.get_auto_covariance_coeff(t0 = start_age_adjusted, unconstrained_params=new_samples)
  143. # nac = nac[..., 0, 1].squeeze()
  144. # #nac = nac_R.squeeze()
  145. # plt_samplesd_line(nac[:, start_age_adjusted:], axs[feature_idx], x=np.arange(start_age_adjusted, n_timesteps), plot_method=plot_method, subsample_rate=1, color=colors[age_idx], label=f"{start_age}")
  146. corr_coef = model.get_correlation_coeff(unconstrained_params=new_samples).squeeze()
  147. plt_samplesd_line(corr_coef, axs[feature_idx], plot_method=plot_method, subsample_rate=1, color='black', label="Volume")
  148. Delta_Ts = [1, 2, 4, 8, 16]
  149. colors = plt.rcParams['axes.prop_cycle'].by_key()['color']
  150. for plot_idx, Delta_T in enumerate(Delta_Ts):
  151. corr_dy_v = model.get_dy_v_covariance(Delta_T=Delta_T, unconstrained_params=new_samples).squeeze()
  152. if Delta_T == 1:
  153. label = f"{Delta_T} Yr Interval"
  154. else:
  155. label = f"{Delta_T} Yrs Interval"
  156. plt_samplesd_line(corr_dy_v, axs[feature_idx], x=np.arange(Delta_T, n_timesteps),
  157. plot_method=plot_method, subsample_rate=1, color=colors[plot_idx], label=label, ls='dotted')
  158. axs[feature_idx].set_ylim((0.8, 1.05))
  159. axs[feature_idx].set_title(f'{pretty_names[feature]}')
  160. ages = np.array([20, 30, 40, 50, 60, 70, 80, 90])
  161. ages_normed = (ages - 18)/age_interval
  162. axs[feature_idx].set_xticks(ages_normed)
  163. axs[feature_idx].set_xticklabels(ages)
  164. axs[feature_idx].set_xlim(((18 - 18)/age_interval, (90 - 18)/age_interval))
  165. y_ticks = np.linspace(0, 1, 6)
  166. axs[feature_idx].set_yticks(y_ticks)
  167. if feature_idx//3 == 1:
  168. axs[feature_idx].set_xlabel('Age')
  169. if feature_idx%3 == 0:
  170. axs[feature_idx].set_ylabel(r'$\rho$')
  171. # Assume all subplots share the same legend entries;
  172. # Get handles and labels from one of the axes.
  173. handles, labels = axs[0].get_legend_handles_labels()
  174. # Create a legend on the figure (centered below all subplots)
  175. fig.legend(handles, labels, loc='lower center', ncol=len(labels)//2,
  176. bbox_to_anchor=(0.5, -0.10))
  177. # Adjust the layout to provide space for the legend
  178. fig.subplots_adjust(bottom=0.25)
  179. fig.suptitle('Correlation of Estimates of Change Rate with Latent Change Rate')
  180. fig.tight_layout()
  181. fig.savefig(out_dir / 'correlation_vol_changerate.pdf', dpi=300, bbox_inches = 'tight')
  182. # %%
  183. fig, axs = plt.subplots(2, len(features)//2, figsize=(7, 4))
  184. axs = axs.flatten()
  185. for feature_idx, feature in enumerate(features):
  186. feature_name = feature
  187. if feature == "prior":
  188. feature_name = 'TotalHippocampus'
  189. print(feature, feature_name)
  190. results_dir = Path('/tsd/p23/home/p23-edvardgr/Code/gaussian-hmm-job-scripts/model_fitter_test/Results') / f'{feature_name}_age_int_{age_interval:.1f}{post_fix}'
  191. mcmc_samples_path = results_dir / 'mcmc_samples.pht'
  192. #meta_data_dict = torch.load(results_dir / 'meta_dict.pht', map_location=torch.device('cpu'), weights_only=False)
  193. y = torch.tensor(dataset['features'][feature_name][: ,:, np.newaxis], device=device, dtype=torch.float64)
  194. n_timesteps = dataset['features'][feature_name].shape[-1]
  195. priors = {}
  196. priors['R_sigma'] = {'loc': dataset['measurment_error'][feature_name]/dataset['norm_std'][feature_name],
  197. 'scale': 0.5*dataset['measurment_error'][feature_name] /dataset['norm_std'][feature_name]}
  198. priors['z0_corr_concentration'] = 1000.0
  199. z0_mu_covariates={'sex': {'type': 'c', 'dim': 2, 'priors': {'loc': torch.tensor([0., 0.]), 'scale': torch.tensor([0.2, 0.01])}},
  200. 'icv': {'type': 'r', 'dim': 1, 'priors': {'loc': torch.tensor([[0.], [0.]]), 'scale': torch.tensor([[1.], [0.01]])}} }
  201. n_sites = dataset['covariates']['site'].shape[-1]
  202. y_bias_covariates={'site': {'type': 'c', 'dim': n_sites, 'priors': {'loc': torch.tensor([0.]), 'scale': torch.tensor([0.1])}}}
  203. model = ghmm.GaussianStateModel(n_timesteps, n_controlpoints,
  204. n_states, device=device, priors=priors,
  205. z0_mu_covariates=z0_mu_covariates,
  206. y_bias_covariates=y_bias_covariates)
  207. mcmc_samples = torch.load(mcmc_samples_path, map_location=torch.device('cpu'), weights_only=False)
  208. # Subsample the mcmc_samples
  209. new_samples = {}
  210. for key, value in mcmc_samples.items():
  211. new_samples[key] = value[::10]
  212. colors = plt.rcParams['axes.prop_cycle'].by_key()['color']
  213. start_age_adjusted = 0
  214. nac, nac_R = model.get_auto_covariance_coeff(t0 = start_age_adjusted, unconstrained_params=new_samples)
  215. r2 = nac[..., 0, 0].squeeze()**2
  216. #nac = nac_R.squeeze()
  217. plt_samplesd_line(r2[:, start_age_adjusted:], axs[feature_idx],
  218. x=np.arange(start_age_adjusted, n_timesteps),
  219. plot_method=plot_method, subsample_rate=1,
  220. color=colors[0], label=f"Latent volume")
  221. r2_R = nac_R.squeeze()**2
  222. plt_samplesd_line(r2_R[:, start_age_adjusted:], axs[feature_idx],
  223. x=np.arange(start_age_adjusted, n_timesteps),
  224. plot_method=plot_method, subsample_rate=1,
  225. color=colors[1], label=f"Measured volume")
  226. print_ages = np.array([30, 40, 50, 60, 70, 80, 90])
  227. print(feature)
  228. print('R2 latent:')
  229. for print_age in print_ages:
  230. print(f"{print_age}: {torch.mean(r2[:, int((print_age-18)/age_interval)]).item():.4f} - ", end='')
  231. print('R2 measured:')
  232. for print_age in print_ages:
  233. print(f"{print_age}: {torch.mean(r2_R[:, int((print_age-18)/age_interval)]).item():.4f} - ", end='')
  234. axs[feature_idx].set_ylim((0.8, 1.05))
  235. axs[feature_idx].set_title(f'{pretty_names[feature]}')
  236. ages = np.array([20, 30, 40, 50, 60, 70, 80, 90])
  237. ages_normed = (ages - 18)/age_interval
  238. axs[feature_idx].set_xticks(ages_normed)
  239. axs[feature_idx].set_xticklabels(ages)
  240. axs[feature_idx].set_xlim(((18 - 18)/age_interval, (90 - 18)/age_interval))
  241. y_ticks = np.linspace(0, 1, 6)
  242. axs[feature_idx].set_yticks(y_ticks)
  243. if feature_idx//3 == 1:
  244. axs[feature_idx].set_xlabel('Age')
  245. if feature_idx%3 == 0:
  246. axs[feature_idx].set_ylabel('R\u00B2')
  247. # Assume all subplots share the same legend entries;
  248. # Get handles and labels from one of the axes.
  249. handles, labels = axs[0].get_legend_handles_labels()
  250. # Create a legend on the figure (centered below all subplots)
  251. fig.legend(handles, labels, loc='lower center', ncol=len(labels), bbox_to_anchor=(0.5, -0.05))
  252. # Adjust the layout to provide space for the legend
  253. fig.subplots_adjust(bottom=0.25)
  254. fig.suptitle('Explained Variance from Volume Levels at Age 18')
  255. fig.tight_layout()
  256. fig.savefig(out_dir / 'explained_variance.pdf', dpi=300, bbox_inches = 'tight')
  257. # %%
  258. fig, axs = plt.subplots(2, len(features)//2, figsize=(7, 4))
  259. axs = axs.flatten()
  260. for feature_idx, feature in enumerate(features):
  261. feature_name = feature
  262. if feature == "prior":
  263. feature_name = 'TotalHippocampus'
  264. print(feature, feature_name)
  265. results_dir = Path('/tsd/p23/home/p23-edvardgr/Code/gaussian-hmm-job-scripts/model_fitter_test/Results') / f'{feature_name}_age_int_{age_interval:.1f}{post_fix}'
  266. mcmc_samples_path = results_dir / 'mcmc_samples.pht'
  267. #meta_data_dict = torch.load(results_dir / 'meta_dict.pht', map_location=torch.device('cpu'), weights_only=False)
  268. y = torch.tensor(dataset['features'][feature_name][: ,:, np.newaxis], device=device, dtype=torch.float64)
  269. n_timesteps = dataset['features'][feature_name].shape[-1]
  270. priors = {}
  271. priors['R_sigma'] = {'loc': dataset['measurment_error'][feature_name]/dataset['norm_std'][feature_name],
  272. 'scale': 0.5*dataset['measurment_error'][feature_name] /dataset['norm_std'][feature_name]}
  273. priors['z0_corr_concentration'] = 1000.0
  274. z0_mu_covariates={'sex': {'type': 'c', 'dim': 2, 'priors': {'loc': torch.tensor([0., 0.]), 'scale': torch.tensor([0.2, 0.01])}},
  275. 'icv': {'type': 'r', 'dim': 1, 'priors': {'loc': torch.tensor([[0.], [0.]]), 'scale': torch.tensor([[1.], [0.01]])}} }
  276. n_sites = dataset['covariates']['site'].shape[-1]
  277. y_bias_covariates={'site': {'type': 'c', 'dim': n_sites, 'priors': {'loc': torch.tensor([0.]), 'scale': torch.tensor([0.1])}}}
  278. model = ghmm.GaussianStateModel(n_timesteps, n_controlpoints,
  279. n_states, device=device, priors=priors,
  280. z0_mu_covariates=z0_mu_covariates,
  281. y_bias_covariates=y_bias_covariates)
  282. mcmc_samples = torch.load(mcmc_samples_path, map_location=torch.device('cpu'), weights_only=False)
  283. # Subsample the mcmc_samples
  284. new_samples = {}
  285. for key, value in mcmc_samples.items():
  286. new_samples[key] = value[::10]
  287. colors = plt.rcParams['axes.prop_cycle'].by_key()['color']
  288. for age_idx, start_age in enumerate([18, 35, 50, 60, 70]):
  289. start_age_adjusted = int((start_age-18)/age_interval)
  290. nac, nac_R = model.get_auto_covariance_coeff(t0 = start_age_adjusted, unconstrained_params=new_samples)
  291. nac = nac[..., 1, 1].squeeze()
  292. plt_samplesd_line(nac[:, start_age_adjusted:], axs[feature_idx], x=np.arange(start_age_adjusted, n_timesteps), plot_method=plot_method, subsample_rate=1, color=colors[age_idx], label=f"{start_age}")
  293. axs[feature_idx].set_ylim((0.8, 1.05))
  294. axs[feature_idx].set_title(f'{pretty_names[feature]}')
  295. ages = np.array([20, 30, 40, 50, 60, 70, 80, 90])
  296. ages_normed = (ages - 18)/age_interval
  297. axs[feature_idx].set_xticks(ages_normed)
  298. axs[feature_idx].set_xticklabels(ages)
  299. axs[feature_idx].set_xlim(((18 - 18)/age_interval, (90 - 18)/age_interval))
  300. y_ticks = np.linspace(0, 1, 6)
  301. axs[feature_idx].set_yticks(y_ticks)
  302. if feature_idx//3 == 1:
  303. axs[feature_idx].set_xlabel('Age')
  304. if feature_idx%3 == 0:
  305. axs[feature_idx].set_ylabel(r"$\rho_{AC}$")
  306. # Assume all subplots share the same legend entries;
  307. # Get handles and labels from one of the axes.
  308. handles, labels = axs[0].get_legend_handles_labels()
  309. # Create a legend on the figure (centered below all subplots)
  310. fig.legend(handles, labels, loc='lower center', ncol=len(labels), bbox_to_anchor=(0.5, -0.05))
  311. # Adjust the layout to provide space for the legend
  312. fig.subplots_adjust(bottom=0.25)
  313. fig.suptitle('Autocorrelation of Latent Change Rate')
  314. fig.tight_layout()
  315. fig.savefig(out_dir / 'correlation_changerate.pdf', dpi=300, bbox_inches = 'tight')
  316. # %%
  317. for key in mcmc_samples.keys():
  318. print(f"'{key}': '',")
  319. # %%
  320. #fig, axs_features = plt.subplots(3, len(features), figsize=(len(features)/6*20, 5), sharex=True)
  321. fig = plt.figure(figsize=(8, 20))
  322. rows = 1
  323. subfigs = fig.subfigures(rows, int(np.ceil(len(features)/rows))).flatten()
  324. pretty_coef_names = {'R_sigma': r'$\sigma_R$',
  325. 'b_t_coeffs': r'$b(t)$',
  326. 'sigma_p_coeffs': r'$\sigma_q(t)$',
  327. 'y_bias.cat_coeffs.site.params': r'$\beta(site)$',
  328. 'z0_mu.bias': r'$\beta_{sv0}$',
  329. 'z0_mu.cat_coeffs.sex.params': r'$\beta_{sv0,sex}$',
  330. 'z0_mu.regressors.icv': r'$\beta_{sv0,ICV}$',
  331. 'z0_sigma': r'$\sigma_{sv0}$'}
  332. for feature_idx, feature in enumerate(features):
  333. feature_name = feature
  334. if feature == "prior":
  335. feature_name = 'TotalHippocampus'
  336. print(feature, feature_name)
  337. results_dir = Path('/tsd/p23/home/p23-edvardgr/Code/gaussian-hmm-job-scripts/model_fitter_test/Results') / f'{feature_name}_age_int_{age_interval:.1f}{post_fix}'
  338. mcmc_samples_path = results_dir / 'mcmc_samples.pht'
  339. #meta_data_dict = torch.load(results_dir / 'meta_dict.pht', map_location=torch.device('cpu'), weights_only=False)
  340. y = torch.tensor(dataset['features'][feature_name][: ,:, np.newaxis], device=device, dtype=torch.float64)
  341. n_timesteps = dataset['features'][feature_name].shape[-1]
  342. priors = {}
  343. priors['R_sigma'] = {'loc': dataset['measurment_error'][feature_name]/dataset['norm_std'][feature_name],
  344. 'scale': 0.5*dataset['measurment_error'][feature_name] /dataset['norm_std'][feature_name]}
  345. priors['z0_corr_concentration'] = 1000.0
  346. z0_mu_covariates={'sex': {'type': 'c', 'dim': 2, 'priors': {'loc': torch.tensor([0., 0.]), 'scale': torch.tensor([1., 0.01])}}}
  347. n_sites = dataset['covariates']['site'].shape[-1]
  348. y_bias_covariates={'site': {'type': 'c', 'dim': n_sites, 'priors': {'loc': torch.tensor([0.]), 'scale': torch.tensor([0.1])}}}
  349. model = ghmm.GaussianStateModel(n_timesteps, n_controlpoints,
  350. n_states, device=device, priors=priors,
  351. z0_mu_covariates=z0_mu_covariates,
  352. y_bias_covariates=y_bias_covariates)
  353. model.norm_mean = dataset['norm_means'][feature_name]
  354. model.norm_std = dataset['norm_std'][feature_name]
  355. if feature == 'prior':
  356. mcmc_samples = Predictive(model, {}, num_samples=100, parallel=True)(y[[0]])
  357. else:
  358. mcmc_samples = torch.load(mcmc_samples_path, map_location=torch.device('cpu'), weights_only=False)
  359. n_params = len(list(pretty_coef_names.keys()))
  360. n_params = 0
  361. for idx, (param_name, pretty_coef_name) in enumerate(pretty_coef_names.items()):
  362. params = mcmc_samples[param_name]
  363. params = params.reshape(params.shape[0], -1).cpu().detach().numpy()
  364. n_params += params.shape[1]
  365. print(n_params)
  366. axs = subfigs[feature_idx].subplots(n_params, 1, sharex=True)
  367. #subfigs[feature_idx].subplots_adjust(hspace=0.4, wspace=0.4)
  368. subfigs[feature_idx].suptitle(pretty_names[feature], y=0.91, wrap=True)
  369. param_idx = 0
  370. for idx, (param_name, pretty_coef_name) in enumerate(pretty_coef_names.items()):
  371. params = mcmc_samples[param_name]
  372. params = params.reshape(params.shape[0], -1).cpu().detach().numpy()
  373. axs[param_idx].text(0, 1, pretty_coef_name, verticalalignment='bottom', horizontalalignment='right', transform=axs[param_idx].transAxes, rotation=90, rotation_mode='anchor')
  374. for sub_param_idx in range(params.shape[1]):
  375. axs[param_idx].plot(params[:, sub_param_idx], lw=0.5)
  376. axs[param_idx].axis('off')
  377. param_idx += 1
  378. axs[param_idx-1].plot([0, 1], [0, 0], color='black', transform=axs[param_idx-1].transAxes)
  379. #fig.tight_layout()
  380. #plt.show()
  381. fig.savefig(out_dir / 'trace_plots.pdf', dpi=300, bbox_inches = 'tight')
  382. # %%
  383. #fig, axs_features = plt.subplots(3, len(features), figsize=(len(features)/6*20, 5), sharex=True)
  384. fig = plt.figure(figsize=(7, 7), dpi=300)
  385. rows = 2
  386. cols = int(np.ceil(len(features)/rows))
  387. subfigs = fig.subfigures(rows, cols).flatten()
  388. for feature_idx, feature in enumerate(features):
  389. feature_name = feature
  390. if feature == "prior":
  391. feature_name = 'TotalHippocampus'
  392. print(feature, feature_name)
  393. results_dir = Path('/tsd/p23/home/p23-edvardgr/Code/gaussian-hmm-job-scripts/model_fitter_test/Results') / f'{feature_name}_age_int_{age_interval:.1f}{post_fix}'
  394. mcmc_samples_path = results_dir / 'mcmc_samples.pht'
  395. #meta_data_dict = torch.load(results_dir / 'meta_dict.pht', map_location=torch.device('cpu'), weights_only=False)
  396. y = torch.tensor(dataset['features'][feature_name][: ,:, np.newaxis], device=device, dtype=torch.float64)
  397. n_timesteps = dataset['features'][feature_name].shape[-1]
  398. priors = {}
  399. priors['R_sigma'] = {'loc': dataset['measurment_error'][feature_name]/dataset['norm_std'][feature_name],
  400. 'scale': 0.5*dataset['measurment_error'][feature_name] /dataset['norm_std'][feature_name]}
  401. priors['z0_corr_concentration'] = 1000.0
  402. z0_mu_covariates={'sex': {'type': 'c', 'dim': 2, 'priors': {'loc': torch.tensor([0., 0.]), 'scale': torch.tensor([0.2, 0.01])}},
  403. 'icv': {'type': 'r', 'dim': 1, 'priors': {'loc': torch.tensor([[0.], [0.]]), 'scale': torch.tensor([[1.], [0.01]])}} }
  404. n_sites = dataset['covariates']['site'].shape[-1]
  405. y_bias_covariates={'site': {'type': 'c', 'dim': n_sites, 'priors': {'loc': torch.tensor([0.]), 'scale': torch.tensor([0.1])}}}
  406. model = ghmm.GaussianStateModel(n_timesteps, n_controlpoints,
  407. n_states, device=device, priors=priors,
  408. z0_mu_covariates=z0_mu_covariates,
  409. y_bias_covariates=y_bias_covariates)
  410. model.norm_mean = dataset['norm_means'][feature_name]
  411. model.norm_std = dataset['norm_std'][feature_name]
  412. if feature == 'prior':
  413. mcmc_samples = Predictive(model, {}, num_samples=100, parallel=True)(y[[0]])
  414. else:
  415. mcmc_samples = torch.load(mcmc_samples_path, map_location=torch.device('cpu'), weights_only=False)
  416. mu_t_g_t, Sigma_t_g_t, y_mu, y_Sigma, b_t, Q_t, _ = model.get_posterior_distribution(unconstrained_params=mcmc_samples)
  417. print(f'mu_t_g_t: {mu_t_g_t.shape}')
  418. print(f'Sigma_t_g_t: {Sigma_t_g_t.shape}')
  419. print(f'b_t: {b_t.shape}')
  420. print(f'Q_t: {Q_t.shape}')
  421. age_range = 100-18
  422. if not ('prior' in features):
  423. mu_t_g_t[..., 0] = mu_t_g_t[..., 0]*model.norm_std + model.norm_mean
  424. mu_t_g_t[..., 1] = mu_t_g_t[..., 1]*model.norm_std/(age_range)
  425. Sigma_t_g_t[..., 0, 0] = Sigma_t_g_t[..., 0, 0]*model.norm_std**2
  426. Sigma_t_g_t[..., 1, 1] = Sigma_t_g_t[..., 1, 1]*model.norm_std**2/(age_range**2)
  427. b_t = b_t*model.norm_std/(age_range**2)
  428. Q_t = Q_t*model.norm_std**2/(age_range**4)
  429. #axs = axs_features[:, feature_idx]
  430. axs = subfigs[feature_idx].subplots(2, 1)
  431. subfigs[feature_idx].subplots_adjust(hspace=0.4, wspace=0.2)
  432. subfigs[feature_idx].suptitle(pretty_names[feature])
  433. ax_s = axs[0]
  434. ax_v = axs[1]
  435. #ax_a = axs[2]
  436. if not ('prior' in features):
  437. for i in range(y.shape[0]):
  438. # Get the indices where the observations are not missing
  439. nan_idx = np.isnan(y[i, :, 0].detach().cpu().numpy())
  440. t = np.arange(y.shape[1])[~nan_idx]
  441. ax_s.plot(t, y[i, ~nan_idx, 0].detach().cpu().numpy(), '.-', alpha=0.02, markersize=2, color='black', rasterized=True)
  442. alpha = 0.003
  443. for idx in range(mu_t_g_t.shape[-1]):
  444. mean = mu_t_g_t[:, ..., idx].detach().squeeze().cpu()
  445. std = torch.sqrt(Sigma_t_g_t[:, ..., idx, idx].detach().squeeze().cpu())
  446. if idx == 0:
  447. Sigma_icv = (mcmc_samples['z0_mu.regressors.icv'].squeeze()[..., 0]**2 * 1.0)[:,None]
  448. std = torch.sqrt(std**2 + Sigma_icv)
  449. #axs[idx+1].plot(mean, label=f"State {idx}", color='blue', alpha=alpha)
  450. plt_samplesd_line(mean, axs[idx], plot_method=plot_method, color='blue')
  451. plt_samplesd_line(mean + 2*std, axs[idx], plot_method=plot_method, color='red')
  452. plt_samplesd_line(mean - 2*std, axs[idx], plot_method=plot_method, color='red')
  453. mean = mu_t_g_t[:, ..., :int((90-18)/age_interval), idx].detach().squeeze().cpu()
  454. std = torch.sqrt(Sigma_t_g_t[:, ..., :int((90-18)/age_interval), idx, idx].detach().squeeze().cpu())
  455. min_value = torch.min(torch.mean(mean, dim=0) - 2*std)
  456. max_value = torch.max(torch.mean(mean, dim=0) + 2*std)
  457. margin = (max_value - min_value)*0.075
  458. y_lim = (min_value - margin, max_value + margin)
  459. axs[idx].set_ylim(y_lim)
  460. # Plot the posterior of the acceleration
  461. #mean = b_t[:, ..., 0].detach().squeeze().cpu()
  462. #std = torch.sqrt(Q_t[:, ..., 0].detach().squeeze().cpu())
  463. #mean = b_t[:, ..., :int((90-18)/age_interval), 0].detach().squeeze().cpu()
  464. #std = torch.sqrt(Q_t[:, ..., :int((90-18)/age_interval), 0].detach().squeeze().cpu())
  465. #min_value = torch.min(torch.mean(mean, dim=0) - 2*std)
  466. #max_value = torch.max(torch.mean(mean, dim=0) + 2*std)
  467. #margin = (max_value - min_value)*0.075
  468. #y_lim = (min_value - margin, max_value + margin)
  469. #ax_a.set_ylim(y_lim)
  470. #plt_samplesd_line(mean, ax_a, plot_method=plot_method, color='blue')
  471. #plt_samplesd_line(mean + 2*std, ax_a, plot_method=plot_method, color='red')
  472. #plt_samplesd_line(mean - 2*std, ax_a, plot_method=plot_method, color='red')
  473. #ax_s.set_title('Volume')
  474. ax_v.set_title("Change Rate")
  475. #ax_a.set_title("Second derviative")
  476. if feature_idx%cols==0:
  477. ax_s.set_ylabel("mm\u00B3 ")
  478. ax_v.set_ylabel("mm\u00B3/year")
  479. #ax_a.set_ylabel("mm\u00B3/year\u00B2")
  480. ax_v.set_xlabel("Age")
  481. ages = np.array([20, 30, 40, 50, 60, 70, 80, 90])
  482. ages_normed = (ages - 18)/age_interval
  483. ax_s.set_xticks(ages_normed)
  484. ax_s.set_xticklabels(ages)
  485. ax_v.set_xticks(ages_normed)
  486. ax_v.set_xticklabels(ages)
  487. ax_s.ticklabel_format(style='sci', useOffset=False, axis='y', scilimits=(3, 3))
  488. ax_v.ticklabel_format(style='sci', useOffset=False, axis='y', scilimits=(3, 3))
  489. #ax_a.ticklabel_format(style='sci', useOffset=False, axis='y', scilimits=(3, 3))
  490. ax_s.yaxis.set_major_locator(ticker.MaxNLocator(nbins=6))
  491. ax_v.yaxis.set_major_locator(ticker.MaxNLocator(nbins=6))
  492. #ax_a.yaxis.set_major_locator(ticker.MaxNLocator(nbins=6))
  493. ax_s.set_xlim((0, (90-18)/age_interval))
  494. ax_v.set_xlim((0, (90-18)/age_interval))
  495. #fig.tight_layout()
  496. #plt.show()
  497. fig.savefig(out_dir / 'norm_curves.pdf', dpi=300, bbox_inches = 'tight')
  498. # %%
  499. fig, axs = plt.subplots(2, len(features)//2, figsize=(7, 4))
  500. axs = axs.flatten()
  501. for feature_idx, feature in enumerate(features):
  502. feature_name = feature
  503. if feature == "prior":
  504. feature_name = 'TotalHippocampus'
  505. print(feature, feature_name)
  506. results_dir = Path('/tsd/p23/home/p23-edvardgr/Code/gaussian-hmm-job-scripts/model_fitter_test/Results') / f'{feature_name}_age_int_{age_interval:.1f}{post_fix}'
  507. mcmc_samples_path = results_dir / 'mcmc_samples.pht'
  508. #meta_data_dict = torch.load(results_dir / 'meta_dict.pht', map_location=torch.device('cpu'), weights_only=False)
  509. y = torch.tensor(dataset['features'][feature_name][: ,:, np.newaxis], device=device, dtype=torch.float64)
  510. n_timesteps = dataset['features'][feature_name].shape[-1]
  511. priors = {}
  512. priors['R_sigma'] = {'loc': dataset['measurment_error'][feature_name]/dataset['norm_std'][feature_name],
  513. 'scale': 0.5*dataset['measurment_error'][feature_name] /dataset['norm_std'][feature_name]}
  514. priors['z0_corr_concentration'] = 1000.0
  515. z0_mu_covariates={'sex': {'type': 'c', 'dim': 2, 'priors': {'loc': torch.tensor([0., 0.]), 'scale': torch.tensor([0.2, 0.01])}},
  516. 'icv': {'type': 'r', 'dim': 1, 'priors': {'loc': torch.tensor([[0.], [0.]]), 'scale': torch.tensor([[1.], [0.01]])}} }
  517. n_sites = dataset['covariates']['site'].shape[-1]
  518. y_bias_covariates={'site': {'type': 'c', 'dim': n_sites, 'priors': {'loc': torch.tensor([0.]), 'scale': torch.tensor([0.1])}}}
  519. mcmc_samples = torch.load(mcmc_samples_path, map_location=torch.device('cpu'), weights_only=False)
  520. # Subsample the mcmc_samples
  521. new_samples = {}
  522. for key, value in mcmc_samples.items():
  523. new_samples[key] = value[::300]
  524. colors = plt.rcParams['axes.prop_cycle'].by_key()['color']
  525. model = ghmm.GaussianStateModel(n_timesteps, n_controlpoints,
  526. n_states, device=device, priors=priors,
  527. z0_mu_covariates=z0_mu_covariates,
  528. y_bias_covariates=y_bias_covariates)
  529. #corr_coef = model.get_correlation_coeff(unconstrained_params=new_samples).squeeze()
  530. #plt_samplesd_line(corr_coef, axs[feature_idx], plot_method=plot_method, subsample_rate=1, color='black', label="$NAC_{s_k v_k}$")
  531. n_samples = [1, 5, 11]
  532. linestyles = ['dotted', (0, (1, 1)), (0, (0.5, 0.5))]
  533. age_sample_intervals = [1, 2, 4]
  534. colors = plt.rcParams['axes.prop_cycle'].by_key()['color']
  535. for age_int_idx, age_sample_interval in enumerate(age_sample_intervals):
  536. for plot_idx, n_sample in enumerate(n_samples):
  537. new_n_timesteps = int(n_timesteps*n_sample/age_sample_interval)
  538. model = ghmm.GaussianStateModel(new_n_timesteps, n_controlpoints,
  539. n_states, device=device, priors=priors,
  540. z0_mu_covariates=z0_mu_covariates,
  541. y_bias_covariates=y_bias_covariates)
  542. corr_dy_v = model.get_alpha_v_covariance(n=n_sample, unconstrained_params=new_samples).squeeze()
  543. if age_sample_interval == 1:
  544. label = f"{age_sample_interval} Yr Interval - {n_sample+1} Samples"
  545. else:
  546. label = f"{age_sample_interval} Yrs Interval - {n_sample+1} Samples"
  547. #age80_normalized = np.round((80-18)/(age_interval*age_sample_interval)*n_sample-n_sample)
  548. #age80_corr = torch.mean(corr_dy_v[:, age80_normalized]).item()
  549. #axs[feature_idx].plot((age80_normalized + n_sample)/n_sample*age_sample_interval , age80_corr, 'x', color='black')
  550. #print(f"Interval {age_sample_interval} years, N samples {n_sample +1}, corr age 80 {age80_corr}")
  551. plt_samplesd_line(corr_dy_v, axs[feature_idx], x=np.arange(n_sample+1, new_n_timesteps)/n_sample*age_sample_interval,
  552. plot_method=plot_method, subsample_rate=1, color=colors[age_int_idx], label=label, ls=linestyles[plot_idx])
  553. #axs[feature_idx].set_ylim((0.8, 1.05))
  554. axs[feature_idx].set_title(f'{pretty_names[feature]}')
  555. ages = np.array([20, 30, 40, 50, 60, 70, 80, 90])
  556. ages_normed = (ages - 18)/age_interval
  557. axs[feature_idx].set_xticks(ages_normed)
  558. axs[feature_idx].set_xticklabels(ages)
  559. axs[feature_idx].set_xlim(((18 - 18)/age_interval, (90 - 18)/age_interval))
  560. y_ticks = np.linspace(0, 1, 6)
  561. axs[feature_idx].set_yticks(y_ticks)
  562. if feature_idx//3 == 1:
  563. axs[feature_idx].set_xlabel('Age')
  564. if feature_idx%3 == 0:
  565. axs[feature_idx].set_ylabel(r'\rho')
  566. # Assume all subplots share the same legend entries;
  567. # Get handles and labels from one of the axes.
  568. handles, labels = axs[0].get_legend_handles_labels()
  569. # Create a legend on the figure (centered below all subplots)
  570. fig.legend(handles, labels, loc='lower center', ncol=3, bbox_to_anchor=(0.5, -0.15))
  571. # Adjust the layout to provide space for the legend
  572. fig.subplots_adjust(bottom=0.25)
  573. fig.suptitle('Correlation of Estimates of Change Rate with Latent Change Rate Using Two or More Time Points')
  574. fig.tight_layout()
  575. fig.savefig(out_dir / 'num_sessions_changerate.pdf', dpi=300, bbox_inches = 'tight')

create_mcmc_figures.ipynb at commit 49d09d4, no license · at the source

Overview

20 affiliations
  1. Center for Lifespan Changes in Brain and Cognition (LCBC), Department of Psychology, University of Oslo, Oslo, Norway
  2. Computational Radiology and Artificial Intelligence (CRAI), Department of Radiology and Nuclear Medicine, Oslo University Hospital, Oslo, Norway
  3. Department of Medicine, Faculty of Medicine and Health Sciences, Institute of Neurosciences, University of Barcelona, Barcelona, Spain
  4. Institut Guttmann, Institut Universitari de Neurorehabilitació adscrit a la UAB, Badalona, Spain
  5. The August Pi i Sunyer Biomedical Research Institute (IDIBAPS), Hospital Clinic of Barcelona, Barcelona, Spain
  6. Center for Lifespan Psychology, Max Planck Institute for Human Development, Berlin, Germany
  7. Department of Psychology, MSB Medical School Berlin, Berlin, Germany
  8. Max Planck UCL Centre for Computational Psychiatry and Ageing Research, Berlin, Germany, and London, United Kingdom
  9. Fundació Institut d’Investigació en Ciències de la Salut Germans Trias i Pujol, Badalona, Spain
  10. MRC Cognition and Brain Sciences Unit, Department of Psychiatry, University of Cambridge, Cambridge, United Kingdom
  11. Center for Environmental Neuroscience, Max Planck Institute for Human Development, Berlin, Germany
  12. Department of Psychiatry and Psychotherapy, University Medical Center Hamburg-Eppendorf, Hamburg, Germany
  13. Umeå Center for Functional Brain Imaging, Umeå University, Umeå, Sweden
  14. Department of Medical and Translational Biology, Umeå University, Umeå, Sweden
  15. Department of Diagnostics and Intervention, Umeå University, Umeå, Sweden
  16. Hinda and Arthur Marcus Institute for Aging Research, Deanna and Sidney Wolk Center for Memory Health, Hebrew SeniorLife, Boston, MA, United States
  17. Department of Neurology, Harvard Medical School, Boston, MA, United States
  18. Oxford Centre for Functional MRI of the Brain (FMRIB/WIN), Oxford University, Oxford, United Kingdom
  19. Oslo Delirium Research Group, Institute of Clinical Medicine, Campus Ahus, University of Oslo, Oslo, Norway
  20. Department of Geriatric Medicine, Akershus University Hospital, Oslo, Norway
Journal: Imaging neuroscience (Cambridge, Mass.), volume 4, article IMAG.a.1242
Dates: received 12 August 2025; accepted 13 April 2026; published online 26 May 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1162/imag.a.1242 · PMID 42212223 · PMCID PMC13214574 · OpenAlex W7158467521
Open access: diamond, a free copy (OpenAlex)
Status: code verified
Categories: structural MRI / diffusion (modality), human (organism), computational (subfield)
Methods: Smoothing, state filtering, decompositions
Keywords: stochastic dynamical system, brain aging, magnetic resonance imaging, methods, MRI, brain age, BAG
Topic: Functional Brain Connectivity Studies (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Funding: European Research Council (283634, 313440, 725025)
Citations: not cited yet (Europe PMC); 106 references in the paper

Abstract

Individual differences in the volumes of brain structures are often linked to various conditions, including Alzheimer’s disease, schizophrenia, and overall brain health. However, it remains unclear to what extent these differences reflect individual levels present from young adulthood or diverging aging trajectories from later ages. In this study, we analyze the aging dynamics of the volumes of six brain structures based on magnetic resonance imaging (MRI) scans from a large cross-cohort longitudinal sample of cognitively healthy adults (n = 8,311 with 18,520 MRIs, ages from 18 to 97 years). From general assumptions about structural brain dynamics and measurement noise, a stochastic dynamical model was fitted to the data to estimate both the variability and persistence of structural changes across adulthood. Using this model, we calculated how much of the variance of volumetric differences between individuals can be attributed to stable levels from young adulthood versus systematic changes at older ages, as well as the theoretical sensitivity of longitudinal studies to detect individual differences in change. The findings were as follows: (1) Before age 60 years, inter-individual differences in neuroanatomical volumes almost exclusively reflect stable differences between individuals, while the influence from systematic differences in rate-of-change increases thereafter: up to 50% of the variation being due to differences in change at 80 years. In contrast, ventricular volume reflects differences in change from early adulthood. (2) Current brain-age models are unlikely to be sensitive to detect differences in aging trajectories. (3) Imaging studies have low reliability in detecting inter-individual brain changes before age 60 years. After 60 years, the study reliability increases sharply with longer intervals between scans and more modestly with additional intermediate observations. In conclusion, our results reinforce the view that it is critical to distinguish stable early adulthood levels from systematic differences in change when studying adult brain aging.

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

Repository

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

EdvardGrodem/brain-trajectories

License: none: the authors keep all their rights
State: the link answers, verified on 28 September 2026
Evidence: files inventoried
Commit: 49d09d46b844859a100428ba04f9ef801b3bd210, 11 August 2025
Languages: Jupyter (5), Python (4)
Size: 11 files, 9 scripts
Software Heritage: not archived
Found in: “Data and Code Availability”
Holds: README, environment (setup.py), 5 notebooks
Not found: license file, CITATION.cff, tests, continuous integration, documentation
Tools: Matplotlib (8 files), NumPy (8 files), Pyro (6 files), PyTorch (6 files), seaborn (3 files), pandas (2 files), SciPy (2 files)
Availability: 1 check, the latest on 28 September 2026: the link answers
  • 28 September 2026: the link answers
10 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;
  • 9 scripts, each with its path and the digest of its content;
  • 2 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 and Code Availability

The raw data were gathered from many different datasets. Different agreements are required for each dataset. Most datasets are openly available with prespecified data usage agreements. For some datasets, such as UKB, fees may apply. Requests for LCBC, UB, and COGNORM should be submitted to the corresponding principal investigator. The code to fit the model and generate the figures is available at https://github.com/EdvardGrodem/brain-trajectories.

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

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 28 September 2026: the first record

Recorded: type, language, journal, volume, pages, dates, 20 authors, 7 keywords, 1 funder, 103 references.

Cite

This paper

Grødem, E. O., Vidal-Pineiro, D., Sørensen, Ø., Bartrés-Faz, D., Brandmaier, A. M., Cattaneo, G., Garrido, P. F., Henson, R. N., Kühn, S., Lindenberger, U., MacIntosh, B. J., Nyberg, L., Pascual-Leone, A., Smith, S. M., Solé-Padullés, C., Solana-Sánchez, J., Watne, L. O., Walhovd, K. B., Bjørnerud, A., & Fjell, A. M. (2026). Stable individual differences dominate adult brain volume variation until later life. Imaging neuroscience (Cambridge, Mass.), 4, IMAG.a.1242. https://doi.org/10.1162/imag.a.1242

BibTeX

@article{grdem2026stable,
author = {Grødem, Edvard OS and Vidal-Pineiro, Didac and Sørensen, Øystein and Bartrés-Faz, David and Brandmaier, Andreas M and Cattaneo, Gabriele and Garrido, Pablo F and Henson, Richard N and Kühn, Simone and Lindenberger, Ulman and MacIntosh, Bradley J and Nyberg, Lars and Pascual-Leone, Alvaro and Smith, Stephen M and Solé-Padullés, Cristina and Solana-Sánchez, Javier and Watne, Leiv Otto and Walhovd, Kristine B and Bjørnerud, Atle and Fjell, Anders M},
title = {{Stable individual differences dominate adult brain volume variation until later life}},
journal = {Imaging neuroscience (Cambridge, Mass.)},
year = {2026},
month = may,
volume = {4},
pages = {IMAG.a.1242},
publisher = {MIT Press},
issn = {2837-6056},
doi = {10.1162/imag.a.1242},
url = {https://doi.org/10.1162/imag.a.1242},
pmid = {42212223},
pmcid = {PMC13214574}
}

RIS

TY - JOUR
AU - Grødem, Edvard OS
AU - Vidal-Pineiro, Didac
AU - Sørensen, Øystein
AU - Bartrés-Faz, David
AU - Brandmaier, Andreas M
AU - Cattaneo, Gabriele
AU - Garrido, Pablo F
AU - Henson, Richard N
AU - Kühn, Simone
AU - Lindenberger, Ulman
AU - MacIntosh, Bradley J
AU - Nyberg, Lars
AU - Pascual-Leone, Alvaro
AU - Smith, Stephen M
AU - Solé-Padullés, Cristina
AU - Solana-Sánchez, Javier
AU - Watne, Leiv Otto
AU - Walhovd, Kristine B
AU - Bjørnerud, Atle
AU - Fjell, Anders M
TI - Stable individual differences dominate adult brain volume variation until later life
T2 - Imaging neuroscience (Cambridge, Mass.)
J2 - Imaging Neurosci (Camb)
PY - 2026
DA - 2026/05/26
VL - 4
SP - IMAG.a.1242
SN - 2837-6056
PB - MIT Press
DO - 10.1162/imag.a.1242
UR - https://doi.org/10.1162/imag.a.1242
LA - en
ER -

CSL-JSON

{
"id": "10.1162/imag.a.1242",
"type": "article-journal",
"title": "Stable individual differences dominate adult brain volume variation until later life",
"container-title": "Imaging neuroscience (Cambridge, Mass.)",
"author": [
{
"family": "Grødem",
"given": "Edvard OS"
},
{
"family": "Vidal-Pineiro",
"given": "Didac"
},
{
"family": "Sørensen",
"given": "Øystein"
},
{
"family": "Bartrés-Faz",
"given": "David"
},
{
"family": "Brandmaier",
"given": "Andreas M"
},
{
"family": "Cattaneo",
"given": "Gabriele"
},
{
"family": "Garrido",
"given": "Pablo F"
},
{
"family": "Henson",
"given": "Richard N"
},
{
"family": "Kühn",
"given": "Simone"
},
{
"family": "Lindenberger",
"given": "Ulman"
},
{
"family": "MacIntosh",
"given": "Bradley J"
},
{
"family": "Nyberg",
"given": "Lars"
},
{
"family": "Pascual-Leone",
"given": "Alvaro"
},
{
"family": "Smith",
"given": "Stephen M"
},
{
"family": "Solé-Padullés",
"given": "Cristina"
},
{
"family": "Solana-Sánchez",
"given": "Javier"
},
{
"family": "Watne",
"given": "Leiv Otto"
},
{
"family": "Walhovd",
"given": "Kristine B"
},
{
"family": "Bjørnerud",
"given": "Atle"
},
{
"family": "Fjell",
"given": "Anders M"
}
],
"container-title-short": "Imaging Neurosci (Camb)",
"volume": "4",
"page": "IMAG.a.1242",
"DOI": "10.1162/imag.a.1242",
"PMID": "42212223",
"PMCID": "PMC13214574",
"ISSN": "2837-6056",
"publisher": "MIT Press",
"URL": "https://doi.org/10.1162/imag.a.1242",
"language": "en",
"issued": {
"date-parts": [
[
2026,
5,
26
]
]
}
}

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/s41593-026-02363-4 [code]
Cortical thickness changes precede high levels of amyloid by at least 7 years.
Journal: Nature neuroscience
In common: structural MRI / diffusion, 2 references, 4 authors
[2] doi:10.1162/imag.a.1306 [code]
Beneficial effects of foreign language learning and aerobic exercise on dentate gyrus volume and mnemonic discrimination in healthy older adults: Results from a randomized controlled trial.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: 1 reference, 3 authors
[3] doi:10.1162/imag.a.1196 [code]
Failure to detect entorhinal grid-like signals in a passive navigation human fMRI study.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: 3 authors
[4] doi:10.1038/s41467-026-73668-y [code]
Convergent and divergent brain-cognition development in early adolescence.
Journal: Nature communications
In common: PyTorch, seaborn, pandas, 3 other tools, 5 references
[5] doi:10.1186/s40708-026-00316-y [code]
Generalizable and explainable deep learning for brain MRI: a multi-cohort evaluation of 3D architectures for age and sex prediction.
Journal: Brain informatics
In common: PyTorch, seaborn, pandas, 3 other tools, structural MRI / diffusion, 4 references
[6] doi:10.1038/s41467-026-71271-9 [code]
Exposome-wide patterns predict brain health in aging.
Journal: Nature communications
In common: seaborn, pandas, SciPy, 2 other tools, 5 references
[7] doi:10.1038/s41467-026-74957-2 [code]
Joint trajectories of brain atrophy, white matter hyperintensities and cognition quantify brain maintenance.
Journal: Nature communications
In common: structural MRI / diffusion, 6 references
[8] doi:10.3389/frai.2026.1771088 [code]
Few-shot deployment of pretrained MRI transformers in brain imaging tasks.
Journal: Frontiers in artificial intelligence
In common: PyTorch, seaborn, pandas, 3 other tools, structural MRI / diffusion, 3 references
[9] doi:10.64898/2026.08.13.26360304 [code]
Lifespan brain structural variation reveals shared organization across mental health conditions
Journal: medRxiv (preprint)
In common: seaborn, pandas, SciPy, 2 other tools, author Bradley J. MacIntosh
[10] doi:10.1038/s43856-026-01722-3 [code]
Local and global patterns support medical imaging as a biomarker of ageing.
Journal: Communications medicine
In common: PyTorch, seaborn, pandas, 3 other tools, 3 references

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

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.