Print

Print


Hi Amir,

> I noticed that when I pad the image using this code or if I change the 
> resolution, the image origin will be changed. In changing resolution 
> case, the actual image size in mm changes as well.

Perhaps I'm confused, but I think these things must happen, in order 
for the image to remain correctly positioned in world-space.

> For instance, if the input image size is 179x233x163 and the origin is 
> at 92.0,95.0,61.0 (spacing 1x1x1), by applying the padding of [-77/2 
> -23/2 0;77/2 23/2 0]+world_bb(), the size is changed to 256x256x164 and 
> the center is changed to 131.0,107.0,61.0.

This "origin" is the voxel location of the world-space origin (0,0,0), 
since the number of voxels change (this is the padding you want, 
right?) the voxel indices for this location must change in order for 
the world origin to be in the same (world/anatomical) position.

If you view the original Image, and the resized rImage, in SPM's check 
reg, you should find they are anatomically registered -- I don't think 
this can be achieved with what you want here:

> Is there anyway to keep the origin and size the same as its original 
> version? Thanks a lot.

Perhaps you could clarify exactly the behaviour you are looking for?

Best,
Ged.