Can fMRIPrep use session specific freesurfer output to preprocess multiple sessions per subject?

I posted in another thread but I did not clearly state my initial issue, and the thread got off track. I am posting again with hopes of some clarification regarding using pre-run Freesurfer outputs from multiple sessions in fMRIPrep.

The Study:

  • We are conducting a multiple session study (two timepoints), and expecting GM change and functional change between each subject’s sessions.

The Data:

  • We have pre-run Freesurfer for each subject’s session, processed cross-sectionally (i.e. not using Freesurfer longitudinal pipeline).

The Desired behavior:

  • We would like to use our pre-run and QC’d Freesurfer output at each subject’s session to separately process fMRI data at each subject’s related session.
  • That is, we want each session’s fMRIPrep functional pre-processing to use the corresponding pre-run QC’d Freesurfer output.
  • For example,
    • Subject 1: FS Session 1 for fMRIprep Session 1; FS Session 2 for fMRIPres Session 2.
    • Subject 2: FS Session 1 for fMRIprep Session 1; FS Session 2 for fMRIPres Session 2.

The problem:

  • When placing pre-run Freesurfer outputs in /out/freesurfer/sub-1 we can only place one session’s pre-run Freesurfer outputs.
  • This is because Freesurfer’s outputs (folder names: label, mri, scripts, stats, surf, tmp, touch, trash) are the same for each session.
  • So, when I copy those outputs into /out/freesurfer/sub-999 there is a duplicate naming issue.

The question:

  • Does fMRIPrep allow for the use of two separate Freesurfer inputs for a single participant?
  • I have tried splitting the freesurfer folder (/out/freesurfer/sub-999) into sessions (/sub-1/ses-1 and /sub-1/ses-2) according to BIDS, but that caused an error.

Any help would be much appreciated.

1 Like

Hello, I have the very same problem. Did you find an answer to this problem atersakyan ?

Fmriprep expects Freesurfer folder to contain one folder per subject. So you can have one folder called FS_ses1, for example, and put all ses1 FS outputs there. Do the same with FS_ses2. Then you can specify the session you want to run with a bids filter file, and specify where you want fmriprep to look for FS outputs (fs-subjects-dir).

Hope this helps,
Steven

1 Like

Hi @Steven - I have the same question as the OP. I’m processing the NKI RS dataset session-wise through fastsurfer (a DL implementation of freesurfer; the outputs dir structure is exactly like freesurfer) and then I’d like fmriprep to use the pre-computed fastsurfer outputs for the a given session. I’m considering doing what you’ve suggested above but I want to make sure I understand the proposed workflow correctly.

  1. Run Freesurfer on every session within a subject and organize the outputs as
fastsurfer/
└── sub-A00079302
    β”œβ”€β”€ ses-BAS1
    β”‚   β”œβ”€β”€ label
    β”‚   β”œβ”€β”€ mri
    β”‚   β”œβ”€β”€ scripts
    β”‚   β”œβ”€β”€ stats
    β”‚   β”œβ”€β”€ surf
    β”‚   β”œβ”€β”€ tmp
    β”‚   β”œβ”€β”€ touch
    β”‚   └── trash
    └── ses-FLU1
        β”œβ”€β”€ label
        β”œβ”€β”€ mri
        β”œβ”€β”€ scripts
        β”œβ”€β”€ stats
        β”œβ”€β”€ surf
        β”œβ”€β”€ tmp
        β”œβ”€β”€ touch
        └── trash
  1. Run fmriprep with the following flags:
    1. --fs-subjects-dir with path to fastsurfer/ directory (as in above)
    2. --bids-filter-file that points to JSON file like below:
      {
         "t1w": {
           "datatype": "anat",
           "session": "BAS1",
           "acquisition": null,
           "suffix": "T1w"
           },
       "bold": {
          "datatype": "func",
          "session": "BAS1",
          "suffix": "bold"
           }
      }
      

Since the dataset has a maximum of 4 sessions so I’ll need four different bids filter files in total. Am I understanding the suggested workflow correctly?

Thanks in advance!
Best,
Arsh

Hi @Arsh,

No, that would not work. fMRIprep expects outputs to be in folders as SUBJECTS_DIR/sub-xx/. It does not expect session organized freesurfer inputs and will not look in them. What you would need to do is something like

fastsurfer/
└── ses-BAS1
    β”œβ”€β”€ sub-A00079302
    β”‚   β”œβ”€β”€ label
    β”‚   β”œβ”€β”€ mri
    β”‚   β”œβ”€β”€ ...
    β”œβ”€β”€ sub-XX
    β”‚   β”œβ”€β”€ label
    β”‚   β”œβ”€β”€ mri
    β”‚   β”œβ”€β”€ ...
└── ses-BAS2
    β”œβ”€β”€ sub-A00079302
    β”‚   β”œβ”€β”€ label
    β”‚   β”œβ”€β”€ mri
    β”‚   β”œβ”€β”€ ...
    β”œβ”€β”€ sub-XX
    β”‚   β”œβ”€β”€ label
    β”‚   β”œβ”€β”€ mri
    β”‚   β”œβ”€β”€ ...

and then in your fmriprep command set the --fs-subjects-dir to /path/to/fastsurfer/ses-XX.

You are correct about the filter file though. Hope it works for you!

Best,
Steven

Thanks for the quick response @Steven that clarifies things a great deal!! I’ll try it out.

A couple follow up questions: Would processing subjects with multiple sessions β€œcross-sectionally” cause within subject registration inconsistencies? Or would all sessions be registered to a default template? If so, what’s the default template used for registration?

Thank you!
Arsh

Hi @Arsh,

Default is MNI152NLin2009cAsym and you can specify other with the --output-spaces argument.

There may be inconsistencies based on the quality of T1s at each time point and time between them (i.e., if sessions were separated by years, during which there could be plausible brain change).

Best,
Steven

A new functionality for session specific preprocessing should be coming soon in fmriprep future releases: Enable longitudinal structural analysis Β· Issue #3133 Β· nipreps/fmriprep Β· GitHub

Thank you @Steven and @jsein ! I’ll keep an eye on the linked issue.