Packages
Dataframes
base<-read.csv('/Users/pucc03/OneDrive - The Ohio State University Wexner Medical Center/FournierLab/Datafiles/Constellation/Extracted_5_prek_2025_9_24.csv')
week<-read.csv('/Users/pucc03/OneDrive - The Ohio State University Wexner Medical Center/FournierLab/Datafiles/Constellation/Extracted_1w_5_prek_2025_9_24.csv')
month<-read.csv('/Users/pucc03/OneDrive - The Ohio State University Wexner Medical Center/FournierLab/Datafiles/Constellation/Extracted_1m_5_prek_2025_9_24.csv')
keta<-read.csv('/Users/pucc03/OneDrive - The Ohio State University Wexner Medical Center/FournierLab/Datafiles/Constellation/Extracted_24hr_5_prek_2025_9_24.csv')
Function to Compute ICC (loop); McGraw Wong ICC C,1
compute_iccs <- function(datalist, rois, timepoints, con_levels) {
tp_pairs <- combn(timepoints, 2, simplify = FALSE)
results <- list()
for (roi in rois) {
for (con in con_levels) {
for (pair in tp_pairs) {
tp1 <- pair[[1]]
tp2 <- pair[[2]]
# Subset each timepoint df for this condition and ROI
df1 <- datalist[[tp1]] %>%
select(sub, con2, all_of(roi)) %>%
filter(con2 == con)
df2 <- datalist[[tp2]] %>%
select(sub, con2, all_of(roi)) %>%
filter(con2 == con)
if (nrow(df1) < 1 || nrow(df2) < 1) next
# Merge subjects across timepoints
merged <- inner_join(df1, df2, by = c("sub","con2"), suffix = c(".t1",".t2"))
roi_cols <- merged %>% select(ends_with(".t1"), ends_with(".t2"))
if (nrow(roi_cols) < 2) next
#roi_cols_t <- t(roi_cols)
icc_out <- tryCatch(psych::ICC(roi_cols), error = function(e) NULL)
if (is.null(icc_out)) next
# Convert ICC results to tidy df
icc_df <- as.data.frame(icc_out$results) %>%
mutate(type = paste0(rownames(.), "_", seq_len(nrow(.)))) %>%
mutate(
ROI = roi,
Condition = con,
Timepoint1 = tp1,
Timepoint2 = tp2
)
results[[length(results) + 1]] <- icc_df
}
}
}
if (length(results) == 0) {
message("No ICC results produced (check data).")
return(tibble())
}
bind_rows(results) %>%
relocate(ROI, Condition, Timepoint1, Timepoint2, type)
}
Applying function to these data
datalist <- list(
base = clustdat_base,
week = clustdat_week,
month = clustdat_month,
keta = clustdat_keta
)
rois <- colnames(clustdat_base)[2:6] # your 5 ROIs
timepoints <- names(datalist) # "base","week","month","keta"
con_levels <- c("Self_Pos", "Self_Neg", "Other_Pos", "Other_Neg","SelfvOther","PosvNeg") # your 6 conditions
icc_summary <- compute_iccs(datalist, rois, timepoints, con_levels)
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
icc_summary_C1 <- subset(icc_summary,icc_summary$type=="Single_random_raters_2")
Summary Tables
icc_base_week <- icc_summary_C1 %>%
filter(
(Timepoint1 == "base" & Timepoint2 == "week") |
(Timepoint1 == "week" & Timepoint2 == "base")
)
Across all conditions/contrasts
icc_by_roi <- icc_base_week %>%
group_by(ROI) %>%
summarize(mean_ICC = mean(ICC, na.rm = TRUE),
sd_ICC = sd(ICC, na.rm = TRUE),
n = n())
icc_by_roi
Across all ROIs
icc_by_condition <- icc_base_week %>%
group_by(Condition) %>%
summarize(mean_ICC = mean(ICC, na.rm = TRUE),
sd_ICC = sd(ICC, na.rm = TRUE),
n = n())
icc_by_condition
Cross tab
icc_base_week %>%
select(ROI, Condition, ICC) %>%
pivot_wider(names_from = Condition, values_from = ICC)