fMRIPrep: how to reuse longitudinal AND pre-run FreeSurfer



Regarding using pre-run freesurfer outputs. I have succesfully done so when each ‘sub’ has only 1 session. However, I am trying to place Freesurfer outputs for session two now (in /fmriprep/out/freesurfer), but since the folders there are organized by ‘sub’ level I can’t place another folder for session two with the same name. How should I include 2 timepoints/sessions of pre-run Freesurfer data? Can the Freesurfer ‘sub’ folders also contain ‘ses’ subfolders?


1 Like
Multiple scan sessions some bad anatomicals

I tried placing the pre-run FS files in these sub-folders:


but that resulted in error. fMRIPrep finished without proper func outputs. I don’t fully understand the error, but it seems it may have to do with FS. Any help would be appreciated, thank you.


@oesteban How do you recommend treating each session as a different participant from BIDS format of /sub/ses (each of my participants have 2 sessions). Or is it already treated as different participants when separated like that?


Can you give me more context? Is your problem exactly the same posted on top?


@oesteban not exactly the same. But I have 2 sessions per participant. I don’t expect any significant anatomical differences between time-points (~3 weeks). How should I treat each session? You mentioned treating as individual participants-- does that mean I have to do something different when running fmriprep/organizing folders?

Also, I have pre-run freesurfer for each of the sessions, how should I organize these in the out/freesurfer/sub-xxx folders before running fmriprep? I’m not sure how to incorporate 2 sessions in the freesurfer folders. Or do I only need 1 of the sessions in there?

Thanks for the help.


Just do not set the --longitudinal argument nor split them into different subjects.

In general, fMRIPrep will run the averaging of the 2 T1w images on its own. You may want to re-run freesurfer via fMRIPrep. If not, it should just work.


Ok, thanks. We want to use our pre-run freesurfer since it’s been QC’d and run through our pipeline. However, I still don’t understand how to incorporate 2 sessions of freesurfer data into the fMRIPrep /out/freesurfer/sub folders. For example, if I create a folder for sub-123 in that fMRIPrep directory/folder, I can only put in one set of pre-run freesurfer outputs (i.e. label, mri, scripts, stats, surt, tmp, touch, trash). When pasting in more than one I get issues with duplicate names. I tried to work around this by creating one more layer of folders (ses-1a, ses-2a), but this caused errors when running fMRIPrep.

Thank you for the help as we would prefer to use our pre-run freesurfer from both sessions before running fMRIPrep.


Here there are some tips to run fMRIPrep reusing a FreeSurfer folder:


I’m not sure to what extent they are applicable to the current version of fmriprep, but here are some relevant github threads. Fmriprep will fuse and conform across sessions for raw data, so presumably it would not support multi-session freesurfer outputs. effigies suggested using --session-label option to run separately for each session, but at the time of writing that was not supported (and it may still not be).

1 Like

Hello again,

@AnonymousBoba, thank you for those links.

@oesteban, thank you for sharing you slides on fMRIPrep. Just a few clarification questions regarding the workflow in general, and the use of FreeSurfer.

Our study has two scan sessions, each with its own T1 and subsequent FreeSurfer processed data. We are examining change across time in our specific patient population and expect morphological changes between scan sessions. Therefore, we want to use QC’d FreeSurfer outputs for each session’s T1 in fMRIP prep and separately process fMRI data for each session.

For example,
• Scan session 1: we need to use scan session 1 T1/FreeSurfer for scan session 1 fMRIPrep Processing.
• Scan session 2: we need to use scan session 2 T1/FreeSurfer for scan session 2 fMRIPrep Processing.

However, our BIDS formatting treats each subject as one subject, with separate scan sessions for each session. Given this file structure, I don’t see a way to split FreeSurfer sub directories in fMRIPrep to use separate T1/FreeSurfer data from each session for processing each session fMRI data.

For example, here: > B:\InProcess\3T\NABM\fMRI\BIDS\derivatives\fmriprep-1.3.2\out\freesurfer\sub-123

In the folder structure above, I am unable to place two sessions of pre-run FreeSurfer outputs (i.e. surf, mri, label, etc…) because both session’s folders have the same names (i.e. surf, mri, label, etc…).

So, I tried doing something like this, but it did not work:


Is there any way I can ensure each fMRI session uses its session specific pre-run FreeSurfer outputs?

Or is the only alternative to change our naming system in my BIDS script that treats each session as a new subject, for example, something like \sub-1231a and \sub1232a

We would prefer not to have to change our BIDS naming structure in order to use separate T1/FreeSurfer output for each of our sessions. If there is any way to do this without having to take that step, please let us know. I have not been able to find much about this specific issue.

Thank you for the help!


Hello again,

Does anyone have experience with this? Any help would be appreciated as I am stuck.

Also, I was wondering how fMRIPrep treats two sessions in terms of FreeSurfer/ registering fmri to anatomicals. When calling FreeSurfer (i.e. no pre-run FreeSurfer inputs) within fMRIPrep, does fMRIPrep use each session’s anatomical/FreeSurfer for its respective fmri masks and preprocessing? Or does it just use one session’s FreeSurfer mask for both sessions of fmri?

My next step would be to rename each subj/ses to be its own subj in BIDS. So subject 123 session 1 would be sub-1231 and subject 123 session 2 would be sub-1232



Hi @atersakyan,

If I understand correctly, you have pre-run FreeSurfer results calculated in longitudinal mode. However, you do not expect to see substantial anatomical differences between timepoints (i.e., it is not a developing sample, nor timepoints are far apart in time, nor it is a clinical population developing disease paths). And you want to reuse them with fMRIPrep. These would be my comments:

  1. At this point, fMRIPrep is unable to take longitudinal FS runs. We welcome contributions to make that possible.

  2. That leaves you with only two options:
    a. You can feed fMRIPrep with only one of those sessions (which you have successfully achieved before).
    b. You can re-run FS. You will need to go through the computational cost, but the turnaround may be worthy: fMRIPrep will average all the T1w images you have (and pull T2w in if there are some) resulting in a less noisy anatomical target for brain extraction, spatial normalization and FS’ surface reconstruction. This could be beneficial as your samples are not expected to change between timepoints.

  3. Make sure your pre-run FS is done with version >6.0.0.

  4. I believe the trick of unfolding sessions as new subjects does not apply to your case.

EDIT: further discussion here -

1 Like

Hi @oesteban,

Sorry for the confusion-- I did not process my data using FreeSurfer’s longitudinal mode. Each timepoint (session) was processed using FreeSurfer’s regular/cross-sectional processing. Thus, I have full separate outputs from FreeSurfer for each session (2 sessions). Furthermore, we do expect to see small anatomical change between timepoints. Ultimately, we are interested in observing within subject change over time (and within group change over time).

The problem is that we can’t figure out how to incorporate multiple/separate pre-run FreeSurfer sessions for one subject. I tried to solve by creating two separate sessions under the subject level, but this caused an error-- screenshot above.

Is there a way to structure multiple sessions per subject so we can use different FreeSurfer data for functional preprocessing at each timepoint? I realize most groups would just use one timepoint’s FreeSurfer for both timepoints’ fmri preprocessing, but we would like to use each timepoint’s FreeSurfer outputs for the respective fmri preprocessing (i.e. session 1 FS with session 1 fmri data). Is this possible in fMRIPrep?

Thank you for the help. Please let me know if you need more information/screenshots.

1 Like

@oesteban Feel free to split this off to a separate issue but I do have a question related to this. You and I have discussed this at length in terms of re-using pre-run FS, particularly for longitudinal analyses.

What is the difference between what fMRIPrep is doing to average the T1s and running FS vs. the subject-specific template step of running longitudinal FS? The values appear to be slightly different but could the same approach for re-using fMRIPrep’s FS (here: FMRIPREP confounds error (copied columns for multiple subjects)) be applied to the subject-specific templates?