Extracting FC matrices from HCP-preprocessed fMRI volumes

extractFC(
  wb_path,
  base_dir = "fmriresults01/",
  atlas,
  subjects,
  motion.thresh = 0.25,
  scrub = F,
  motion.reg = T,
  GSR = F,
  bandpass = c(0.01, 0.1),
  TR,
  task,
  extension = "_Atlas_MSMAll_hp0_clean.dtseries.nii",
  movement.extension = "Movement_Regressors.txt",
  output_dir = "output_dir",
  output.timeseries = F,
  overwrite = TRUE,
  dir.check = TRUE
)

Arguments

wb_path

The filepath to the workbench folder that you have previously downloaded and unzipped

base_dir

The filepath to directory containing the subject folders. Set to fmriresults01/" by default.

atlas

The version (number of parcels) of the Schaefer atlas; it has to be in multiples of 100, from 100 to 1000. The specified atlas template will be automatically downloaded from here if it does not exist in the current directory.

motion.thresh

the threshold used for scrubbing frames. Set to 0.25 by default.

scrub

If set to TRUE, remove frames with excessive head motion (FD > 0.25) and also remove segments in between two time-points if the segment has less than 5 frames. This is the ‘full scrubbing; method described in Power et. al (2014). This is not recommended for task-based fMRI volumes.

motion.reg

When set to TRUE, the 6 motion parameters (3 translation and 3 rotation), their derivatives and the squares of these parameters and their derivatives will be regressed out of the fMRI timeseries data. This motion regression procedure will only work if each subject folder contains a Movement_Regressors.txt file.

GSR

If set to TRUE, global signal, its derivative and the squares of the global signal and its derivatives will be regressed out from the fMRI timeseries data.

bandpass

Lower and upper limits of band pass filter. Signals below the lower limit and above the upper limit of the band pass filter will be eliminated. set to c(0.01,0.1) by default. Can turned off by setting to NA.

TR

Temporal resolution of the fMRI data. Only used if bandpass is not NA.

task

The name of the task (case-sensitive), without any numbers or acquisition direction labels

extension

The filename extension of the fMRI volumes. Set to _Atlas_MSMAll_hp0_clean.dtseries.nii by default

movement.extension

The filename extension of the head motion files. Set to Movement_Regressors.txt by default. Note the head motion file should be a text file containing either a single column of numbers (RMS measurements), or at least 6 columns (3 displacement + 3 rotational vectors). If there are more than 6 columns, only the first 6 columns will be used to compute framewise displacement.

output_dir

The output directory where the FC matrices and headmotion parameters will be saved. A default output_dir directory will be created if it does not exist.

output.timeseries

When set to TRUE, the parcellated timeseries data will be output instead of the FC matrix.

overwrite

If set to FALSE, subjects that already have their FC matrices in output_dir will be skipped. Set to TRUE by default.

dir.check

check the directory structure to ensure that each fMRI directory should only contain one fMRI file and at least one movement file. Set to TRUE by default.

Value

outputs M x M matrices in output_dir\FCmat, headmotion measurements in output_dir\headmotion and a summary headmotion measurements across all subjects output_dir\report.csv.

Details

This function extracts FC matrices from fMRI volumes preprocessed with the HCP pipeline with the option of carrying out global signal regression and scrubbing. The directory structure and file names must adhere to the NDA/HCP data structure and file naming conventions. Connectome Workbench has to be installed prior to running the function.

Examples

if (FALSE) {
extractFC(wb_path = "/home/junhong.yu/workbench/",task="REST",atlas=100,GSR=TRUE,scrub=TRUE,output_dir = "FCmat")
}