Hi,
I would like to get a slice of an unwarped image, i.e. in MNI space,
corresponding to a plane of a raw PET image. The PET images have been
processed by SPM (realigned with replications & warped) but I am interested
in the raw PET (neither warped or aligned).
I can extract relevant voxels and transform them but I want to avoid doing
that for the entire image (will take hours!). I can apply inverse
deformations to the templates but I also want to avoid creating a plethora
of new images.
For example:
- Want to register 'spm2/apriori/gray.mnc' to 'pet02.img', in plane z
- 'pet02.img' coregistered to 'pet01.img'
- 'pet*.img' warped to MNI template via 'meanpet01.img'
- created inverse deformation 'iy_meanpet01.img'
%%So Far - from spm_applydef_ui.m ...
V1 = spm_vol('gray.mnc');
VD = spm_vol([repmat(['iy_meanpet01.img' ','],3,1) num2str([1 2 3]')]);
dim =V1.dim(1:3);
Mi = spm_matrix([0 0 z]);
x1 = spm_slice_vol(VD(1),Mi,VD(1).dim(1:2),1);
x2 = spm_slice_vol(VD(2),Mi,VD(1).dim(1:2),1);
x3 = spm_slice_vol(VD(3),Mi,VD(1).dim(1:2),1);
M = inv(V1.mat);
y1 = M(1,1)*x1+M(1,2)*x2+M(1,3)*x3+M(1,4);
y2 = M(2,1)*x1+M(2,2)*x2+M(2,3)*x3+M(2,4);
y3 = M(3,1)*x1+M(3,2)*x2+M(3,3)*x3+M(3,4);
img = spm_sample_vol(V1,y1,y2,y3,1);
%% end
This will output warped slice of 'gray.mnc' corresponding to plane z
of 'pet01.img'.
But how do I get the same corresponding to 'pet02.img'??? If I had
unwarped 'gray.mnc' to 'wgray.img' I could use:
V1 = spm_vol('wgray.img');
V2 = spm_vol('pet02.img');
M1 = V2.mat\V1.mat\Mi;
img= spm_slice_vol(V2,M1,V1.dim(1:2),1);
I'm sure there's a clue in there somewhere, without having to create
unwarped images for every template...
Thanks
Joel
|