fMRIPrep coregistration within sessions?

Hi all,

I have a dataset with two fMRI sessions collected several hours apart. Each session contains multiple runs. From my understanding, fmriprep registers all bold files from all runs and sessions to the same T1 (which in this case was collected only in the first session). I’m wondering if it’s possible to first register the bold images within session, before registering to the T1? I would like to use RSA to compare activity from the first to the second session, so it’s important that they are well-aligned.


1 Like

Hi @cpauley, this isn’t currently possible.

You could hack around it by creating a fake sbref file for each BOLD series that will preempt our attempt to create a series-specific reference image. If you provide the same sbref for each BOLD series in a session, then that should achieve the goal you’re aiming at.

Hi @effigies,

How would you recommend creating this fake sbref file? The data was acquired using a multiband sequence.


I am also interested in this. If @effigies or @oesteban could suggest how to create this fake sbref file that would be highly appreciated.

Ah, right. Thanks for bumping this topic. If you would like to use our reference images, then probably the easiest approach is to install niworkflows:

pip install niworkflows

This will also install nipype, which will provide nipypecli, which we can use to run the tool that estimates reference images:

nipypecli run niworkflows.interfaces.registration EstimateReferenceImage /path/to/bold.nii.gz

You’ll get output like the following:

200203-11:21:53,787 nipype.utils INFO:
	 No new version available.
setting function inputs

in_file = /path/to/bold.nii.gz
mc_method = AFNI
sbref_file = <undefined>

n_volumes_to_discard = 1
ref_image = <pwd>/ref_bold.nii.gz

That last line shows you where the reference image was saved. You’ll probably want to save it to a new name that references the run it came from, so you don’t lose track.

Once you have a list of those, I would inspect each to make sure it looks reasonable, discard any that you don’t like, and construct a template with mri_robust_template (from FreeSurfer):

mri_robust_template --mov ref1.nii.gz ref2.nii.gz ... \
    --template ref.nii.gz --satit

You can use any other tool you like, but mri_robust_template has nice properties of discounting outlier voxels and constructing a template that’s approximately equidistant from each of the inputs, to reduce bias.

The result can now be copied to your BIDS directory as sub-XX/ses-YY/sub-XX_ses-YY_task-TASK_run-Z_sbref.nii.gz. You’ll need a copy for each BOLD file that you want to be registered using that as the reference.

Note that this may be sensitive to large changes in head position between runs. sbrefs are typically acquired immediately before a multiband run, so the offset should be minimal, and our head-motion-correction algorithms may assume that.

Note also that fMRIPrep will not know about this hack, and you’ll need to adjust any methods reporting to cover this. If you’re going to share your data, I would also suggest that you share these derived images and a script to produce them in your <bids-root>/derivatives directory, so that others can reproduce your work.