Including fmriprep a_comp_cor components causes raw and cleaned data to be anti-correlated

I am conducting task-based fMRI analyses using fmriprep and nipype.

After preprocessing the data, I am cleaning the data in NiPype as follows:

confound_df = pd.read_csv(confound_file, delimiter="\t")

    # Motion outliers (fd threshold from fmriprep defaults)
    motion_outliers = [col for col in confound_df.columns if "motion_outlier" in col]
    # PCA first 5 components
   # a_comp_cor = [
    #    "a_comp_cor_00",
    #    "a_comp_cor_01",
    #    "a_comp_cor_02",
    #    "a_comp_cor_03",
    #    "a_comp_cor_04",
    #    "a_comp_cor_05",
    a_comp_cor = []
    # In case of dummy scans
    non_steady_state = [
        col for col in confound_df.columns if col.startswith("non_steady_state")
    # Motion regressors
    motion = ["trans_x", "trans_y", "trans_z", "rot_x", "rot_y", "rot_z"]
    fd = ["framewise_displacement"]

    # Combine them all
    filter_col = np.concatenate(
        [motion_outliers, a_comp_cor, non_steady_state, motion, fd]
    confound_df = confound_df[filter_col]
    # Fill nans with 0's
    confound_df = confound_df.fillna(0)

    if verbose:
        print(f"Confounds: {confound_df.columns}")

    confounds_matrix = confound_df.values
    confounds_output_file = get_output_name(confound_file, output_path, "_trimmed.csv")


    # Load in functional data
    raw_func_img = nimg.load_img(func_file)

    # Make sure these are the same length.
    assert raw_func_img.shape[3] == confounds_matrix.shape[0]

    # Clean!
    clean_img = nimg.clean_img(

Strangely, (for at least two subjects) this is resulting in a NEGATIVE correlation between the raw timeseries and the cleaned timeseries (for a few random ROIs).

Also strangely, the first two components plotted against each other make a circle?

Does anyone have ideas what might be causing this? Are some of my other confounds oddly redundant? (All of the a_comp_cors are ‘combined’ according to the json).


Where are these random ROIs located? More specifically, do they tend to be gray vs white matter?

You wouldn’t want this relationship to form a line, for example, because that would suggest that the components are correlated with each other, which is bad for your design matrix.

I would imagine that FD is redundant in combination with head motion parameters.

Other notes:

  1. When you include acompcor components, you should include the cosine regressors made by fMRIPrep (explained more here). In this case, you would not need to run additional high pass filter.
  2. Your code suggests you wanted to include 5 components but you put in the first 6.