Fmriprep > 1 lesion



Hi all,

Thanks for making such wonderful tools for neuroimaging analysis–it makes all ofour lives so much easier :slight_smile:

The workflow page for fmriprep ( says that a lesion mask will be used for ANTs registration. How does fmriprep handle individuals who may have more than 1 lesion mask? Should the lesion masks be added together and then binarized?



Hi Kito,

According to the documentation,

Lesion masks should be binary NIfTI images (damaged areas = 1, everywhere else = 0) in the same space and resolution as the T1 image, and follow the naming convention specified in BIDS Extension Proposal 3: Common Derivatives (e.g. sub-001_T1w_label-lesion_roi.nii.gz).

As you’ve stated, putting them together in one map and binarizing sounds like a good solution.



Got it - thanks Jon!


Hi Jon,

I tried to run fmriprep with and without the lesion included in my “anat” directory labeled as “sub-01_T1w_label-lesion_roi.nii.gz”. I used the same command for both, and when I run it excluding the lesion, all of the output files are in the correct place, and I get a sub-01 html output as well, but when I include the lesion file, I only get the following outputs:

├── logs
│   ├── CITATION.html
│   ├──
│   └── CITATION.tex
└── sub-01
    └── anat
        ├── sub-01_T1w_brainmask.nii.gz
        ├── sub-01_T1w_label-aparcaseg_roi.nii.gz
        ├── sub-01_T1w_label-aseg_roi.nii.gz
        ├── sub-01_T1w_preproc.nii.gz
        ├── sub-01_T1w_space-orig_target-T1w_affine.txt
        └── sub-01_T1w_target-fsnative_affine.txt

And here are the last few lines out the log (with the lesion):

  [Node] Finished "fmriprep_wf.single_subject_01_wf.func_preproc_task_AO_run_03_wf.bold_reg_wf.bbreg_wf.bbregister".
180807-00:42:15,244 nipype.workflow INFO:
 [Node] Finished "_midthickness1".
180807-00:42:21,882 nipype.workflow INFO:
 [Node] Finished "_midthickness0".

Should I not be running the same command when including a lesion file? I was under the impression that it would include the lesion mask for registration as long as the lesion was in BIDS compatible format…



Hi @kito,

Is the command finishing when you see _midthickness0 as the final line of the log? It may be that the normalization step is taking longer than usual with the lesion ROI. (@danlurie may have an estimate of how long to expect a normalization to take.)



Thanks for your response Chris!

Hmm I’m running it on a remote/screen, but I tried using the $? command and it returned 1, so I’m guessing the command didn’t finish… (Do you think I just need to wait longer?)


If you have a prompt, then it stopped, and you should see more of an error message. You can try re-running, if you’ve lost your logs; it should pick up where it left off and print full error logs. Errors should also show up in the report.


Hi Chris,

So I re-ran the same command again, but it actually doesn’t produce any error messages but gives me a prompt. It also doesn’t produce a report. (I’m rerunning again now to get the log piped into a text file so I can send that over when it’s done).

I can also send over my test case if that would be helpful.



Sure. I can see if I can reproduce.



Here’s the link to the (1) subject data I was trying to run

and I was running with this command:

docker run -ti --rm -v /home/kito/Learning/fmriprep/bids_compatible/LHS_data:/data:ro -v /home/kito/Learning/fmriprep/fmriprep_AON_LHS/:/out -v /home/kito/.licenses/freesurfer/license.txt:/opt/freesurfer/license.txt poldracklab/fmriprep:latest /data /out/out participant


Your sub-01_T1w_label-lesion_roi.nii.gz is actually an uncompressed NIfTI. That’s going to cause problems. You can fix this with:

mv sub-01_T1w_label-lesion_roi.nii.gz sub-01_T1w_label-lesion_roi.nii
gzip sub-01_T1w_label-lesion_roi.nii

That may not be the only issue, so I’ll fix this on my end, as well, and run fmriprep. (I’ll be using the latest, version 1.1.4.)


Lesion images are assumed to be the same size and orientation as the T1w image. Here you have a 256x208x256 T1w image and a 254x208x154 lesion image.

$ nib-ls sub-01_T1w.nii.gz sub-01_T1w_label-lesion_roi.nii 
sub-01_T1w.nii.gz               int16 [256, 208, 256] 1.00x1.00x1.00
sub-01_T1w_label-lesion_roi.nii uint8 [254, 208, 154] 1.00x1.00x1.00


Ah - yes. Thank you for catching that!

I tried re-running it with the corrected lesion file, and it runs all the way through without errors… though when I look at the results side by side with the one ran without the lesion mask, it seems to look the same, and the output html/methods sections were identical.

I will try re-running it both ways again with a brain with a larger lesion.