XCP-D error output: Can't find anatomical image

Summary of what happened:

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):

singularity run --cleanenv \
  -B /code/freesurfer/ \
  ${singularityDir}/xcp_d.sif \
  ${prepDir} ${xcpDir} participant --participant-label $SUBJECT \
  --mode none \
  --file-format nifti \
  --despike n \
  --fd-thresh 0.5 \
  --input-type fmriprep \
  --abcc-qc y \
  --dummy-scans auto \
  --lower-bpf 0.008 \
  --upper-bpf 0.08 \
  --smoothing 6 \
  --linc-qc y \
  --combine-runs n \
  --motion-filter-type none \
  --output-type censored \
  --min-coverage 0.5 \
  --warp-surfaces-native2std n \
  -t rest \
  -p 36P \
  -w ${WDIR} \
  --fs-license-file /code/freesurfer/license.txt \
  --resource-monitor

Version:

0.11.0

Environment (Docker, Singularity / Apptainer, custom installation):

Singularity

Relevant log outputs (up to 20 lines):

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

Hi @jypeters and welcome to neurostars!

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.

Best,
Steven

Hi @Steven,

fMRIPrep was run using a singularity container. I will post the command used:

singularity run --cleanenv \
-B "${DATA_DIR}" \
-B /code/freesurfer/ \
/code/singularityContainers/fmriprep-23.2.0.simg \
"${DATA_DIR}" "${OUT_DIR}" \
participant --participant_label "${SUBJECT}" \
--fs-license-file /code/freesurfer/license.txt \
--ignore slicetiming \
--output-spaces MNI152NLin6Asym:res-2 T1w:res-2 fsaverage6 \
--output-layout bids \
--bold2t1w-init register \
--bold2t1w-dof 12 --force-bbr \
--slice-time-ref 0.5 \
--fd-spike-threshold 0.5 \
--dvars-spike-threshold 1.5 \
--skull-strip-template OASIS30ANTs \
--skull-strip-fixed-seed \
--skull-strip-t1w force \
--resource-monitor \
--notrack \
-w "${WDIR}" \
--stop-on-first-crash

I’m assuming both sessions were aligned to the same T1w since only one T1w image exists per subject.

Hi @jypeters.

Ah, that fMRIPrep version is fairly old, perhaps that’s why.

Best,
Steven

Hi @Steven

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.