Skip to content

SPM8 custom PET template creation script

by manuel on December 20th, 2014

Download script here.

If you want to make your own SPM8 custom PET template to do PET normalization (for example with 18F-FDG)  and are looking for a script that does this with one command, today is your lucky day!  After some googling around and reading through different instructions, I decided to write my own batch script. It is mostly based on a post by Alexander Hammers from June 18 2009 in the SPM mail group.

All you need is a bunch of normal PET images (at least 10, the more the better) with the corresponding MRI images. I ended up using some patients too, since I didn’t have enough normal PET+MRI images.

First, put the mktemplate.m script in your Matlab folder. Change the location of the spm8 folder on lines 45-47 to match your settings.

Rename PET images to PET_$.nii, and MRI images to MRI_$.nii, where $ is the patient ID (like PET_001.nii and MRI_001.nii). Put all images in one folder. Navigate to that folder in Matlab and just type mktemplate. 😉

The script will search for all MRI_*.nii files in the folder and assume corresponding PET_*.nii files. For each pair it will run:
1. coregistration of PET onto MRI
2. segmenation of MRI (we are only interested in the sn.mat file containing the variables used to transform the MRI into standart MNI space)
3. normalization of PET image using the sn.mat file generated above

After that, it will create a soft mean of all the PET images (8bit UINT) and smooth the result with a 8mm FWHW.

The result is a file called s08customPET.img/hdr. Just move it to the spm8 templates folder and rename it. I used MRIcron to transform it to .nii so it’s like the other template files.


Hope this helps and please post comments if any questions!

From → Image Processing

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS