I am running xcp-d on my fmriprep output. My data is structured so each subject has two sessions but only the first session has a anatomical scan. xcp-d produced an error saying it requires a one-to-one or one-to-all mapping between anatomical and functional sessions.
EDIT: fMRIPrep was run on both sessions and only creates an anat folder in first session folder. I should also clarify that this is not a longitudinal study and scans are collected within a week of each other.
Command used (and if a helper script was used, a link to the helper script or the command generated):
Atlas 'MIDB' requires CIFTI processing. Skipping atlas.
Atlas 'MyersLabonte' requires CIFTI processing. Skipping atlas.
Traceback (most recent call last):
File "/usr/local/miniconda/bin/xcp_d", line 8, in <module>
sys.exit(main())
File "/usr/local/miniconda/lib/python3.10/site-packages/xcp_d/cli/run.py", line 25, in main
parse_args(args=sys.argv[1:])
File "/usr/local/miniconda/lib/python3.10/site-packages/xcp_d/cli/parser.py", line 971, in parse_args
raise ValueError(
ValueError: XCP-D expects a one-to-one mapping between anatomical sessions and functional sessions, or a one-to-all mapping. Found 1 functional sessions that do not have anatomical data: 02
How did you run fMRIPrep? Usually for multisession data fMRIPrep puts an overarching anatomical folder on the same level as the session-level folders. That is what XCP-D would expect if session-specific anatomical data are not available. Were both sessions aligned to the same T1w in fMRIPrep? If so, I imagine you could experiment with either copying the anatomical data from session 1 to session 2 (and renaming accordingly) or moving the anatomical data to the subject (instead of session) level, and renaming accordingly.
I downloaded a newer version of fMRIPrep (v25.2.0) and re-ran with the same parameters as before. However, it still did not put an overarching anatomical folder on the same level as the session-level folders. The anatomical folder is still only being outputted in my session one folder.
I’m trying out the first option you recommended with copying the anatomical data from session one to two now.
May you please provide enough information for us to help debug your issue? What fMRIPrep command did you use, and what version? What does the tree directory structure for a subject’s fMRIPrep folder and raw folder look like? Are you getting the exact same error as above?
If the issue was specifically with longitudinal studies where only one session included anatomical images, then that should be fixed in 0.13.0.
The problem was that, if multiple sessions contain anatomical data, fMRIPrep’s default behavior is to average the anatomical data across sessions and write out the results to the subject folder. Therefore, XCP-D assumed that, if the preprocessed anatomical images were located in session-level folders, there would be a one-to-one mapping between anatomical and functional data within sessions. This didn’t account for the scenario where one session has anatomical data and others do not, in which case fMRIPrep will write out the preprocessed anatomical data to the session folder instead of the subject folder, and XCP-D operated under the assumption that the anatomical data only applied to that session.