Ah, right. Thanks for bumping this topic. If you would like to use our reference images, then probably the easiest approach is to install
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.