Porting a transformation from Matlab to Slicer

Operating system: Windows 10
Slicer version: 4.7
Expected behavior: Transformation to match registered and transformed image in Matlab
Actual behavior: Transformation is off

Hi, I am trying to double check the results of image registration (developed in Matlab) by copying the linear transformation matrix into slicer and applying it to the image. However, I do not get the same result. In matlab I use the affine3d() function to apply a homogenous transformation to an image.

I know that there is a difference between coordinate system definitions in Matlab and Slicer (IJK to RAS), but I still can’t seem to match the registration output when trying to compensate for this. What is the correct way of porting matlab affine3d() transformations to slicer?

Slicer works in RAS coordinate system, but transform files are written as LPS, so you need a base transform between them: multiply from left and right by diag([-1,-1,1,1]).
You might also need to invert the matrix, depending on what you need: transform to or from parent.

2 Likes

Thanks, I just realised shortly after posting that the transforms are in LPS, and the above base transform works correctly!

1 Like