Running fmriprep with --anat-derivatives

Hi all, I have a question about running fmriprep in a two-step fashion. I’ve first run it using the --anat-only flag, to preprocess my structural data. Now I’m trying to preprocess my functional data, session by session, but not all my sessions have T1w images.

I have an input folder which contains a dataset description, and then data from a single session (in proper bids format)

I have an output folder which contains the outputs of my previous run of fmriprep (–anat-only).

Then I run this command:
sudo docker run -v ~/input:/data:ro -v ~/output:/output -v ~/scratch/:/scratch -v ~/freesurfer:/freesurfer nipreps/fmriprep:latest /data /output participant --participant-label 001 -w /scratch --fs-license-file /freesurfer/license.txt --anat-derivatives /output/fmriprep/sub-001/anat/ --skip_bids_validation

And get this output:

231025-22:02:32,124 nipype.workflow IMPORTANT:
         Running fMRIPrep version 23.1.4

         License NOTICE ##################################################
         fMRIPrep 23.1.4
         Copyright 2023 The NiPreps Developers.
         
         This product includes software developed by
         the NiPreps Community (https://nipreps.org/).
         
         Portions of this software were developed at the Department of
         Psychology at Stanford University, Stanford, CA, US.
         
         This software is also distributed as a Docker container image.
         The bootstrapping file for the image ("Dockerfile") is licensed
         under the MIT License.
         
         This software may be distributed through an add-on package called
         "Docker Wrapper" that is under the BSD 3-clause License.
         #################################################################
231025-22:02:32,161 nipype.workflow IMPORTANT:
         Building fMRIPrep's workflow:
           * BIDS dataset path: /data.
           * Participant list: ['001'].
           * Run identifier: 20231025-220218_29bc133c-fc77-44bf-a2d5-474268cd15cd.
           * Output spaces: MNI152NLin2009cAsym:res-native.
           * Anatomical derivatives: /output/fmriprep/sub-001/anat.
           * Pre-run FreeSurfer's SUBJECTS_DIR: /output/sourcedata/freesurfer.
231025-22:02:32,337 nipype.workflow WARNING:
         Attempted to access pre-existing anatomical derivatives at </output/fmriprep/sub-001/anat>, however not all expectations of fMRIPrep were met (for participant <001>, spaces <MNI152NLin2009cAsym>, reconall <True>).
Process Process-2:
Traceback (most recent call last):
  File "/opt/conda/envs/fmriprep/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/opt/conda/envs/fmriprep/lib/python3.10/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/cli/workflow.py", line 115, in build_workflow
    retval["workflow"] = init_fmriprep_wf()
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/workflows/base.py", line 93, in init_fmriprep_wf
    single_subject_wf = init_single_subject_wf(subject_id)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/workflows/base.py", line 202, in init_single_subject_wf
    raise Exception(
Exception: No T1w images found for participant 001. All workflows require T1w images.

Any suggestions? Thanks for the help!

Hi @Kirk_Graff,

Fmriprep will not run if there is not a t1 passed into the command. You’ll still need to have a t1 available for fmriprep in the raw input data, even if using precomputed derivatives.

Best,
Steven

Thanks Steven; that’s annoying. Regardless, when I try to run on a session that actually has a T1w, it appears to be carrying out structural preprocessing on that T1w. Or am I mistaken? It creates a bunch of session specific anat outputs that otherwise wouldn’t be created.

Can you try specifying the overall fmriprep output directory as the anat derivative, and not the specific anatomical folder?

I tried running it with both --anat-derivatives /output/fmriprep and --anat-derivatives /output, running on 2 sessions, one with a T1w and one without. It produced session-specific structural outputs for the session, and (I assume?) ignored the structural outputs specified with --anat-derivatives.