OSCR

Factors Contributing to Short-Term Structural Variability in a Longitudinal MRI Dataset.

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 › Complementary Analysis I ↔ Patterns_longitudinal_manuscript/Step4_sPLS_final.R, lines 96–145 · score 0.91 · superior parietal lobule, superior occipital gyrus, angular gyrus, postcentral gyrus, medial segment, precuneus
  2. [2] § Results › Main Analysis ↔ Patterns_longitudinal_manuscript/Step4_sPLS_final.R, lines 96–145 · score 0.71 · middle temporal gyrus, middle occipital gyrus, inferior temporal, sPLS
  3. [3] § Method › Materials and Time‐Varying Predictors of Brain Changes ↔ Patterns_longitudinal_manuscript/Step4_sPLS_final.R, lines 47–94 · score 0.64 · room temperature, concentration, Estradiol, physical, Testosterone, PANAS
  4. [4] § Method › Materials and Time‐Varying Predictors of Brain Changes ↔ Patterns_longitudinal_manuscript/Step3_Imputation_2.0.R, lines 101–140 · score 0.56 · room temperature, Estradiol, Testosterone, PANAS, humidity, hours

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

R · 419 lines · 21 KB · CC-BY-4.0 · 3 matches

  1. #spls analysis
  2. # Bioconductor install
  3. if (!requireNamespace("BiocManager", quietly = TRUE)){
  4. install.packages("BiocManager")
  5. }
  6. # Install BiocParallel
  7. BiocManager::install("BiocParallel")
  8. BiocManager::install(update = TRUE)
  9. # over GitHub
  10. install.packages("devtools") # restart no
  11. devtools::install_github("mixOmicsTeam/mixOmics", force = TRUE)
  12. #BiocManager::install("mixOmics")
  13. #install.packages("mixOmics")
  14. library(mixOmics) # import the mixOmics library
  15. install.packages("ggplot2")
  16. library(ggplot2)
  17. install.packages("MASS")
  18. library(MASS)
  19. install.packages("lattice")
  20. library(lattice)
  21. # -------------------------------------------------------------------------------------------------------------------------------
  22. ### Import my data
  23. install.packages("jsonlite")
  24. library(jsonlite)
  25. #######
  26. X_impu <- read.csv("/Users/Masterthesis_Mayla/Step8_spls/Data_for_spls/x_impu.csv")
  27. X_not_impu <- read.csv("/Users/Masterthesis_Mayla/Step8_spls/Data_for_spls/X_not_impu.csv")
  28. Y_ROI <- read.csv("/Users/Masterthesis_Mayla/Step8_spls/Data_for_spls/Y_ROI_final_Cobra_neuromorpho.csv")
  29. rm(Y_ROI)
  30. rm(X_impu)
  31. rm(X_not_impu)
  32. # change X and Y df into matrix
  33. X_impu <- as.matrix(X_impu[, sapply(X_impu, is.numeric)]) #change the numeric columns in a matrix
  34. Y_ROI <- as.matrix(Y_ROI[, sapply(Y_ROI, is.numeric)])
  35. X_not_impu <- as.matrix(X_not_impu[, sapply(X_not_impu, is.numeric)])
  36. ## Check Dimensions of dataframes
  37. dim(X_impu) # check the dimensions of the X dataframe
  38. dim(Y_ROI) # check the dimensions of the Y dataframe
  39. dim(X_not_impu)
  40. original_names <- c(
  41. "anxietyDuringScan", "atmPressume", "bloodPressure_diastolic_mmHg",
  42. "bloodPressure_systolic_mmHg", "cacao_last24hs_percentage", "cacao_last2hs_percentage",
  43. "caffein_last24hs_cups", "caffein_last2hs_cups", "calories_burned",
  44. "chocolate_last24hs_gramms", "chocolate_last2hs_gramms", "cigarettes_last24hs",
  45. "daysFromFirstScan", "dayDreams_last24hs", "easeOfConcentration_last24hs", "estradiol",
  46. "generalHealth_last24hs", "generalStress_last24hs", "hoursActiveSocialInteraction_last24hs",
  47. "hoursFree_last24hs", "hoursOfWork_last24hs", "hoursPassiveSocialInteraction_last24hs",
  48. "hoursSpentOutdoors_last24hs", "hoursSport_last24hs", "hoursUsingScreens_last24hs",
  49. "liquid_last24hs_liters", "marihuanaCigarettes_last24hs", "maxTemp_C", "menstrualCycleDay",
  50. "minTemp_C", "MR_HeliumLevel", "MR_Room_Humidity", "MR_Room_Temperature", "number_steps",
  51. "number_stories", "PANAS_afraid", "PANAS_active", "PANAS_alert", "PANAS_ashamed",
  52. "PANAS_attentive", "PANAS_determined", "PANAS_distressed", "PANAS_enthusiastic",
  53. "PANAS_excited", "PANAS_guilty", "PANAS_hostile", "PANAS_inspired", "PANAS_interested",
  54. "PANAS_irritable", "PANAS_jittery", "PANAS_nervous", "PANAS_proud", "PANAS_scared",
  55. "PANAS_strong", "PANAS_upset", "physicalPainDuringScan", "precip_form", "precip_mm",
  56. "relHumidity", "rememberDreams_fromLastNight", "ruminationDuringScan", "scanDate",
  57. "scanTime", "sleepQuality_lastNight", "sleptDuringScan", "sunshine_hrs", "sweets_last24hs_Likert",
  58. "testosterone", "time_bed", "time_slept_min", "walk_distance", "weight_kg", "wind_km_h"
  59. )
  60. # New names
  61. new_names <- c(
  62. "Anxiety during Scan", "Athmospheric pressure", "Blood pressure diastolic",
  63. "Blood pressure systolic", "Cacao intake (%) last 24 hs", "Cacao intake (%) last 2 hs",
  64. "Caffeine intake last 24 hs", "Caffeine intake last 2 hs", "Calories burned",
  65. "Chocolate intake (g) last 24 hs", "Chocolate intake (g) last 2 hs", "Cigarettes last 24 hs",
  66. "Days from first Scan", "Daydreams last 24 hs", "Ease of concentration", "Estradiol",
  67. "Genereal Health last 24 hs", "General Stress last 24 hs", "Active Social Interact last 24 hs",
  68. "Hours free last 24 hs", "Hours of Work last 24 hs", "Passive Social Interact last 24 hs",
  69. "Hours outdoors last 24 hs", "Hours Sport last 24 hs", "Hours using Screen last 24 hs",
  70. "liquid litres last 24 hs", "Marihuana Cigarettes last 24 hs", "Maximum Temperature",
  71. "Day of menstrual cycle", "Minimum Temperature", "MR Helium Level", "MR Room Humidity",
  72. "MR Room Temperature", "Number of steps", "Number of stories climbed", "PANAS afraid",
  73. "PANAS active", "PANAS alert", "PANAS ashamed", "PANAS attentive", "PANAS determined",
  74. "PANAS distressed", "PANAS enthusiastic", "PANAS excited", "PANAS guilty", "PANAS hostile",
  75. "PANAS inspired", "PANAS interested", "PANAS irritable", "PANAS jittery", "PANAS nervous",
  76. "PANAS proud", "PANAS scared", "PANAS strong", "PANAS upset", "Physical Pain during Scan",
  77. "Precipitation Form", "Precipitation mm", "Relative Humidity", "Remember Dreams", "Rumination during Scan",
  78. "Scandate", "Scantime", "Sleep Quality last Night", "Slept during Scan", "Sunshine hs", "Sweets last 24 hs",
  79. "Testosterone", "Time Bed", "Time slept min", "Walk Distance", "Weight kg", "Wind km/h"
  80. )
  81. # Create a named vector for mapping
  82. name_mapping <- setNames(new_names, original_names)
  83. # Replace column names in the dataframe
  84. colnames(X_impu) <- ifelse(colnames(X_impu) %in% names(name_mapping),
  85. name_mapping[colnames(X_impu)],
  86. colnames(X_impu))
  87. colnames(X_not_impu) <- ifelse(colnames(X_not_impu) %in% names(name_mapping),
  88. name_mapping[colnames(X_not_impu)],
  89. colnames(X_not_impu))
  90. original_names_Y <- c(
  91. "lStriatum", "lGloPal", "lTha", "lAntCerebLI_II", "lAntCerebLIII", "lAntCerebLIV", "lAntCerebLV", "lSupPostCerebLVI", "lSupPostCerebCI",
  92. "lSupPostCerebCII", "lSupPostCerebLVIIB", "lInfPostCerebLVIIIA", "lInfPostCerebLVIIIB", "lInfPostCerebLIX", "lInfPostCerebLX", "lAmy", "lHCA1",
  93. "lSub", "lCA4", "lCA2_3", "lStratum", "rStriatum", "rGloPal", "rTha", "rAntCerebLI_II", "rAntCerebLIII", "rAntCerebLIV", "rAntCerebLV",
  94. "rSupPostCerebLVI", "rSupPostCerebCI", "rSupPostCerebCII", "rSupPostCerebLVIIB", "rInfPostCerebLVIIIA", "rInfPostCerebLVIIIB", "rInfPostCerebLIX",
  95. "rInfPostCerebLX", "rAmy", "rHCA1", "rSub", "rCA4", "rCA2_3", "rStratum", "Right.Accumbens.Area.1", "Left.Accumbens.Area.1", "Right.Amygdala.1",
  96. "Left.Amygdala.1", "Right.Caudate.1", "Left.Caudate.1", "Right.Cerebellum.Exterior.1", "Left.Cerebellum.Exterior.1", "Right.Hippocampus.1",
  97. "Left.Hippocampus.1", "Right.Pallidum.1", "Left.Pallidum.1", "Right.Putamen.1", "Left.Putamen.1", "Right.Thalamus.Proper.1", "Left.Thalamus.Proper.1",
  98. "Right.Ventral.DC.1", "Left.Ventral.DC.1", "Optic.Chiasm.1", "Cerebellar.Vermal.Lobules.I.V.1", "Cerebellar.Vermal.Lobules.VI.VII.1",
  99. "Cerebellar.Vermal.Lobules.VIII.X.1", "Left.Basal.Forebrain.1", "Right.Basal.Forebrain.1", "Right.ACgG.anterior.cingulate.gyrus.1",
  100. "Left.ACgG.anterior.cingulate.gyrus.1", "Right.AIns.anterior.insula.1", "Left.AIns.anterior.insula.1", "Right.AOrG.anterior.orbital.gyrus.1",
  101. "Left.AOrG.anterior.orbital.gyrus.1", "Right.AnG.angular.gyrus.1", "Left.AnG.angular.gyrus.1", "Right.Calc.calcarine.cortex.1",
  102. "Left.Calc.calcarine.cortex.1", "Right.CO.central.operculum.1", "Left.CO.central.operculum.1", "Right.Cun.cuneus.1", "Left.Cun.cuneus.1",
  103. "Right.Ent.entorhinal.area.1", "Left.Ent.entorhinal.area.1", "Right.FO.frontal.operculum.1", "Left.FO.frontal.operculum.1", "Right.FRP.frontal.pole.1",
  104. "Left.FRP.frontal.pole.1", "Right.FuG.fusiform.gyrus.1", "Left.FuG.fusiform.gyrus.1", "Right.GRe.gyrus.rectus.1", "Left.GRe.gyrus.rectus.1",
  105. "Right.IOG.inferior.occipital.gyrus.1", "Left.IOG.inferior.occipital.gyrus.1", "Right.ITG.inferior.temporal.gyrus.1",
  106. "Left.ITG.inferior.temporal.gyrus.1", "Right.LiG.lingual.gyrus.1", "Left.LiG.lingual.gyrus.1", "Right.LOrG.lateral.orbital.gyrus.1",
  107. "Left.LOrG.lateral.orbital.gyrus.1", "Right.MCgG.middle.cingulate.gyrus.1", "Left.MCgG.middle.cingulate.gyrus.1", "Right.MFC.medial.frontal.cortex.1",
  108. "Left.MFC.medial.frontal.cortex.1", "Right.MFG.middle.frontal.gyrus.1", "Left.MFG.middle.frontal.gyrus.1", "Right.MOG.middle.occipital.gyrus.1",
  109. "Left.MOG.middle.occipital.gyrus.1", "Right.MOrG.medial.orbital.gyrus.1", "Left.MOrG.medial.orbital.gyrus.1",
  110. "Right.MPoG.postcentral.gyrus.medial.segment.1", "Left.MPoG.postcentral.gyrus.medial.segment.1", "Right.MPrG.precentral.gyrus.medial.segment.1",
  111. "Left.MPrG.precentral.gyrus.medial.segment.1", "Right.MSFG.superior.frontal.gyrus.medial.segment.1", "Left.MSFG.superior.frontal.gyrus.medial.segment.1",
  112. "Right.MTG.middle.temporal.gyrus.1", "Left.MTG.middle.temporal.gyrus.1", "Right.OCP.occipital.pole.1", "Left.OCP.occipital.pole.1",
  113. "Right.OFuG.occipital.fusiform.gyrus.1", "Left.OFuG.occipital.fusiform.gyrus.1", "Right.OpIFG.opercular.part.of.the.inferior.frontal.gyrus.1",
  114. "Left.OpIFG.opercular.part.of.the.inferior.frontal.gyrus.1", "Right.OrIFG.orbital.part.of.the.inferior.frontal.gyrus.1",
  115. "Left.OrIFG.orbital.part.of.the.inferior.frontal.gyrus.1", "Right.PCgG.posterior.cingulate.gyrus.1", "Left.PCgG.posterior.cingulate.gyrus.1",
  116. "Right.PCu.precuneus.1", "Left.PCu.precuneus.1", "Right.PHG.parahippocampal.gyrus.1", "Left.PHG.parahippocampal.gyrus.1",
  117. "Right.PIns.posterior.insula.1", "Left.PIns.posterior.insula.1", "Right.PO.parietal.operculum.1", "Left.PO.parietal.operculum.1",
  118. "Right.PoG.postcentral.gyrus.1", "Left.PoG.postcentral.gyrus.1", "Right.POrG.posterior.orbital.gyrus.1", "Left.POrG.posterior.orbital.gyrus.1",
  119. "Right.PP.planum.polare.1", "Left.PP.planum.polare.1", "Right.PrG.precentral.gyrus.1", "Left.PrG.precentral.gyrus.1", "Right.PT.planum.temporale.1",
  120. "Left.PT.planum.temporale.1", "Right.SCA.subcallosal.area.1", "Left.SCA.subcallosal.area.1", "Right.SFG.superior.frontal.gyrus.1",
  121. "Left.SFG.superior.frontal.gyrus.1", "Right.SMC.supplementary.motor.cortex.1", "Left.SMC.supplementary.motor.cortex.1",
  122. "Right.SMG.supramarginal.gyrus.1", "Left.SMG.supramarginal.gyrus.1", "Right.SOG.superior.occipital.gyrus.1",
  123. "Left.SOG.superior.occipital.gyrus.1", "Right.SPL.superior.parietal.lobule.1", "Left.SPL.superior.parietal.lobule.1",
  124. "Right.STG.superior.temporal.gyrus.1", "Left.STG.superior.temporal.gyrus.1", "Right.TMP.temporal.pole.1", "Left.TMP.temporal.pole.1",
  125. "Right.TrIFG.triangular.part.of.the.inferior.frontal.gyrus.1", "Left.TrIFG.triangular.part.of.the.inferior.frontal.gyrus.1",
  126. "Right.TTG.transverse.temporal.gyrus.1", "Left.TTG.transverse.temporal.gyrus.1"
  127. )
  128. # Changes for the loading plots
  129. new_names_Y_network_plot <- c(
  130. "L.Striatum", "L.GloPal", "L.Tha", "L.AntCereLI_II", "L.AntCereLIII", "L.AntCereLIV", "L.AntCereLV", "L.SupPoCereLVI",
  131. "L.SupPoCereCI", "L.SupPoCereCII", "L.SupPoCereLVIIB", "L.InfPoCereLVIIIA", "L.InfPoCereLVIIIB", "L.InfPoCereLIX",
  132. "L.InfPoCereLX", "L.Amy", "L.HCA1", "L.Sub", "L.CA4", "L.CA2_3", "L.Stratum", "R.Striatum", "R.GloPal", "R.Tha", "R.AntCereLI_II",
  133. "R.AntCereLIII", "R.AntCerebLIV", "R.AntCereLV", "R.SupPoCereLVI", "R.SupPoCereCI", "R.SupPoCereCII", "R.SupPoCereLVIIB",
  134. "R.InfPoCereLVIIIA", "R.InfPoCereLVIIIB", "R.InfPoCereLIX", "R.InfPoCereLX", "R.Amy", "R.HCA1", "R.Sub", "R.CA4", "R.CA2_3",
  135. "R.Stratum", "R.Accumb.Area", "L.Accumb.Area", "R.Amygdala", "L.Amygdala", "R.Caudate", "L.Caudate",
  136. "R.Cereb.Ext", "L.Cereb.Ext", "R.Hippoc", "L.Hippoc", "R.Pallidum", "L.Pallidum",
  137. "R.Putamen", "L.Putamen", "R.Thal.Prop", "L.Thal.Prop", "R.Ventral.DC", "L.Ventral.DC", "Optic.Chiasm",
  138. "Cereb.Vermal.Lob.I.V", "Cereb.Vermal.Lob.VI.VII", "Cereb.Vermal.Lob.VIII.X", "L.Basal.Forebrain",
  139. "R.Basal.Forebrain", "R.ACgG", "L.ACgG", "R.AIns",
  140. "L.AIns", "R.AOrG", "L.AOrG", "R.AnG",
  141. "L.AnG", "R.Calc", "L.Calc", "R.CO", "L.CO",
  142. "R.Cun", "L.Cun", "R.Ent", "L.Ent", "R.FO",
  143. "L.FO", "R.FRP", "L.FRP", "R.FuG", "L.FuG",
  144. "R.GRe", "L.GRe", "R.IOG", "L.IOG",
  145. "R.ITG", "L.ITG", "R.LiG", "L.LiG",
  146. "R.LOrG", "L.LOrG", "R.MCgG", "L.MCgG",
  147. "R.MFC", "L.MFC", "R.MFG", "L.MFG",
  148. "R.MOG", "L.MOG", "R.MOrG", "L.MOrG",
  149. "R.MPoG", "L.MPoG", "R.MPrG",
  150. "L.MPrG", "R.MSFG",
  151. "L.MSFG", "R.MTG", "L.MTG",
  152. "R.OCP", "L.OCP", "R.OFuG", "L.OFuG",
  153. "R.OpIFG", "L.OpIFG",
  154. "R.OrIFG", "L.OrIFG",
  155. "R.PCgG", "L.PCgG", "R.PCu", "L.PCu",
  156. "R.PHG", "L.PHG", "R.PIns", "L.PIns",
  157. "R.PO", "L.PO", "R.PoG", "L.PoG",
  158. "R.POrG", "L.POrG", "R.PP", "L.PP",
  159. "R.PrG", "L.PrG", "R.PT", "L.PT", "R.SCA",
  160. "L.SCA", "R.SFG", "L.SFG", "R.SMC",
  161. "L.SMC", "R.SMG", "L.SMG", "R.SOG",
  162. "L.SOG", "R.SPL", "L.SPL",
  163. "R.STG", "L.STG", "R.TMP", "L.TMP",
  164. "R.TrIFG", "L.TrIFG",
  165. "R.TTG", "L.TTG")
  166. name_mapping <- setNames(new_names_Y_network_plot, original_names_Y)
  167. colnames(Y_ROI) <- ifelse(colnames(Y_ROI) %in% names(name_mapping),
  168. name_mapping[colnames(Y_ROI)],
  169. colnames(Y_ROI))
  170. # -------------------------------------------------------------------------------------------
  171. # -------------------------------------------------------------------------------------------
  172. ### Multilevel ### (taking longitudinal data of all subjects into account)
  173. # -------------------------------------------------------------------------------------------
  174. # -------------------------------------------------------------------------------------------
  175. # Design matrix
  176. table(X_impu[, 1])
  177. # Number of measures:
  178. # Person 1: 50, Person 2: 12, Person 3: 50,
  179. # Person 4: 11, Person 5: 45, Person 6: 47,
  180. # Person 7: 40, Person 8: 49
  181. repeat.indiv <- c(rep(1, 50), rep(2, 12), rep(3, 50), rep(4, 11),
  182. rep(5, 45), rep(6, 47), rep(7, 40), rep(8, 49))
  183. # create Design matrix
  184. # basically contains the ‘Person’ column from my data
  185. # specifies for the spls command how the measurement repetition is handled
  186. design <- data.frame(sample = repeat.indiv)
  187. # --------------------------------------------------------------------------------------------------
  188. ### SPLS Multilevel Basic Model
  189. # --------------------------------------------------------------------------------------------------
  190. ### Basic Multilevel Model with imputed data: X_impu
  191. spls.4comp.multi.basic <- spls(X_impu, Y_ROI, ncomp = 4, mode = 'regression', multilevel = design)
  192. # --------------------------------------------------------------------------------------------------
  193. ### TUNING
  194. # --------------------------------------------------------------------------------------------------
  195. # set range of test values for number of variables to use from X dataframe
  196. list.keepX <- c(3:12)
  197. # set range of test values for number of variables to use from Y dataframe
  198. list.keepY <- c(5:164)
  199. # ---------------------------------------------------------
  200. ### Tune.splslevel ###
  201. ### Wrapper function to be able to understand the output
  202. tune.splslevel.wrapper <- function(X,
  203. Y,
  204. design,
  205. ncomp,
  206. test.keepX,
  207. test.keepY) {
  208. ncomps <- 1:ncomp # set range of ncomp values to use
  209. final.obj <- list() # initialise returned object
  210. # default values are -1 for debugging
  211. atX <- rep(-1, length(ncomps)-1) # already.tested.X
  212. atY <- rep(-1, length(ncomps)-1) # already.tested.Y
  213. for (ncomp in ncomps) {
  214. # previously calculated optimal keepX/Y value
  215. tmp.atX <- c(atX[1:ncomp-1])
  216. tmp.atY <- c(atY[1:ncomp-1])
  217. # need to be NULL for first iteration
  218. if (ncomp==1) { tmp.atX <- NULL; tmp.atY <- NULL }
  219. cat("=== NCOMP:", ncomp, "===\n")
  220. model <- suppressMessages(tune.splslevel(X, Y, multilevel=design,
  221. mode="regression",
  222. ncomp=ncomp,
  223. test.keepX = test.keepX,
  224. test.keepY = test.keepY,
  225. already.tested.X = tmp.atX,
  226. already.tested.Y = tmp.atY))
  227. # extract position in cor.value which corresponds to max
  228. opt.pos <- which(model$cor.value==max(model$cor.value), arr.ind=T)
  229. # set these for future iterations
  230. atX[ncomp] <- test.keepX[opt.pos[1]]
  231. atY[ncomp] <- test.keepY[opt.pos[2]]
  232. # add to returned object
  233. final.obj[["X"]][ncomp] <- test.keepX[opt.pos[1]]
  234. final.obj[["Y"]][ncomp] <- test.keepY[opt.pos[2]]
  235. final.obj[["cor"]][ncomp] <- max(model$cor.value)
  236. }
  237. # determine ncomp with optimal correlation
  238. cor.max <- which(final.obj[["cor"]]==max(final.obj[["cor"]]))
  239. final.obj[["opt.ncomp"]] <- cor.max
  240. return(final.obj)
  241. }
  242. # set range of test values for number of variables to use from X dataframe
  243. #list.keepX <- c(3:10)
  244. # set range of test values for number of variables to use from Y dataframe
  245. #list.keepY <- c(5:15)
  246. tune.spls.4comp.multi.wrapper <- tune.splslevel.wrapper(X = X_impu, Y = Y_ROI,
  247. design,
  248. ncomp = 4,
  249. test.keepX = list.keepX,
  250. test.keepY = list.keepY)
  251. #plot(tune.spls.multi.wrapper)
  252. # extract optimal number of variables for X and Y dataframe and number of components
  253. optimal.keepX <- tune.spls.4comp.multi.wrapper$X
  254. optimal.keepY <- tune.spls.4comp.multi.wrapper$Y
  255. optimal.ncomp <- length(optimal.keepX)
  256. # -----------------------------------------
  257. ### Final model
  258. # final: not imputed canonical
  259. spls.final.4comp.multilevel.canonical <- spls(X = X_not_impu, Y = Y_ROI, # generate a tuned sPLS model
  260. multilevel = design,
  261. ncomp = 4,
  262. keepX = optimal.keepX,
  263. keepY = optimal.keepY,
  264. mode = 'canonical')
  265. ### -----------------------------------------------------------------------------
  266. ### Plots ###
  267. ### mulitlevel spls tuned ###
  268. ### -----------------------------------------------------------------------------
  269. # extract loadings of Y variables to do a plot of the brain with regions visible that correlate positively with component 1 / negatively with component 1
  270. # same for component 2 (in one plot?)
  271. Loadings_Y_canonical <- spls.final.4comp.multilevel.canonical$loadings$Y
  272. write.csv(Loadings_Y, file = "/Users/Masterthesis_Mayla/Step8_spls/Results/Loadings_Y_final_4comp_cobneuro_canonical.csv", row.names = TRUE)
  273. Loadings_Y_regression <- spls.final.multilevel.regression$loadings$Y
  274. write.csv(Loadings_Y, file = "/Users/Masterthesis_Mayla/Step8_spls/Results/Loadings_Y_final_4comp_cobneuro_regression.csv", row.names = TRUE)
  275. dev.off()
  276. par(oma=c(0.5,7,0.5,1)) # bottom, left, top, right
  277. # Loadings
  278. ?plotLoadings
  279. plotLoadings(spls.final.4comp.multilevel.canonical, comp = 1, contrib = max, method = "median", subtitle = c('Questionnairy Loadings Comp 1', "Brain Loadings Comp 1"), size.name = 1.4)
  280. plotLoadings(spls.final.4comp.multilevel.canonical, comp = 2, contrib = max, method = "median", subtitle = c('Questionnairy Loadings Comp 2', "Brain Loadings Comp 2"), size.name = 1.4)
  281. plotLoadings(spls.final.4comp.multilevel.canonical, comp = 3, contrib = max, method = "median", subtitle = c('Questionnairy Loadings Comp 3', "Brain Loadings Comp 3"), size.name = 1.4)
  282. plotLoadings(spls.final.4comp.multilevel.canonical, comp = 4, contrib = max, method = "median", subtitle = c('Questionnairy Loadings Comp 4', "Brain Loadings Comp 4"), size.name = 1.4)
  283. # Correlation Cirle
  284. dev.off()
  285. ?plotVar
  286. #for component 1 and 2
  287. plotVar(spls.final.4comp.multilevel.canonical,
  288. cex = c(4,4), # font size of variable names
  289. # overlap = FALSE # creates two separate plots for X and Y; default is TRUE
  290. )
  291. # or component 1 and 3
  292. plotVar(spls.final.4comp.multilevel.canonical,
  293. comp = c(1,3),
  294. cex = c(4,4), # font size of variable names
  295. # overlap = FALSE # creates two separate plots for X and Y; default is TRUE
  296. )
  297. # or component 1 and 4
  298. plotVar(spls.final.4comp.multilevel.canonical,
  299. comp = c(1,4),
  300. cex = c(4,4), # font size of variable names
  301. # overlap = FALSE # creates two separate plots for X and Y; default is TRUE
  302. )
  303. # or component 2 and 3
  304. plotVar(spls.final.4comp.multilevel.canonical,
  305. comp = c(2,3),
  306. cex = c(4,4), # font size of variable names
  307. # overlap = FALSE # creates two separate plots for X and Y; default is TRUE
  308. )
  309. # or component 2 and 4
  310. plotVar(spls.final.4comp.multilevel.canonical,
  311. comp = c(2,4),
  312. cex = c(4,4), # font size of variable names
  313. # overlap = FALSE # creates two separate plots for X and Y; default is TRUE
  314. )
  315. # or component 4 and 3
  316. plotVar(spls.final.4comp.multilevel.canonical,
  317. comp = c(3,4),
  318. cex = c(4,4), # font size of variable names
  319. # overlap = FALSE # creates two separate plots for X and Y; default is TRUE
  320. )
  321. # Inividuals
  322. #plotIndiv(spls.final.multilevel.canonical, comp = c(1,2))
  323. #plotIndiv(spls.final.multilevel.canonical, rep.space = "XY",
  324. # group = design$sample,
  325. # col.per.group = color.mixo(1:8),
  326. # legend = TRUE, legend.title = 'Subject')
  327. # Variance explained
  328. spls.final.4comp.multilevel.canonical$prop_expl_var
  329. # Network Plot
  330. color.edge <- color.GreenRed(50) # set the colours of the connecting lines
  331. X11()
  332. par(oma=c(0.5,0.5,0.5,0.5)) # bottom, left, top, right
  333. dev.off()
  334. # To open a new window for Rstudio
  335. network(spls.final.4comp.multilevel.canonical, comp = 1:4,
  336. cutoff = 0.4, # only show connections with a correlation above 0.7
  337. shape.node = c("circle", "rectangle"),
  338. color.node = c("steelblue", "salmon2"),
  339. color.edge = color.edge,
  340. size.node = 1,
  341. cex.node.name = 0.7)
  342. ?cim
  343. X11()
  344. dev.off()
  345. par(oma=c(3,2,2,6))
  346. cim(spls.final.4comp.multilevel.canonical)

Step4_sPLS_final.R, under CC-BY-4.0 · at the source

Overview

Authors: Polona Kalc1, Mayla ter Veer1,2, Robert Dahnke1,3,4, Gabriel Ziegler5,6, Simone Kühn7, Christian Gaser1,3,4
  1. Structural Brain Mapping Group, Department of Neurology Jena University Hospital Jena Germany
  2. Department of Biological Psychology and Cognitive Neuroscience Institute for Psychology, Friedrich‐Schiller University of Jena Jena Germany
  3. Department of Psychiatry and Psychotherapy Jena University Hospital Jena Germany
  4. German Center for Mental Health (DZPG), Jena‐Halle‐Magdeburg Germany
  5. German Center for Neurodegenerative Diseases (DZNE) Magdeburg Germany
  6. Institute of Cognitive Neurology and Dementia Research (IKND), Otto‐von‐Guericke University Magdeburg Germany
  7. Center for Environmental Neuroscience, Max Planck Institute for Human Development Berlin Germany
Journal: Human brain mapping, volume 47, issue 4, article e70500
Dates: received 29 April 2025; accepted 3 March 2026; published online 12 March 2026; in print March 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1002/hbm.70500 · PMID 41817026 · PMCID PMC13093422 · OpenAlex W7135074313
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: structural MRI / diffusion (modality), human (organism), methods / tools (subfield)
Methods: Smoothing, state filtering, decompositions, Machine learning, Statistics
Keywords: longitudinal, partial least squares, structural MRI, within‐subject variance
MeSH: Brain*, Gray Matter*, Magnetic Resonance Imaging*, Female, Humans, Image Processing, Computer-Assisted, Longitudinal Studies, Male (* major topic)
Topic: Functional Brain Connectivity Studies (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Funding: Carl‐Zeiss‐Stiftung (IMPULS P2019‐01‐006); Marie Skłodowska-Curie Innovative Training Network (SmartAge 859890 H2020‐MSCA‐ITN2019); European Union (ERC‐2022‐CoG‐BrainScape‐101086188); Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) (Pattern‐Cog ERAPERMED2021‐127)
Citations: cited by 1 paper (Europe PMC); 60 references in the paper

Abstract

When planning longitudinal magnetic resonance imaging (MRI) studies, it is advisable to consider various (confounding) factors that could influence brain structural changes over time. The goal of this study was to identify factors that contribute to intraindividual variability of brain structure within a short period of time. We employed multilevel sparse partial least squares regression to investigate the changes in regional gray matter volume in the longitudinal Day2day MRI dataset. The findings suggest that the changes in regional GM volume estimations were primarily driven by image quality, while the outdoor temperature and time since baseline appeared as the main predictors of volumetric changes in insular and diencephalic brain regions. We additionally investigated factors associated with variability in image quality. The findings underscore the importance of maintaining adequate participant arousal during scanning.

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 4 matches between paragraphs and lines of code.

figshare 28839635

License: CC-BY-4.0
State: the link answers, verified on 30 September 2026
Evidence: files inventoried
Size: 1 file
Software Heritage: not checked
Found in: “Data Availability Statement”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: tidyverse (3 files), ggplot2 (2 files), CAT12 (1 file), cowplot (1 file), GIfTI library for MATLAB (1 file), patchwork (1 file)
Availability: 1 check, the latest on 30 September 2026: the link answers (HTTP 200)
  • 30 September 2026: the link answers (HTTP 200)
6 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;
  • 6 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 Statement

The Day2day data is available freely on request from Prof. Dr. Simone Kühn. The code to replicate the findings is available at Figshare (DOI: 10.6084/m9.figshare.28839635 (https://doi.org/10.6084/m9.figshare.28839635)).

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, 30 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 6 authors, 4 keywords, 8 MeSH terms, 4 funders, 59 references.

Cite

This paper

Kalc, P., ter Veer, M., Dahnke, R., Ziegler, G., Kühn, S., & Gaser, C. (2026). Factors Contributing to Short-Term Structural Variability in a Longitudinal MRI Dataset. Human brain mapping, 47(4), e70500. https://doi.org/10.1002/hbm.70500

BibTeX

@article{kalc2026factors,
author = {Kalc, Polona and ter Veer, Mayla and Dahnke, Robert and Ziegler, Gabriel and Kühn, Simone and Gaser, Christian},
title = {{Factors Contributing to Short-Term Structural Variability in a Longitudinal MRI Dataset}},
journal = {Human brain mapping},
year = {2026},
month = mar,
volume = {47},
number = {4},
pages = {e70500},
publisher = {Wiley},
issn = {1065-9471},
doi = {10.1002/hbm.70500},
url = {https://doi.org/10.1002/hbm.70500},
pmid = {41817026},
pmcid = {PMC13093422}
}

RIS

TY - JOUR
AU - Kalc, Polona
AU - ter Veer, Mayla
AU - Dahnke, Robert
AU - Ziegler, Gabriel
AU - Kühn, Simone
AU - Gaser, Christian
TI - Factors Contributing to Short-Term Structural Variability in a Longitudinal MRI Dataset
T2 - Human brain mapping
J2 - Hum Brain Mapp
PY - 2026
DA - 2026/03/01
VL - 47
IS - 4
SP - e70500
SN - 1065-9471
PB - Wiley
DO - 10.1002/hbm.70500
UR - https://doi.org/10.1002/hbm.70500
LA - en
ER -

CSL-JSON

{
"id": "10.1002/hbm.70500",
"type": "article-journal",
"title": "Factors Contributing to Short-Term Structural Variability in a Longitudinal MRI Dataset",
"container-title": "Human brain mapping",
"author": [
{
"family": "Kalc",
"given": "Polona"
},
{
"family": "ter Veer",
"given": "Mayla"
},
{
"family": "Dahnke",
"given": "Robert"
},
{
"family": "Ziegler",
"given": "Gabriel"
},
{
"family": "Kühn",
"given": "Simone"
},
{
"family": "Gaser",
"given": "Christian"
}
],
"container-title-short": "Hum Brain Mapp",
"volume": "47",
"issue": "4",
"page": "e70500",
"DOI": "10.1002/hbm.70500",
"PMID": "41817026",
"PMCID": "PMC13093422",
"ISSN": "1065-9471",
"publisher": "Wiley",
"URL": "https://doi.org/10.1002/hbm.70500",
"language": "en",
"issued": {
"date-parts": [
[
2026,
3,
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.7554/elife.109461 [code]
The effect of physical activity on brain structure and cognitive function in the population-based cohort of LIFE-Adult Study.
Journal: eLife
In common: tidyverse, structural MRI / diffusion, 4 references, author Polona Kalc
[2] doi:10.1038/s41467-026-71831-z [code]
Dysfunction of the episodic memory network in the Alzheimer's disease cascade.
Journal: Nature communications
In common: CAT12, GIfTI library for MATLAB, author Gabriel Ziegler
[3] doi:10.1038/s41593-026-02289-x [code]
Cerebellar aging is spatially heterogeneous and supports cognitive resilience in later life.
Journal: Nature neuroscience
In common: cowplot, patchwork, ggplot2, 1 other tool, structural MRI / diffusion, 2 references
[4] doi:10.1162/imag.a.1337 [code]
Data quality biases normative models derived from fetal brain MRI.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: cowplot, patchwork, ggplot2, 1 other tool, structural MRI / diffusion, 2 references
[5] doi:10.1038/s42003-026-10276-y [code]
The cellular correlates and adolescent reorganisation of cortical myelination networks in the common marmoset.
Journal: Communications biology
In common: CAT12, GIfTI library for MATLAB, patchwork, 1 other tool, structural MRI / diffusion
[6] doi:10.1002/hbm.70605 [code]
BrainEnrich: Revealing Biological Insights for Imaging-Derived Phenotypes Through Transcriptomic Enrichment.
Journal: Human brain mapping
In common: GIfTI library for MATLAB, cowplot, patchwork, 2 other tools
[7] doi:10.1038/s41597-026-07423-9 [code]
Unraveling the Complexity of Multilingual Comprehension: Neuroimaging and Linguistic Profiling in 700+ Adults.
Journal: Scientific data
In common: CAT12, cowplot, ggplot2, 1 other tool, methods / tools
[8] doi:10.1186/s13195-026-02054-z [code]
Pathways to resilience: relationships between cognitive reserve, psychological debt, and Alzheimer's disease biomarkers.
Journal: Alzheimer's research & therapy
In common: ggplot2, tidyverse, author Gabriel Ziegler
[9] doi:10.1038/s41467-026-74565-0 [code]
The functional neurobiology of dispositions towards negative emotions.
Journal: Nature communications
In common: GIfTI library for MATLAB, cowplot, ggplot2, 1 other tool, 1 reference
[10] doi:10.1002/hbm.70512 [code]
Precision Imaging for Intraindividual Investigation of the Reward Response.
Journal: Human brain mapping
In common: patchwork, ggplot2, tidyverse, methods / tools, 2 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.