Ras coordinates to voxel

Hello,

I am trying to convert a set of RAS coordinates (.fcsv) exported from slicer, into voxel units.

I’m using matmul with the coordinates [X,Y,Z] and the affine from the .nii file header of my registered image…

voxel_coords = [np.round(np.linalg.inv(affine) @ np.array(ras_coord).T) for ras_coord in ras_vals]

The coordinates are correctly spaced and seem to even be on the same plane , but there are misaligning with the original image. Seems to be a translational problem, I’m thinking it has to do with the last row of my affine matrix, or a field of view issue? Or did I miss a step?

Asking for some insight from anyone who has converted ras2voxel before :slight_smile: thanks,

Bart