Code
knitr::opts_chunk$set(echo = TRUE, eval=TRUE)
Sys.setenv("FSLDIR" = "/Users/vandeks/fsl")
Sys.setenv("FSLOUTPUTTYPE" = "NIFTI_GZ")
templatefile='/Users/vandeks/fsl/data/standard/MNI152_T1_2mm_brain.nii.gz'We will perform a group-level analysis of the Despicable Me task.
sites = read.csv('/Users/vandeks/Library/CloudStorage/Box-Box/SMN/3first-level_analysis/homework/first-level_analysis/subject_assignment.csv')
sites = sites[ ! sites$student %in% c('Yisu', 'Shuai', 'Laura') & !is.na(sites$student),]
# list available feat directories
feats = sapply(strsplit(system("ls -d /Users/vandeks/Library/CloudStorage/Box-Box/SMN/data/RBC/HBN_BIDS/*/*/func/*bold.feat", intern = TRUE), "/"), function(x) x[[11]])
suppressWarnings(feats <- sapply(sites$subject, function(x)
system(
paste0("ls -d /Users/vandeks/Library/CloudStorage/Box-Box/SMN/data/RBC/HBN_BIDS/", x, "/*/func/*bold.feat 2>/dev/null"),
intern = TRUE) ))
feats = unlist(feats)
sites$feat = NA
sites$feat[ match(names(feats), sites$subject)] = feats
# A lot of motion artifact in their T1 image, so exclude them.
regExclude = c('NDARAU939WUK', 'NDARAM675UR8', 'NDARAN262WK6', 'NDARAN814UPR', 'NDARAK738BGC', 'NDARAH948UF0')
regExclude[1] "NDARAU939WUK" "NDARAM675UR8" "NDARAN262WK6" "NDARAN814UPR" "NDARAK738BGC"
[6] "NDARAH948UF0"
For the group-level analyses, we are going to look at how some demographic features are associated with BOLD response during the task.
data/RBC/HBN_BIDS/study-HBN_desc-participants.tsv in tab delimited format.The motion files are included in the feat directories in the file mc/prefiltered_func_data_mcf_rel_mean.rms.
Hint: You should have 51 participants total included in the data after making exclusions.
I already registered all of the images to the MNI template and put the output in the participant feat directories in the stats_reg folder.
Fit a FLAME model with the following design: \[ Y_i(v) = \beta_0(v) + \beta_1(v)*\text{age}_i + \beta_3(v)*\text{motion}_i, \]
where \(Y_i\) the the “cope” file for the difference between positive and negative emotional states. For age, use the centered age (subtract the mean age from each participant’s age).
For the group level contrasts, create one:
Hint: For the FLAME model, you can use the flameo function. You will need to pass the varcope images in addition to the cope images. The varcope images are also located in the feat directories.
pbj packagepbj package to fit the same model for the age and intercept effects. Hint: to test the intercept effect you need to fit a model formula without the intercept.easythresh function from FSL to perform cluster extent inference (CEI) for the intercept term of the FLAME output. Use a cluster-forming threshold of 2.32.easythresh function to perform cluster extent inference for the intercept term of the pbj output with a cluster-forming threshold of 2.32.This will take a little while longer to run because it is using bootstraps to compute \(p\)-values.
pbj package to perform spatial extent inference for the intercept term. Use a cluster-forming threshold of \(Z \ge 2.32\). Run it with 1000 bootstrap samples.easythresh results.For this section, report the results from the pbj analysis (you can choose which one) for the intercept term.
Describe the methods you used to analyze the results 1-2 paragraphs including a description of the first-level analysis and group-level analysis. It should be described well enough that someone could repeat your analyses starting from the first-level analysis.
Describe the results of your analyses in one paragraph, including a final figure showing the significant clusters from the spatial extent inference for the overall mean (Intercept) effect. Include a table with the cluster information. You should interpret the location of the result and why you think it is relevant to the task and the contrast.