nipreps / fmriprep

fMRIPrep is a robust and easy-to-use pipeline for preprocessing of diverse fMRI data. The transparent workflow dispenses of manual intervention, thereby ensuring the reproducibility of the results.
https://fmriprep.org
Apache License 2.0
625 stars 290 forks source link

Output Space of fmriprep #2338

Open ly6ustc opened 3 years ago

ly6ustc commented 3 years ago

Hi all, I'm trying to preprocess Parkinson's resting-state fMRI data by fmriprep20.1.1 (docker). Here I have some questions of output space. 1) If I have done all processes and got results of MNI152NLin2009cAsym:res-2 space, and then I want results of MNI152NLin2009cAsym:res-native and MNI152NLin6Asym:res-2 space. Should I do all processes again after revise option "--cifti-output"? Maybe I could skip time-consuming surface reconstruction by using option "--fs-subjects-dir". Besides, are there other ways(options) to speed up the process by taking advantage of existing derivatives? As for results with different resolutions in the same space, can I convert them by resampling (interpolation)? 2) For Parkinson's Disease, there is a specific PD25 T1 template (http://nist.mni.mcgill.ca/?p=1209) in MNI152NLin2009cAsym space. Although this template is warped to MNI152NLin2009cAsym space, there still are some slight differences between PD template and MNI152NLin2009cAsym T1 template. So, is it necessary for me to output my results to PD25 template? If Yes, how do I use it as my custom templates? I have read the fmriprep document of "Custom standard spaces", but I can't find the templateFlow’s home directory "$HOME/.cache/templateflow" in my computer, and I don't know how to get the template_description.json file of PD template. Maybe I misunderstand somethings. Thanks!

oesteban commented 3 years ago
  1. If I have done all processes and got results of MNI152NLin2009cAsym:res-2 space, and then I want results of MNI152NLin2009cAsym:res-native and MNI152NLin6Asym:res-2 space. Should I do all processes again after revise option "--cifti-output"? Maybe I could skip time-consuming surface reconstruction by using option "--fs-subjects-dir". Besides, are there other ways(options) to speed up the process by taking advantage of existing derivatives? As for results with different resolutions in the same space, can I convert them by resampling (interpolation)?

I might be wrong, but I believe that --output-spaces MNI152NLin2009cAsym:res-2 MNI152NLin2009cAsym:native MNI152NLin6Asym:res-2 should do in your case.

2. how do I use it as my custom templates?

https://www.templateflow.org/usage/client/#custom-study-population-specific-templates

2. I have read the fmriprep document of "Custom standard spaces", but I can't find the templateFlow’s home directory "$HOME/.cache/templateflow" in my computer, and I don't know how to get the template_description.json file of PD template. Maybe I misunderstand somethings.

Because you are running with Docker, then that $HOME/.cache/templateflow folder will be the home directory inside the container. In this case you want to store the state of TemplateFlow outside the container, in your host.

The easiest way of doing this, in your case would be adding the following <docker-argument> into your docker run <docker-arguments> nipreps/fmriprep:20.1.1 <fmriprep-arguments> command line:

-v $HOME/.cache/templateflow:/home/fmriprep/.cache/templateflow

ly6ustc commented 3 years ago
  1. If I have done all processes and got results of MNI152NLin2009cAsym:res-2 space, and then I want results of MNI152NLin2009cAsym:res-native and MNI152NLin6Asym:res-2 space. Should I do all processes again after revise option "--cifti-output"? Maybe I could skip time-consuming surface reconstruction by using option "--fs-subjects-dir". Besides, are there other ways(options) to speed up the process by taking advantage of existing derivatives? As for results with different resolutions in the same space, can I convert them by resampling (interpolation)?

I might be wrong, but I believe that --output-spaces MNI152NLin2009cAsym:res-2 MNI152NLin2009cAsym:native MNI152NLin6Asym:res-2 should do in your case.

  1. how do I use it as my custom templates?

https://www.templateflow.org/usage/client/#custom-study-population-specific-templates

  1. I have read the fmriprep document of "Custom standard spaces", but I can't find the templateFlow’s home directory "$HOME/.cache/templateflow" in my computer, and I don't know how to get the template_description.json file of PD template. Maybe I misunderstand somethings.

Because you are running with Docker, then that $HOME/.cache/templateflow folder will be the home directory inside the container. In this case you want to store the state of TemplateFlow outside the container, in your host.

The easiest way of doing this, in your case would be adding the following <docker-argument> into your docker run <docker-arguments> nipreps/fmriprep:20.1.1 <fmriprep-arguments> command line:

-v $HOME/.cache/templateflow:/home/fmriprep/.cache/templateflow

Thanks for your response, they are help a lot. I will try your suggetions. Actually, for question #1 , I want to know if we could use other options besides "--fs-subjects-dir" to speed up when I run fmriprep preproceesing again. Because I think there might be some repeated work if I just want to change output space. Or is it better for me to use all widely-used space when I firstly run fmriprep? Thanks for you response again!

oesteban commented 3 years ago

Because I think there might be some repeated work if I just want to change output space. Or is it better for me to use all widely-used space when I firstly run fmriprep?

Yes, there's some workload that is repeated with every change to the output spaces. We are working towards improving this (see discussions relative to the "fast-track" at sMRIPrep), but there's nothing in-place working at the moment (other than --fs-subjects-dir).

ly6ustc commented 3 years ago

Because I think there might be some repeated work if I just want to change output space. Or is it better for me to use all widely-used space when I firstly run fmriprep?

Yes, there's some workload that is repeated with every change to the output spaces. We are working towards improving this (see discussions relative to the "fast-track" at sMRIPrep), but there's nothing in-place working at the moment (other than --fs-subjects-dir).

OK, thank you very much.

ly6ustc commented 3 years ago
  1. If I have done all processes and got results of MNI152NLin2009cAsym:res-2 space, and then I want results of MNI152NLin2009cAsym:res-native and MNI152NLin6Asym:res-2 space. Should I do all processes again after revise option "--cifti-output"? Maybe I could skip time-consuming surface reconstruction by using option "--fs-subjects-dir". Besides, are there other ways(options) to speed up the process by taking advantage of existing derivatives? As for results with different resolutions in the same space, can I convert them by resampling (interpolation)?

I might be wrong, but I believe that --output-spaces MNI152NLin2009cAsym:res-2 MNI152NLin2009cAsym:native MNI152NLin6Asym:res-2 should do in your case.

  1. how do I use it as my custom templates?

https://www.templateflow.org/usage/client/#custom-study-population-specific-templates

  1. I have read the fmriprep document of "Custom standard spaces", but I can't find the templateFlow’s home directory "$HOME/.cache/templateflow" in my computer, and I don't know how to get the template_description.json file of PD template. Maybe I misunderstand somethings.

Because you are running with Docker, then that $HOME/.cache/templateflow folder will be the home directory inside the container. In this case you want to store the state of TemplateFlow outside the container, in your host.

The easiest way of doing this, in your case would be adding the following <docker-argument> into your docker run <docker-arguments> nipreps/fmriprep:20.1.1 <fmriprep-arguments> command line:

-v $HOME/.cache/templateflow:/home/fmriprep/.cache/templateflow

  1. If I have done all processes and got results of MNI152NLin2009cAsym:res-2 space, and then I want results of MNI152NLin2009cAsym:res-native and MNI152NLin6Asym:res-2 space. Should I do all processes again after revise option "--cifti-output"? Maybe I could skip time-consuming surface reconstruction by using option "--fs-subjects-dir". Besides, are there other ways(options) to speed up the process by taking advantage of existing derivatives? As for results with different resolutions in the same space, can I convert them by resampling (interpolation)?

I might be wrong, but I believe that --output-spaces MNI152NLin2009cAsym:res-2 MNI152NLin2009cAsym:native MNI152NLin6Asym:res-2 should do in your case.

  1. how do I use it as my custom templates?

https://www.templateflow.org/usage/client/#custom-study-population-specific-templates

  1. I have read the fmriprep document of "Custom standard spaces", but I can't find the templateFlow’s home directory "$HOME/.cache/templateflow" in my computer, and I don't know how to get the template_description.json file of PD template. Maybe I misunderstand somethings.

Because you are running with Docker, then that $HOME/.cache/templateflow folder will be the home directory inside the container. In this case you want to store the state of TemplateFlow outside the container, in your host.

The easiest way of doing this, in your case would be adding the following <docker-argument> into your docker run <docker-arguments> nipreps/fmriprep:20.1.1 <fmriprep-arguments> command line:

-v $HOME/.cache/templateflow:/home/fmriprep/.cache/templateflow

I'm sorry that I still can’t use custom templates by docker. I have followed the steps described in https://fmriprep.readthedocs.io/en/stable/spaces.html#custom-standard-spaces. My custom template follows: $TEMPLATEFLOW_HOME/ tpl-MNI152NLin2009cAsym_PD25/ template_description.json tpl-MNI152NLin2009cAsym_PD25_res-01_T1w.nii.gz tpl-MNI152NLin2009cAsym_PD25_res-01_desc-brain_mask.nii.gz tpl-MNI152NLin2009cAsym_PD25_res-02_T1w.nii.gz tpl-MNI152NLin2009cAsym_PD25_res-02_desc-brain_mask.nii.gz

And my docker command is docker run -i --name fmriprep$name --rm \ -v $fs_licence:/opt/freesurfer/license.txt:ro \ -v $BIDSdir:/data:ro \ -v $TEMPLATEFLOW_HOME:/home/fmriprep/.cache/templateflow \ -v $prepre_dir/$name:/out \ -v $work_dir/$name/work:/scratch \ poldracklab/fmriprep:latest \ /data /out \ participant --participant-label $name \ -w /scratch \ --nthreads $nthreads \ --fs-no-reconall \ --output-spaces MNI152NLin2009cAsym_PD25:res-2 MNI152NLin2009cAsym_PD25:res-native

But it didn't work, and the error is "ValueError: space identifier "MNI152NLin2009cAsym_PD25" is invalid. Valid identifiers are: Fischer344, ILABSInfant, MNI152Lin, MNI152NLin2009cAsym, MNI152NLin2009cSym, MNI152NLin6Asym, MNI152NLin6Sym, MNIInfant, MNIPediatricAsym, NKI, OASIS30ANTs, PNC, UNCInfant, WHS, fsLR, fsaverage, test, T1w, T2w, anat, fsnative, func, run, sbref, session"

I think the docker's container didn't find the correct path of templateflow. What should I do?

Thanks!

oesteban commented 3 years ago

I think the docker's container didn't find the correct path of templateflow. What should I do?

What makes you think that?

Let's re-read the error slowly:

ValueError: space identifier "MNI152NLin2009cAsym_PD25" is invalid.
Valid identifiers are: Fischer344, ILABSInfant, MNI152Lin, MNI152NLin2009cAsym, MNI152NLin2009cSym, MNI152NLin6Asym, MNI152NLin6Sym, MNIInfant, MNIPediatricAsym, NKI, OASIS30ANTs, PNC, UNCInfant, WHS, fsLR, fsaverage, test, T1w, T2w, anat, fsnative, func, run, sbref, session

As per the documentation, templates are identified by an alphanumeric label (like the subject label in BIDS, basically). Because - and _ are delimiters in BIDS' (and hence, TemplateFlow's) grammar, the identifier CANNOT contain those characters.

You need to update all your files to something like:

$TEMPLATEFLOW_HOME/
tpl-MNI152NLin2009cAsymPD25/
template_description.json
tpl-MNI152NLin2009cAsymPD25_res-01_T1w.nii.gz
tpl-MNI152NLin2009cAsymPD25_res-01_desc-brain_mask.nii.gz
tpl-MNI152NLin2009cAsymPD25_res-02_T1w.nii.gz
tpl-MNI152NLin2009cAsymPD25_res-02_desc-brain_mask.nii.gz

Then, you should be able to use the identifier MNI152NLin2009cAsymPD25 on your --output-spaces argument.

ly6ustc commented 3 years ago

I think the docker's container didn't find the correct path of templateflow. What should I do?

What makes you think that?

Let's re-read the error slowly:

ValueError: space identifier "MNI152NLin2009cAsym_PD25" is invalid.
Valid identifiers are: Fischer344, ILABSInfant, MNI152Lin, MNI152NLin2009cAsym, MNI152NLin2009cSym, MNI152NLin6Asym, MNI152NLin6Sym, MNIInfant, MNIPediatricAsym, NKI, OASIS30ANTs, PNC, UNCInfant, WHS, fsLR, fsaverage, test, T1w, T2w, anat, fsnative, func, run, sbref, session

As per the documentation, templates are identified by an alphanumeric label (like the subject label in BIDS, basically). Because - and _ are delimiters in BIDS' (and hence, TemplateFlow's) grammar, the identifier CANNOT contain those characters.

You need to update all your files to something like:

$TEMPLATEFLOW_HOME/
tpl-MNI152NLin2009cAsymPD25/
template_description.json
tpl-MNI152NLin2009cAsymPD25_res-01_T1w.nii.gz
tpl-MNI152NLin2009cAsymPD25_res-01_desc-brain_mask.nii.gz
tpl-MNI152NLin2009cAsymPD25_res-02_T1w.nii.gz
tpl-MNI152NLin2009cAsymPD25_res-02_desc-brain_mask.nii.gz

Then, you should be able to use the identifier MNI152NLin2009cAsymPD25 on your --output-spaces argument.

I think the docker's container didn't find the correct path of templateflow. What should I do?

What makes you think that?

Let's re-read the error slowly:

ValueError: space identifier "MNI152NLin2009cAsym_PD25" is invalid.
Valid identifiers are: Fischer344, ILABSInfant, MNI152Lin, MNI152NLin2009cAsym, MNI152NLin2009cSym, MNI152NLin6Asym, MNI152NLin6Sym, MNIInfant, MNIPediatricAsym, NKI, OASIS30ANTs, PNC, UNCInfant, WHS, fsLR, fsaverage, test, T1w, T2w, anat, fsnative, func, run, sbref, session

As per the documentation, templates are identified by an alphanumeric label (like the subject label in BIDS, basically). Because - and _ are delimiters in BIDS' (and hence, TemplateFlow's) grammar, the identifier CANNOT contain those characters.

You need to update all your files to something like:

$TEMPLATEFLOW_HOME/
tpl-MNI152NLin2009cAsymPD25/
template_description.json
tpl-MNI152NLin2009cAsymPD25_res-01_T1w.nii.gz
tpl-MNI152NLin2009cAsymPD25_res-01_desc-brain_mask.nii.gz
tpl-MNI152NLin2009cAsymPD25_res-02_T1w.nii.gz
tpl-MNI152NLin2009cAsymPD25_res-02_desc-brain_mask.nii.gz

Then, you should be able to use the identifier MNI152NLin2009cAsymPD25 on your --output-spaces argument.

Thank you for correcting my mistakes. Now, fmriprep outputs the results in MNI152NLin2009cAsymPD25 space successfully. But when fmriprep was running, I noticed a message : "pandoc-citeproc: reference mni152nlin2009casympd25 not found". Is it okay? I have checked all results, and they looks good. So could I ignore that message? Thanks again!

arianayoum commented 5 months ago

@oesteban Hello, I was following the steps in this thread because I also want to use a custom template, but I am getting a path error: "fmriprep: error: Path does not exist: < >."

My template directory:

tpl_MyCustom/ tpl-colintoOAWarpedfmriprep/ template_description.json tpl-colintoOAWarpedfmriprep_res-01_T1w.nii.gz tpl-colintoOAWarpedfmriprep_res-1_desc_brain_mask.nii.gz

My docker command:

docker run --rm \
    -v /files/bids/data/bids:/data:ro \
    -v /files/fmriprep_preprocessed/tpl_MyCustom/:/home/fmriprep/.cache/templateflow \
    -v /files/fmriprep_preprocessed/temp_output:/out \
    -v /files/freesurfer/license.txt:/opt/freesurfer/license.txt \
    nipreps/fmriprep:23.2.1 \ 
    /data /out participant \
    --skip_bids_validation \
    --participant_label 002 \
    --fs-no-reconall \
    --ignore slicetiming \
    --fd-spike-threshold 0.8 \
    --dvars-spike-threshold 1.8 \
    --output-spaces colintoOAWarpedfmriprep:res-1 \
    --verbose

Could someone direct me as to what's causing this error? Thank you!