Bad registration of PET images to MRI template?

Summary of what happened:

I am preprocessing some PET data to be used as example data for a computational lab class for undergrads. I inherited some very old partial PET NIFTIs associated with Volkow et al (2009) from a colleague. The PET NIFTIs appear to have been preprocessed in the long past but I have no record of what was done to them.

I have a decent amount of experience working with BOLD fMRI but basically none with PET until this project, heh.

I would like for students to be able to average the subject-specific PET timeseries together for their condition of interest to get one across-subjects timeseries mean. They would then select a seed ROI based on xyz coordinates to use to extract signal and calculate receptor binding potential. In order for images to be averageable across subjects, they must of course be registered to the same template image. An MRI template was provided (no documentation on what image this is, but based on the paper it might be an old SPM anatomical template), so I am trying to register each of the PET timeseries to this MRI template.

I am trying to use ANTs to:

  1. Create a PET template for each PET timeseries by meaning images together (SUCCESSFUL)
  2. Register each scan-specific PET template to the MRI template, apply registration to the timeseries image. I would like to keep it to rigid-body registration if possible, so I have been using type_of_transform=’AffineFast’, but everything else left as default. (ISSUES HERE)

I’ve gotten the code to run all the way through to attempt registrations on every timeseries. A couple of the registrations look all right, but most of them just look awful! Seeking advice on other pre-processing transforms that can be applied, other transform algorithms, or other issues to check to improve the bad registrations.

Screenshots / relevant information:

EXAMPLE OF BAD REGISTRATIONS

Overlay of mean PET template on MRI BEFORE registration. You can see that the affine for the original PET images is very much not in the neighborhood of the MRI template to start, but the mean PET image does at least show some brain-shape that could be registered.

Overlay AFTER registration. Equally bad but different!

Command used (and if a helper script was used, a link to the helper script or the command generated):

import ants

template_img = ants.image_read('MRI_Template.nii')
pet_img = ants.image_read('PET_timeseries.nii')

# mean over timeseries for PET template
mean_img = ants.from_numpy_like(
  data=pet_img.mean(axis=3),
  image=ants.slice_image(pet_img, axis=3, idx=0)
)

# calculate rigid body registration
reg = ants.registration(fixed=template_img, moving=mean_img, type_of_transform='Affine')

# apply registration
pet_warped = ants.apply_transforms(fixed=template_img, moving=pet_img, transformlist=reg['fwdtransforms'], imagetype=3)
mean_warped = ants.apply_transforms(fixed=template_img, moving=mean_img, transformlist=reg['fwdtransforms'])

# this generates the plot screenshots
ants.plot(image=template_img,overlay=mean_warped, overlay_alpha=0.8, overlay_cmap='viridis')

Hey Monica! I also have zero experience with PET haha, and I almost exclusively use ANTs through the bash interface, so this is a real shot in the dark—but I’m wondering how necessary it is to use the provided SPM template? Since it’s not a subject-level T1, I feel like you could probably use any skull-stripped MNI template with a (dilated) brain mask for the fixed image. And since the images are so far out of alignment, it might be good to use ANTs’ affine initialization tool to get things going (you’d feed the result of this into ANTs as the initial moving transform). In my experience, that really helps with challenging registration problems. I also see that antspy has ‘BOLDRigid’ and ‘BOLDAffine’ options which may be better than ‘AffineFast’? I dunno, totally spitballing here, but those would be my immediate suggestions :slight_smile: Hope it’s helpful!

Hi Tyler!! Thanks for your pointers :slight_smile: I experimented some with using the affine initializer before the main registration, but no dice there. HOWEVER, turns out I actually was able to solve the problem another, more doozy-tastic way :woman_facepalming: let this be a warning to all those analyzing old old PET data!

It turns out that the past image registration that had been done on the data made all of the imputed background voxel values outside of the original scan FOV suuuuuuper negative. Like values of -50 and such. I didn’t notice them at first but you can actually see in the overlay check images above, that’s why the entire main PET scan area looks so bright, it’s because the extra imputed background outside the original FOV is suuuuuuper dark. I went into the underlying array data of the PET scans and truncated all negative voxel values at 0, and then re-ran the original registration procedure on the truncated images.

pet_img = ants.image_read(os.path.join(root, file))

pet_numpy = pet_img.numpy()
pet_numpy[pet_numpy < 0] = 0
pet_zeroed = ants.from_numpy_like(
  data=pet_numpy,
  image=pet_img
)

# use pet_zeroed instead of pet_img going forward

Ta-da!!! they all look much better, and the colormap also looks much more sensible to boot. Good reminder to put colorbars with units on all of my diagnostic plots lol.