XCP-D custom nuisance regressor config

Summary of what happened:

I am new to XCP-D. I am trying to use my confound regressor strategy which is only a slight variation from the built-in ones. I wrote my custom.yml file which only includes regressors from fMRIPrep. But I am having trouble figuring out how to pass it in.

Command used

apptainer run --cleanenv xcp-d_v0.8.3.sif input_dir output_dir participant
–participant_label 01
–mode linc
–nuisance-regressors output_dir/custom.yaml
–dummy-scans 4
–fs-license-file /project/mri/license.txt

Version:

v0.8.3

The error suggests that --nuisance-regressors only takes custom strategies, or custom, or none, contrary to the documentation

Relevant log outputs (up to 20 lines):

PASTE LOG OUTPUT HERE

xcp_d: error: argument -p/–nuisance-regressors/–nuisance_regressors: invalid choice: ‘/xdisk/jandrewshanna/yuhua/ACHV/MRIS/postprocess2/acompcor_aroma.yaml’ (choose from ‘27P’, ‘36P’, ‘24P’, ‘acompcor’, ‘aroma’, ‘acompcor_gsr’, ‘aroma_gsr’, ‘custom’, ‘none’, ‘gsr_only’)


Hi @Yuhua_Yu and welcome to neurostars!

If you look at the changelog on the GitHub repo, you can see that the ability to pass confound configs was only introduced in the release candidate for version 0.10.0rc1 5 days ago, so you need to update. Description of the config files are here: Processing Pipeline Details — xcp_d 0.10.0rc2.dev5+gf54208a documentation

Additionally, it doesn’t look like you mounted your drives with the -B flag in your apptainer preamble. See more about that here: Executing with Singularity - NiPreps

Best,
Steven

1 Like

Got it, thank you so much! @Steven

Summary of what happened:

I am trying out the custom confound regressor strategy (which only uses fMRIprep regressors) with the latest release candidate. I ran into a problem that I didn’t have with the previous version 0.8.3 (it all ran through with the older version with the default -p)

Command used (and if a helper script was used, a link to the helper script or the command generated):

apptainer run --cleanenv xcp-d_v0.10.0rc1.sif input_dir output_dir participant
–participant_label 01
–mode linc
–nuisance-regressors output_dir/custom.yaml
–dummy-scans 4
–fs-license-file /project/mri/license.txt

Version:

0.10.0rc1

Relevant log outputs (up to 20 lines):

2024-10-10 20:25:15,493 [ WARNING] WARNING: `sentry_sdk.Hub` is deprecated and will be removed in a future major release. Please consult our 1.x to 2.x migration guide for details on how to migrate `Hub` usage to the new API: https://docs.sentry.io/platforms/python/migration/1.x-to-2.x
2024-10-10 20:25:15,733 [ WARNING] Framewise displacement-based scrubbing is disabled. The following parameters will have no effect:
	--min-time
2024-10-10 20:25:26,902 [ WARNING] WARNING: sentry_sdk.configure_scope is deprecated and will be removed in the next major version. Please consult our migration guide to learn how to migrate to the new API: https://docs.sentry.io/platforms/python/migration/1.x-to-2.x#scope-configuring
2024-10-10 20:25:39,324 [ WARNING] WARNING: `sentry_sdk.Hub` is deprecated and will be removed in a future major release. Please consult our 1.x to 2.x migration guide for details on how to migrate `Hub` usage to the new API: https://docs.sentry.io/platforms/python/migration/1.x-to-2.x
241010-20:25:41,509 nipype.workflow IMPORTANT:
	 Running XCP-D version 0.10.0rc1
2024-10-10 20:25:41,509 [IMPORTANT] Running XCP-D version 0.10.0rc1
241010-20:25:41,512 nipype.workflow WARNING:
	 Previous output generated by version 0+unknown found.
2024-10-10 20:25:41,512 [ WARNING] Previous output generated by version 0+unknown found.
241010-20:25:45,253 nipype.workflow IMPORTANT:
	 Building XCP-D's workflow:
           * Preprocessing derivatives path: /xdisk/jandrewshanna/yuhua/ACHV/MRIS/derivatives.
           * Participant list: ['74'].
           * Run identifier: 20241010-202511_2a158dae-8a8c-4cb3-9a40-b13d6df5e31c.
           * Searching for derivatives and atlases: {'xcpdatlases': PosixPath('/usr/local/miniconda/lib/python3.10/site-packages/xcp_d/data/atlases'), 'xcpd4s': PosixPath('/AtlasPack')}.
2024-10-10 20:25:45,253 [IMPORTANT] Building XCP-D's workflow:
           * Preprocessing derivatives path: /xdisk/jandrewshanna/yuhua/ACHV/MRIS/derivatives.
           * Participant list: ['74'].
           * Run identifier: 20241010-202511_2a158dae-8a8c-4cb3-9a40-b13d6df5e31c.
           * Searching for derivatives and atlases: {'xcpdatlases': PosixPath('/usr/local/miniconda/lib/python3.10/site-packages/xcp_d/data/atlases'), 'xcpd4s': PosixPath('/AtlasPack')}.
Process Process-2:
Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/usr/local/miniconda/lib/python3.10/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/miniconda/lib/python3.10/site-packages/xcp_d/cli/workflow.py", line 100, in build_workflow
    retval["workflow"] = init_xcpd_wf()
  File "/usr/local/miniconda/lib/python3.10/site-packages/xcp_d/workflows/base.py", line 81, in init_xcpd_wf
    single_subject_wf = init_single_subject_wf(subject_id)
  File "/usr/local/miniconda/lib/python3.10/site-packages/xcp_d/workflows/base.py", line 127, in init_single_subject_wf
    subj_data = collect_data(
  File "/usr/local/miniconda/lib/python3.10/site-packages/xcp_d/utils/bids.py", line 209, in collect_data
    raise FileNotFoundError(
FileNotFoundError: No BOLD data found in allowed spaces (fsLR).

Query: {'datatype': 'func', 'desc': ['preproc', None], 'suffix': 'bold', 'extension': '.dtseries.nii', 'space': 'fsLR'}

Found files:

Screenshots / relevant information:


Hi @Yuhua_Yu,

Did you run fmriprep with the cifti outputs? That’s what it’s looking for. If you only have volumetric data you can change the —file-format flag.

Best,
Steven

You are right, overwrite the -file-format to nifti solved this problem. But now when it gets to pull the regressors, it seems cannot find AROMA, even though they are included in my fMRIPrep. So in the case of using a custom config, do I always need to provide my custom data, with -c?

FYI, my custom.yaml looks like this:

name: acompcor_aroma
description: |
Nuisance regressors were selected according to the ‘acompcor’ and ‘aroma’ combined strategy.

confounds:
    preproc_confounds:
        dataset: preprocessed
        query:
            space: null
            cohort: null
            res: null
            den: null
            desc: confounds
            extension: .tsv
            suffix: timeseries
        columns:
        - ^w_comp_cor_0[1-5]$
        - ^c_comp_cor_0[1-5]$
        - ^cosine\d+$
    aroma_confounds:
        dataset: aroma
        query:
            space: null
            cohort: null
            res: null
            den: null
            desc: aroma
            extension: .tsv
            suffix: timeseries
        columns:
        # Regular expressions begin with ``^`` and end with ``$``.
        - ^aroma_orth_motion_.*$

and here is the error log:

Process Process-2:
Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/usr/local/miniconda/lib/python3.10/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/miniconda/lib/python3.10/site-packages/xcp_d/cli/workflow.py", line 100, in build_workflow
    retval["workflow"] = init_xcpd_wf()
  File "/usr/local/miniconda/lib/python3.10/site-packages/xcp_d/workflows/base.py", line 81, in init_xcpd_wf
    single_subject_wf = init_single_subject_wf(subject_id)
  File "/usr/local/miniconda/lib/python3.10/site-packages/xcp_d/workflows/base.py", line 426, in init_single_subject_wf
    confounds_dict = collect_confounds(
  File "/usr/local/miniconda/lib/python3.10/site-packages/xcp_d/utils/bids.py", line 724, in collect_confounds
    raise ValueError(
ValueError: Missing dataset required by confound spec: *aroma*. Did you provide it with the `--datasets` flag?
Not required: xcpdatlases
Not required: xcpd4s
2

Hi @Yuhua_Yu,

Do you not have your aroma confounds in the same confounds file as your other confounds? The way you structured this makes it sound like you have a aroma-specific confound file.

Best,
Steven

That is indeed the problem. Thanks for your extraordinary patience and responsive help!

1 Like