Fmriprep processing of BOLD nii using T1w nii from another specific session

Summary of what happened:

I am using fmriprep 25.2.2 to process a longitudinal functional MRI dataset with annual MRI sessions. I am specifically using fmriprep v25.2.2 for the “–subject-anatomical-reference sessionwise” flag, as some of these participants had neurosurgery after their first MRI session.

For this project, MRI data was reviewed for quality after each session: participants returned within a week to repeat “bad” scans (and only “bad” scans; good scans were not repeated). So if a participant returned to repeat only a T1w image, their bids directory will look like this:
sub-001/
|–ses-01/
| |–func/
| |–sub-001_ses-01_bold.nii
|–ses-01-repeat/
| |–anat/
| |–sub-001_ses-01-repeat_T1w.nii
|–ses-02/
|–anat/
| |–sub-001_ses-02_T1w.nii
|–func/
|–sub-001_ses-02_bold.nii

For these participants, how can I instruct fmriprep to use “sub-001_ses-01-repeat_T1w.nii” for processing of “sub-00_ses-01_bold.nii” while still using the “–subject-anatomical-reference sessionwise” flag? Alternatively, if there is no good solution and I have to merge ses-01 and ses-01-repeat, what is the best practice for documenting this merger of sessions within the bids format?

Hi @AndyJames and welcome to neurostars!

You cannot have dashes in your session name, so ses-01-repeat is not a valid name.

You have options. First would be to merge the sessions into one folder. This may not be the most bids valid because you would be combining images that are acquired weeks apart. In this case you can use something like an acq-<> label to differentiate images kept and discarded. Then use a BIDS filter file to say to only consider the one with the label that you keep. Or simply delete the images if you know they won’t be used for anything.

The second would be to not use the subject sessionwise anatomical option, and instead use session-wise bids filter files that would allow consideration of original and repeated session folders for a given session number.

Best,
Steven