Problem with parcellating data - UCLA Consortium, old version of fMRIPrep (0.4.4.)

Hello everyone,

I’m completely new to neuroimaging, and I’m working with a dataset from the UCLA (UCLA Consortium for Neuropsychiatric Phenomics LA5c Study). This dataset has been preprocessed using an older version of fMRIPrep (0.4.4). My goal is to parcellate resting-state signals using the Schaefer 100 parcellation. Therefore, I selected a preprocessed file in the MNI152NLin2009cAsym space, which has a resolution of 3x3x3 mm. Then, on TemplateFlow, I located the Schaefer 100 atlas, which is also in the MNI152NLin2009cAsym space but with a resolution of 2x2x2 mm. Subsequently, I attempted to parcellate it using Python and the Nilearn library:

fmri_filename = ‘{subject}_task-rest_bold_space-MNI152NLin2009cAsym_preproc.nii.gz’
atlas_filename = ‘tpl-MNI152NLin2009cAsym_res-02_atlas-Schaefer2018_desc-100Parcels7Networks_dseg.nii.gz’
fmri_img = image.load_img(fmri_filename)
atlas_img = image.load_img(atlas_filename)
masker = NiftiLabelsMasker(labels_img=atlas_img)
BOLD = masker.fit_transform(fmri_img)

Is this approach appropriate, or should I done something differently?

Thank you all for any help.

P.S. I previously posted a question here about my efforts, thinking my issues had been resolved. However, I’m now doubting whether my approach is correct

Hello @Szym.Ty

If I understand correctly, you are worried that your parcellation might be going wrong due to the resolution mismatch between fmri_img and atlas_img?

This should not be a problem because NiftiLabelsMasker, by default, resamples the labels_img (equivalent to atlas_img here) to imgs provided during .fit_transform (equivalent to fmri_img here).

You can control this behavior using the parameter resampling_target while defining NiftiLabelsMasker, see docs

You could also avoid automatic resampling for each subject by resampling your atlas_img only once:

from nilearn import image, datasets
from nilearn.maskers import NiftiLabelsMasker

# input file names, note that you do not need to load the images explicitly
fmri_filename = '{subject}_task-rest_bold_space-MNI152NLin2009cAsym_preproc.nii.gz'

# you can use the fetch_atlas_schaefer_2018 function to download the atlas
# indeed Schaefer 2018 atlas is not available in 3mm resolution
atlas_image = datasets.fetch_atlas_schaefer_2018(n_rois=100, resolution_mm=2)
atlas_filename = atlas_image.maps

# resample the atlas to match the resolution of the input image
# do this once before looping over subjects, if all subjects have the same resolution
resampled_atlas = image.resample_to_img(atlas_filename, fmri_filename)

# create the masker
masker = NiftiLabelsMasker(labels_img=resampled_atlas)
BOLD = masker.fit_transform(fmri_filename)

Thank you for your response. This is my first attempt, and I wanted to make sure that I wasn’t making any glaring errors. I plan to use this data for modeling purposes and aim to minimize any mistakes at this stage. From your answer, I gather that everything appears to be in order.