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
630 stars 292 forks source link

freesurfer fails #2192

Closed bpinsard closed 4 years ago

bpinsard commented 4 years ago

I am experiencing lots of problems with freesurfer in fmriprep. Though it might be a freesurfer issues, I know that the pipeline is a bit modified in fmriprep. Also, I have never seen such disastrous results in the past using freesurfer, in particular with quality data (no motion, .8mm iso). Here is what the aseg looks like before the surface reconstruction crashed with segfault.

image

Other subjects preprocessing completed, but it shows the same problems, others are fine.

Two factors that could play a role here:

Do you have any clue why this fails? I read somewhere that fmriprep had mainly been tested on defaced datasets, but maybe our defacing is breaking the topology of the images (like a watershed step or else).

Would cropping the neck area could help?

Thanks.

What version of fMRIPrep are you using?

20.1.0

What kind of installation are you using? Containers (Singularity, Docker), or "bare-metal"?

singularity

What is the exact command-line you used?

singularity run --cleanenv -B /scratch/bpinsard:/work -B /scratch/bpinsard/templateflow:/templateflow -B /etc/pki:
/etc/pki/ -B /lustre03/project/6003287/datasets/cneuromod_new/anat:/data /lustre03/project/6003287/datasets/cneuro
mod_new/code/ds_prep/containers/fmriprep-20.1.0.simg -w /work --participant-label 04 --anat-only --bids-filter-fil
e /data/.slurm/bids_filters.json --output-spaces MNI152NLin2009cAsym fsLR --cifti-output 91k --skip_bids_validatio
n --mem_mb 16384 /data /data/derivatives/fmriprep-20.1.0 participant

Have you checked that your inputs are BIDS valid?

Yes, it is not, because it relies on BEPS not yet merged, but it is valid for all fmriprep inputs (T1w, T2w, and BOLD).

Did fMRIPrep generate the visual report for this particular subject? If yes, could you share it?

Can you find some traces of the error reported in the visual report (at the bottom) or in crashfiles?

<please copy&paste all the information you can gather about errors>

Are you reusing previously computed results (e.g., FreeSurfer, Anatomical derivatives, work directory of previous run)?

no

fMRIPrep log

If you have access to the output logged by fMRIPrep, please make sure to attach it as a text file to this issue.

bpinsard commented 4 years ago

Looking at the work-dir I found the problem was in brain_extraction_wf/res_tmpl, so it was completely independent of the input image. In fact the problem was the templateflow image being corrupted (truncated). Any other software is unable to open the image, but surprisingly Ants ResampleImageBySpacing is able to open and resample it, with a small portion of the image and a lot of zeros in the rest of the volume.

I will rerun the pipeline and see if it fixes the bug.

oesteban commented 4 years ago

In fact the problem was the templateflow image being corrupted (truncated).

What do you mean? Can you elaborate more?

bpinsard commented 4 years ago

I had pre-downloaded the templates (outside of container, with templateflow package) because the cluster nodes don't have access to the internet. Maybe something went wrong with the download? Like it was interrupted.

Here is what the res_tmpl output looks like with the corrupted input file. Clearly explains why brain extraction failed.

image

Re-downloaded it now, it looks fine.

bpinsard commented 4 years ago

@oesteban do you want me to submit an issue to templateflow? Looking at the code, it seems that it checks if the size is zero to determine if it has been fetched. Would a checksum or a file-size check fix that kind of (super rare) issues? Might not be worth it though.

oesteban commented 4 years ago

Yes, please do file an issue at https://github.com/templateflow/python-client - checksums sound sensible.

bpinsard commented 4 years ago

Closing it now, as this is a templateflow (and Ants) issue. Thanks.