Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
seaguldee opened this issue Oct 30, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@seaguldee
Copy link

seaguldee commented Oct 30, 2024

Summary

Run aslprep when pointing to fmriprep data output folder. Point aslprep to the subject and session specific folder of previously run fMRIprep. Anatomy data gets pulled into the asl output folder but I keep getting this error...

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.

Additional details

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.

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

What were you trying to do?

run aslprep when pointing to previously run fmriprep anatomic data

What did you expect to happen?

pulls the anatomic data into the asl_prep output but then it sends me an error that it can't find the T1w image

What actually happened?

Reproducing the bug

Beginning of ASL output when running below script

Building ASLPrep's workflow:
           * BIDS dataset path: /scratch/06953/jes6785/short_cal.
           * Participant list: ['lsa123'].
           * Run identifier: 20241030-165029_49230fe2-983d-44a4-9210-44dfcf507c65.
           * Output spaces: MNI152NLin2009cAsym:res-native.
           * Searching for derivatives: [PosixPath('/scratch/06953/jes6785/fmriprep_asl_ref2/sub-lsa123/ses-02')].
           * Pre-run FreeSurfer's SUBJECTS_DIR: /scratch/06953/jes6785/short_cal/asl_prep/sourcedata/freesurfer.
241030-16:51:15,675 nipype.workflow INFO:
	 ANAT Found preprocessed T1w - skipping Stage 1
241030-16:51:15,676 nipype.workflow INFO:
	 ANAT Found brain mask
241030-16:51:15,677 nipype.workflow INFO:
	 ANAT Skipping Stage 2
241030-16:51:15,677 nipype.workflow INFO:
	 ANAT Skipping Stage 3
241030-16:51:15,677 nipype.workflow INFO:
	 ANAT Found discrete segmentation
241030-16:51:15,677 nipype.workflow INFO:
	 ANAT Found tissue probability maps
241030-16:51:15,677 nipype.workflow INFO:

Error

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.

code to run aslprep

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}"
-->
[aslprep.pdf](https://github.com/user-attachments/files/17579537/aslprep.pdf)
[crash-20241030-155518-jes6785-bidssrc-cf9da2b4-4bd8-4f42-b420-04a4a390ac89.txt](https://github.com/user-attachments/files/17579541/crash-20241030-155518-jes6785-b
[ses_02_bids_filter.json](https://github.com/user-attachments/files/17579547/ses_02_bids_filter.json)
idssrc-cf9da2b4-4bd8-4f42-b420-04a4a390ac89.txt)
[asl_script_short_ses_02.txt](https://github.com/user-attachments/files/17579553/asl_script_short_ses_02.txt)

I have attached my full script, the error log, my bids filter file
@seaguldee seaguldee added the bug Something isn't working label Oct 30, 2024
@seaguldee seaguldee changed the title can't find T1w images when pointing to fMRIprep derivatives folder? can't find T1w images when pointing to fMRIprep derivatives folder? More than 1 session folder per subject Oct 30, 2024
@tsalo
Copy link
Member

tsalo commented Oct 31, 2024

The approach that should work is:

--derivatives /scratch/06953/jes6785/fmriprep_asl_ref

I'm not sure what's going wrong, but I will try to debug this problem later today.

@seaguldee
Copy link
Author

seaguldee commented Oct 31, 2024

Thank you for the feedback and your help is very much appreciated as otherwise this program works fantastically.

When I do the above suggestion, it pulls in all the T1s from each session for that subject and then throws an error that it can't decide which one to use. Including a bids filter specifying session 02 or whatever doesn't seem to help (unless I am doing this wrong but seems pretty straight forward).

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.

@tsalo
Copy link
Member

tsalo commented Oct 31, 2024

fMRIPrep doesn't support session-wise anatomical processing, so did you run fMRIPrep separately on each session?

EDIT: Also, can you share your BIDS filter file?

@tsalo
Copy link
Member

tsalo commented Nov 6, 2024

I need to get session-wise processing implemented in sMRIPrep (and preferably fMRIPrep) before I can implement it in ASLPrep, but I'm planning to work on that this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants