Regions and mask do not have the same affine while running xcp_d

Summary of what happened:

I ran the following command:

docker run --rm -it    
-v /arch/OpenCloseProject/derivatives:/fmriprep:ro    
-v /home/tm/workdir:/work:rw    
-v /home/tm/projects/OpenCloseProject/test_xcp:/out:rw    
-v /home/tm/freesurfer/license.txt:/freesurfer:ro    
pennlinc/xcp_d    /fmriprep /out    
participant --participant-label 002    
--nthreads 32 --nuisance-regressors '24P'    
--lower-bpf 0.008 --upper-bpf 0.09 -w /home/tm/workdir

which executes with several similar errors for all atlases provided in xcp-d by default (taken from logs):

Traceback:
	Traceback (most recent call last):
	  File "/usr/local/miniconda/lib/python3.10/site-packages/nipype/interfaces/base/core.py", line 397, in run
	    runtime = self._run_interface(runtime)
	  File "/usr/local/miniconda/lib/python3.10/site-packages/xcp_d/interfaces/connectivity.py", line 105, in _run_interface
	    n_voxels_in_masked_parcels = sum_masker_masked.fit_transform(atlas_img_bin)
	  File "/usr/local/miniconda/lib/python3.10/site-packages/sklearn/utils/_set_output.py", line 273, in wrapped
	    data_to_wrap = f(self, X, *args, **kwargs)
	  File "/usr/local/miniconda/lib/python3.10/site-packages/nilearn/maskers/nifti_labels_masker.py", line 455, in fit_transform
	    return self.fit().transform(imgs, confounds=confounds,
	  File "/usr/local/miniconda/lib/python3.10/site-packages/nilearn/maskers/nifti_labels_masker.py", line 376, in fit
	    raise ValueError(
	ValueError: Regions and mask do not have the same affine.
	labels_img: /out/xcp_d/atlases/atlas-4S156Parcels/space-MNI152NLin2009cAsym_atlas-4S156Parcels_dseg.nii.gz
	mask_img: /fmriprep/sub-002/func/sub-002_task-rest_run-2_space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz

I think atlas files cause this problem. Previously i used nilearn’s nifti labels masker and it worked without errors on my atlases and the same data.
Data was preprocessed using fmriprep

additional question

Is it possible to use several confound regressors in xcp-d? e.g. 24P and acompcor


That’s interesting, thank you. Would you be willing to share the outputted atlas file and mask file with me so I can debug this? You should be able to send it via DM if you’d like.

There’s no builtin way to do this in XCP-D, since each of the regression strategies are meant to mirror validated ones from previous papers. The easiest way to get both 24P and aCompCor regressors into XCP-D would be to extract them from the fMRIPrep confounds files yourself and use that as a custom confounds file with --nuisance-regressors custom.