Question about using preprocessed T1 to do the preprocessing of fMRI with fmriprep

Dear all:

I have preprocessed the T1 image of a group of subjects with freesurfer. However, I found that I need to use their rest fMRI data later. Instead of redo the preprocessing with T1 and fMRI together, Can I only preprocess the rest fMRI data with the preprocessed T1 I already have in fmriprep?

Best,
Xiaoying

Hi @Xiaoying,

Yes, try putting --derivatives $ANAT_OUTPUT (pointing to your anatomical data) in your fmriprep command.

Best,
Steven

Hi Steven,

Thank you so much for your prompt reply! Iā€™ll try it with your advice.

Best,
Xiaoying

Hi Stevenļ¼Œ
Iā€™ve tried adding --derivatives in my script but encountered an error ā€œfmriprep: error: argument analysis_level: invalid choice: ā€˜/home/addFour_SCZ/UESTC_FEP_BIDS_prepā€™ (choose from ā€˜participantā€™)ā€.

I ran the following code:
#!/bin/bash
singularity run --cleanenv /fmriprep.simg  \
/home/addFour_SCZ/UESTC_FEP_BIDS \
-w /home/hujian/sxy \
--nprocs 48 \
--omp-nthreads 1 \
--use-aroma  \
--cifti-output 91k \

ā€“output-space fsaverage5 \
ā€“derivatives /home/UESTC_FEP_T1
ā€“fs-license /home/HJ/soft/freesurfer/license.txt
/home/addFour_SCZ/UESTC_FEP_BIDS_prep participant

The /home/UESTC_FEP_T1 is the directory of preprocessed T1, It contains fsaverage, fsaverage5 and every subjectā€™s directory. Do these codes seem right?

Hi @Xiaoying,

Oh, those are FreeSurfer outputs! In that case, pass that directory into ā€”fs-subjects-dir.

Best,
Steven

Hi Steven,
Sorry to bother you again :sob: :sob:, I passed the directory into --fs-subjects-dir. The error of participant was solved but I encountered a new one.
The information in the slurm is pasted below:

    */usr/local/miniconda/lib/python3.7/site-packages/bids/layout/validation.py:46: UserWarning: The ability to pass arguments to BIDSLayout that control indexing is likely to be removed in future; possibly as early as PyBIDS 0.14. This includes the `config_filename`, `ignore`, `force_index`, and `index_metadata` arguments. The recommended usage pattern is to initialize a new BIDSLayoutIndexer with these arguments, and pass it to the BIDSLayout via the `indexer` argument.*
*  warnings.warn("The ability to pass arguments to BIDSLayout that control "*
*You are using fMRIPrep-20.2.0, and a newer version of fMRIPrep is available: 23.2.3.*
*Please check out our documentation about how and when to upgrade:*
*https://fmriprep.readthedocs.io/en/latest/faq.html#upgrading*
*WARNING: Version 20.2.0 of fMRIPrep (current) has been FLAGGED*
*(reason: Functional outputs in standard space can be wrong depending on the original data's orientation headers - see https://github.com/nipreps/fmriprep/issues/2307).*
*That means some severe flaw was found in it and we strongly*
*discourage its usage.*
*Traceback (most recent call last):*
*  File "/usr/local/miniconda/bin/fmriprep", line 10, in <module>*
*    sys.exit(main())*
*  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/cli/run.py", line 17, in main*
*    parse_args()*
*  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/cli/parser.py", line 684, in parse_args*
*    config.environment.exec_env, opts.bids_dir, opts.participant_label*
*  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/utils/bids.py", line 155, in validate_input_dir*
*    subprocess.check_call(['bids-validator', bids_dir, '-c', temp.name])*
*  File "/usr/local/miniconda/lib/python3.7/subprocess.py", line 341, in check_call*
*    raise CalledProcessError(retcode, cmd)*
*subprocess.CalledProcessError: Command '['bids-validator', PosixPath('/home/addFour_SCZ/UESTC_FEP_BIDS'), '-c', '/tmp/tmpotnk84z8']' returned non-zero exit status 1.*

Iā€™m wondering if itā€™s caused by my input BIDS directory. The structure of the directory is: input BIDSā€”Subject directory(sub-XX)ā€”funcā€”bold.nii.gz & json file. I only put the fMRI in it because I already preprocessed T1 image with freesurfer 2 months ago. So I ask whether I can do fmriprep with preprocessed T1 in the beginning of this topic.
Was there any detail that I didnā€™t notice. Thank you for your help!

Best,
Xiaoying

Hi @Xiaoying,

It probably means your data are not bids valid. Please return the structure of one of your raw subject folders, using the tree command, making sure to publish your text as code so it formats nicely

like this

by using the </> button in the text editor.

Best,
Steven

Hi Steven,

Hereā€™s the structure of one of my subject folders,
/home/addFour_SCZ/UESTC_FEP_BIDS/sub-140/func/sub-140_task-rest_bold.nii.gz
/home/addFour_SCZ/UESTC_FEP_BIDS/sub-140/func/sub-140_task-rest_bold.json

Sorry for the messy text before, the code Iā€™m using is

singularity run --cleanenv /fmriprep.simg  \
/home/addFour_SCZ/UESTC_FEP_BIDS \
-w /home/hujian/sxy \
--nprocs 48 \
--omp-nthreads 1 \
--use-aroma  \
--cifti-output 91k \
--output-space fsaverage5 \
--fs-subjects-dir /home/addFour_SCZ/UESTC_FEP_T1 \
--fs-license /home/HJ/soft/freesurfer/license.txt \
/home/addFour_SCZ/UESTC_FEP_BIDS_prep participant

And the error that I received was:

Fri  7 Jun 20:39:07 CST 2024
bids-validator@1.4.0

	e[31m1: [ERR] Dataset does not contain any T1w scans. (code: 53 - NO_T1W)e[39m

e[36m	Please visit https://neurostars.org/search?q=NO_T1W for existing conversations about this issue.e[39m

	e[33m1: [WARN] The recommended file /README is missing. See Section 03 (Modality agnostic files) of the BIDS specification. (code: 101 - README_FILE_MISSING)e[39m

e[36m	Please visit https://neurostars.org/search?q=README_FILE_MISSING for existing conversations about this issue.e[39m


        e[34me[4mSummary:e[24me[39m                  e[34me[4mAvailable Tasks:e[24me[39m        e[34me[4mAvailable Modalities:e[24me[39m 
        18 Files, 361.67MB                                bold                  
        9 - Subjects                                                            
        1 - Session                                                             


e[36m	If you have any questions, please post on https://neurostars.org/tags/bids.e[39m

/usr/local/miniconda/lib/python3.7/site-packages/bids/layout/validation.py:46: UserWarning: The ability to pass arguments to BIDSLayout that control indexing is likely to be removed in future; possibly as early as PyBIDS 0.14. This includes the `config_filename`, `ignore`, `force_index`, and `index_metadata` arguments. The recommended usage pattern is to initialize a new BIDSLayoutIndexer with these arguments, and pass it to the BIDSLayout via the `indexer` argument.
  warnings.warn("The ability to pass arguments to BIDSLayout that control "
You are using fMRIPrep-20.2.0, and a newer version of fMRIPrep is available: 23.2.3.
Please check out our documentation about how and when to upgrade:
https://fmriprep.readthedocs.io/en/latest/faq.html#upgrading
WARNING: Version 20.2.0 of fMRIPrep (current) has been FLAGGED
(reason: Functional outputs in standard space can be wrong depending on the original data's orientation headers - see https://github.com/nipreps/fmriprep/issues/2307).
That means some severe flaw was found in it and we strongly
discourage its usage.
Traceback (most recent call last):
  File "/usr/local/miniconda/bin/fmriprep", line 10, in <module>
    sys.exit(main())
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/cli/run.py", line 17, in main
    parse_args()
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/cli/parser.py", line 684, in parse_args
    config.environment.exec_env, opts.bids_dir, opts.participant_label
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/utils/bids.py", line 155, in validate_input_dir
    subprocess.check_call(['bids-validator', bids_dir, '-c', temp.name])
  File "/usr/local/miniconda/lib/python3.7/subprocess.py", line 341, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['bids-validator', PosixPath('/home/hujian/sunxiaoying/addFour_SCZ/UESTC_FEP_BIDS'), '-c', '/tmp/tmpotnk84z8']' returned non-zero exit status 1.
Fri  7 Jun 20:39:17 CST 2024

Many thanks for your help again.

Best,
Xiaoying

Hi @Xiaoying,

You still need to put T1w scans in the raw bids folder, even if youā€™ve already ran freesurfer on them.

Best,
Steven

Hi Steven,
It worked this time! I added the T1w data into my BIDS folder and the code worked just fine! Thank you very much for your time and invaluable assistance.

Best,
Xiaoying

1 Like