R/subtyper.R
select_high_quality_data.Rd
This function filters a data frame to include only subjects/scans that meet a set of predefined quality control (QC) criteria. It dynamically applies filters only for the QC columns that are present in the input data frame, and prints a message for any skipped QC checks.
select_high_quality_data(
data,
t1_grade_thresh = 0.8,
rsfmri_fd_thresh = 0.5,
dti_fd_thresh = 10,
rsfmri_minutes_thresh = 2,
study_name = NULL
)
A data frame containing some or all of the QC variables.
A numeric value for the minimum acceptable T1 image
quality grade. Filtering is skipped if T1Hier_resnetGrade
column is absent.
Default is 0.8.
A numeric value for the maximum acceptable mean
framewise displacement (FD) in rsfMRI data. Filtering is skipped if
rsfMRI_fcnxpro122_FD_mean
column is absent. Default is 0.5.
A numeric value for the maximum acceptable mean
framewise displacement (FD) in DTI data. Filtering is skipped if
DTI_dti_FD_mean
column is absent. Default is 10.
A numeric value for the minimum acceptable
duration of uncensored rsfMRI data in minutes. Filtering is skipped if
rsfMRI_fcnxpro122_minutes_censored_data
column is absent. Default is 2.
An optional character string. If provided, the data will
also be filtered to include only rows where the studyName
column
matches this value. Filtering is skipped if studyName
column is absent.
Default is NULL.
A logical vector of the same length as nrow(data)
. TRUE
indicates
a row that passes all available QC criteria, and FALSE
indicates a row
that fails at least one.
# Create a dummy data frame that is missing the DTI column
mock_data <- data.frame(
T1Hier_resnetGrade = c(0.9, 0.7, 0.95, 0.85),
rsfMRI_fcnxpro122_FD_mean = c(0.2, 0.6, 0.3, 0.4),
rsfMRI_fcnxpro122_minutes_censored_data = c(5, 4, 3, 6),
studyName = c("ADNI", "ADNI", "PPMI", "ADNI")
)
# The function will run, apply all possible filters, and print a message
# about the missing DTI column.
qc_passed <- select_high_quality_data(mock_data, study_name = "ADNI")
#> QC check for 'DTI_dti_FD_mean' skipped: column not found.
#> Message: QC check for 'DTI_dti_FD_mean' skipped: column not found.
print(qc_passed)
#> [1] TRUE FALSE FALSE TRUE
#> [1] TRUE FALSE FALSE TRUE