Can't find T1w images when pointing to fMRIprep derivatives folder? More than 1 session folder per subject

Summary of what happened:

can't find T1w images when pointing to fMRIprep derivatives folder? More than 1 session folder per subject · Issue #454 · PennLINC/aslprep · GitHub - also posted here, but including here if anyone has any advice…

I have 3 sessions per subject (for example)

sub-lsa123
-ses-01
-ses-02
-ses-03
sub-lsa146
-ses-01
-ses-02
-ses-03

Aslprep is forcing me to point specifically to the subject and session rather than the larger fmriprep output folder because when I try to point asl to the top of my fmriprep output folder it pulls all the T1w images in for each session and errors. This happens even when I try to use a bidsfilter file to specify the session.

This inputs all three session T1w images and errors

--derivatives /scratch/06953/jes6785/fmriprep_asl_ref

So currently, I am using bids filter file to process each session of asl data separately and pointing to the subject and session specific fmriprep output like this…

--derivatives /scratch/06953/jes6785/fmriprep_asl_ref2/sub-lsa123/ses-02

This pulls the output from fMRIprep anatomy folders into the aslprep/sub-lsa123/ses-02/anat/ folder but I am still getting an error that it can’t find the T1w images??? I don’t understand.

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

module load tacc-apptainer

BIDS_DIR="/scratch/06953/jes6785/short_cal"
ASL_OUTPUT="${BIDS_DIR}/asl_prep"
SUB="lsa123"
SESSION="02"
#SUB_LIST=("a006" "a008")
DEP=""
STUDY_NAME="project_laser"

# Create output directory if it doesn't exist


#THIS DIRECTORY SHOULD BE /work/06950/jalmeida/CONTAINERS/fmriprep_23.1.3.sif - but I can't write into this one
ASLPREP_CONTAINER="/work/06953/jes6785/Containers/aslprep_0.7.2.sif" # this is where you docker for singularity .sif lives
FSL_LICENSE_DIR="/scratch/06953/jes6785/license.txt" # location of your FSL license, see documentation, needed for fMRI prep to run
FREESURFER_LOCATION="/scratch/06953/jes6785/fmriprep_asl_ref" # This is wherever you have fMRIprep output folder - looks for a sourcedata/freesurfer folder and outputs are there are no differences in outputs for each session here 
FMRIPREP_ANAT_LOCATION="/scratch/06953/jes6785/fmriprep_asl_ref2/sub-${SUB}/ses-${SESSION}" # you have to point directly to the session location because ASL prep will input all the sessions otherwise 
BIDS_FILTER="/scratch/06953/jes6785/short_cal/ses_${SESSION}.json"
WORK="/scratch/06953/jes6785/work" # Wherever you want the intermediate data processed 
# NO CHNAGES NECESSARY BELOW HERE
#----------------------------------------------------------------------------------------------------------------------
mkdir -p "$ASL_OUTPUT"
apptainer run -e
"$ASLPREP_CONTAINER"
"${BIDS_DIR}"
"${ASL_OUTPUT}"
participant
--participant-label "${SUB}"
--fs-license-file "${FSL_LICENSE_DIR}"
--skip_bids_validation
--derivatives "${FMRIPREP_ANAT_LOCATION}"
--bids-filter-file "${BIDS_FILTER}"
--basil
--scorescrub
-w "${WORK}"

Version:

  • ASLPrep version: aslprep_0.7.2
  • Apptainer version: 1.1.8-2.el8

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

Apptainer

Data formatted according to a validatable standard? Please provide the output of the validator:

PASTE VALIDATOR OUTPUT HERE

Relevant log outputs (up to 20 lines):

Error   File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/nipype/pipeline/engine/nodes.py", line 771, in _run_command
    raise NodeExecutionError(msg)
nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node bidssrc.

Traceback:
	Traceback (most recent call last):
	  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/nipype/interfaces/base/core.py", line 397, in run
	    runtime = self._run_interface(runtime)
	              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/aslprep/interfaces/bids.py", line 68, in _run_interface
	    raise FileNotFoundError(
	FileNotFoundError: No T1w images found for subject sub-lsa123


241030-16:03:32,84 cli ERROR:
	 Preprocessing did not finish successfully. Errors occurred while processing data from participants: lsa123 (1). Check the HTML reports for details.

Screenshots / relevant information:


Hi @AustinBipolar,

In the future, please use the software support category, as it prompts you to organize your post better and provide important information. I reorganized it and added information taken the github post, but it would be better if you could do it in the future.

It doesn’t look like you binded any directories in your apptainer run command. You should make to mount /scratch and /work.

Also, you can try pointing the derivatives folder higher up, to the place where the subject-level folders can be found.

Best,
Steven

Thanks for that feedback.

Our HPC system automatically binds the directories when using apptainer but I will try binding just in case.

I can’t point aslprep to the overall fMRIprep directory because when I do, it pulls all the T1w volumes for each session and doesn’t seem to be able to differentiate between them. ASLprep then throws an error saying it doesn’t know which T1 to use even though they are all clearly labelled as ses-01 or ses-02 as per BIDS formatting. I am wondering if the aslprep processing didn’t account for a way to handle different sessions when pulling in from fMRIprep derivatives folder??

Here is the error…

during handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/envs/aslprep/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/opt/conda/envs/aslprep/lib/python3.11/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/aslprep/cli/workflow.py", line 95, in build_workflow
    retval["workflow"] = init_aslprep_wf()
                         ^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/aslprep/workflows/base.py", line 68, in init_aslprep_wf
    single_subject_wf = init_single_subject_wf(subject_id)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/aslprep/workflows/base.py", line 273, in init_single_subject_wf
    anat_fit_wf = init_anat_fit_wf(
                  ^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/smriprep/workflows/anatomical.py", line 782, in init_anat_fit_wf
    anat_validate.inputs.in_file = precomputed["t1w_preproc"]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/nipype/interfaces/base/traits_extension.py", line 330, in validate
    value = super(File, self).validate(objekt, name, value, return_pathlike=True)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/nipype/interfaces/base/traits_extension.py", line 131, in validate
    self.error(objekt, name, str(value))
  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/traits/base_trait_handler.py", line 74, in error
    raise TraitError(
traits.trait_errors.TraitError: The 'in_file' trait of a _ValidateImageInputSpec instance must be a pathlike object or string representing an existing file, but a value of "['/scratch/06953/jes6785/fmriprep_asl_ref2/sub-lsa123/ses-01/anat/sub-lsa123_ses-01_rec-normDefaced_desc-preproc_T1w.nii.gz', '/scratch/06953/jes6785/fmriprep_asl_ref2/sub-lsa123/ses-02/anat/sub-lsa123_ses-02_rec-normDefaced_desc-preproc_T1w.nii.gz', '/scratch/06953/jes6785/fmriprep_asl_ref2/sub-lsa123/ses-03/anat/sub-lsa123_ses-03_rec-normDefaced_desc-preproc_T1w.nii.gz']" <class 'str'> was specified.

Thanks for your feedback though on this again,

Jennifer

Also, sorry about missing the software support category. Should I delete and repost?

Hi @AustinBipolar,

No, I edited your post to put in the category and add in the appropriate post template. Just keep in mind for future posts.

What does your BIDS filter look like?

You could try, in scratch space, making temporary session specific fmriprep folders that are deleted after aslprep runs. Also, what is the motivation for passing in fmriprep derivatives in the first place?

Best,
Steven

Motivation = saving time so I don’t have to rerun all the anatomical segmentations. Yeah, was thinking that re: session specific folders. Just was hoping it would work out of the box :slight_smile: Will implement that option tomorrow. We have a ton of scans and just didn’t want things to messy. Thanks and happy Halloween.