Lesion maps & longitudinal pipeline error


I’m currently running fmriprep v 21 and I’m getting the following error:

File “/opt/conda/lib/python3.8/site-packages/traits/base_trait_handler.py”, line 74, in error
raise TraitError(
traits.trait_errors.TraitError: The ‘lesion_mask’ trait of a _SpatialNormalizationInputSpec instance must be a pathlike object or string representing an existing file, but a value of “[’/data/sub-Trac001/ses-post/anat/sub-Trac001_ses-post_run-01_T1w_label-lesion_roi.nii.gz’, ‘/data/sub-Trac001/ses-pre/anat/sub-Trac001_ses-pre_run-01_T1w_label-lesion_roi.nii.gz’]” <class ‘str’> was specified. "

From what I can tell it seems like there’s an issue because I have a separate lesion map for each session (stored in the anat folder of each session). Is there a way to overcome this error, or am I not understanding how the longitudinal processing works? I thought each anatomical session would be processed separately.

Also, what exactly does the longitudinal pipeline do? I was under the impression that it gives additional outputs from FreeSurfer but now I’m curious if that is true.

Thank you!


Please read this documentation: Processing pipeline details — fmriprep version documentation

In particular “Cost function masking during spatial normalization” and “Longitudinal processing” sections will relate to your questions.

Also, if you search previous topics with the magnifying glasses icon on this website, you will find that others have also asked about fmriprep lesion masks and longitudinal settings. You may find that someone has already answered your question.


Hi Steven,

From what I gather, there are advantages to using the longitudinal pipeline if interested in longitudinal analysis of brain morphology, which our lab is. However, the prior discussions on the issue with multiple lesion maps at different timepoints doesn’t seem to have been visited since 2019, and the conclusion from that thread is for a different situation where there is not expected to be significant differences between timepoints (https://github.com/nipreps/smriprep/issues/58).

Our data does have multiple timepoints with multiple lesion maps where we do anticipate significant differences in the lesion maps and T1s between sessions (patients with progressing multiple sclerosis). If there’s been no further development, it seems we are forced to choose between using the lesion maps and using the longitudinal flag. Is that your impression as well?


I am no expert on lesion studies, but in relation to the T1, it is more of a question of how comfortable you are putting all T1s in the same space. The longitudinal flag still outputs a single image that is used for the T1 template, but what changes is how it is estimated. The longitudinal flag enables an unbiased estimate that is more computationally demanding than what usually happens (aligning to first T1). So it depends on “how longitudinal” your data are. Is this between child and adult? Then probably not ideal to try to create a single template from that. Does your clinical condition create considerable brain anatomical differences across time points (such that an estimate using them wouldn’t be appropriate for either time point)? Probably not ideal then either. If you need to take a session-specific approach, you can use --bids-filter-files to process time points individually, and you may want run freesurfer on each individual T1 to, and point the session-specific recon-all outputs into fmriprep via fs-subjects-dir argument.