Hello everyone,
I am currently analyzing rs-fMRI data that was preprocessed using an older version of fMRIPrep. My plan is to perform analyses of functional connectivity dynamics using sliding window method. I recently read an article (https://www.biorxiv.org/content/10.1101/2023.10.06.561221v2.full) that offers valuable advice on performing the same analyses with both actual signals and nuisance signals.
I am attempting to extract these nuisance signals using Nilearn, as shown below:
def empirical_BOLD_nuisance_signal(subject):
>
fmri_filename = f'/{subject}_task-rest_bold_space-T1w_preproc.nii.gz'
confounds_filename = f'{subject}_task-rest_bold_confounds.tsv'
atlas_filename = f'{subject}_aparc+aseg.mgz'
fmri_img = image.load_img(fmri_filename)
atlas_img = image.load_img(atlas_filename)
confounds = pd.read_csv(confounds_filename, sep='\t')
confounds = confounds[['X', 'Y', 'Z', 'RotX', 'RotY', 'RotZ']].values
masker = NiftiLabelsMasker(labels_img=atlas_img, detrend=True, standardize='zscore_sample', filter='butterworth', low_pass=0.1, high_pass=0.01, t_r=2.0, ensure_finite=False, extrapolate=False)
raw_parcellated_signals = masker.fit_transform(fmri_img)
regions_of_interest = list(range(1001, 1036)) + list(range(2001, 2036))
indices_of_interest = [i for i, label in enumerate(masker.labels_) if label in regions_of_interest]
raw_parcellated_signals = raw_parcellated_signals[:, indices_of_interest]
nuisance_model = LinearRegression()
nuisance_model.fit(confounds, raw_parcellated_signals)
nuisance_signals = nuisance_model.predict(confounds)
return nuisance_signals.T
My question is whether I am doing this correctly.
Additionally, I would greatly appreciate any feedback on whether I am applying the DK parcellation correctly here. Specifically, I am using a preprocessed fMRIPrep NIfTI file in T1w space (see file name) along with the aparc+aseg.mgz file (which I believe is the individual atlas in the same space, as per the standard output of FreeSurfer).
As you can see, I am a beginner in neuroimaging, so I would welcome any suggestions and help.
Thank you in advance,
Szymon