Skip to content

Instantly share code, notes, and snippets.

@jgeller112
jgeller112 / gist:f9f66940cb00d8b02b211378b6761d2f
Created September 5, 2024 14:32
Calculate ISC Pupil/Eye movements
calculate_isc_per_subject <- function(data_matrix, window_size = 10) {
# data_matrix: A matrix where each column is a participant and each row is a time point.
# window_size: The size of the sliding window for calculating correlations.
n_timepoints <- nrow(data_matrix)
n_participants <- ncol(data_matrix)
# Check that the number of participants is greater than 1
if (n_participants <= 1) {
stop("There must be more than one participant to calculate inter-subject correlation.")