I just started using Afni. My routine inputs a CT .nii volume and a Nx3 set of voxel (ijk) coordinates to Afni (extracted from the CT from an upstream external software). Afni then transforms them to RAI xyz (mm) coordinates (1st set), then a subroutine generates a 2nd RAI coordinates after some coregistrations inside Afni. I need to generate back voxel coordinates from this 2nd RAI set, since I need to move the set of point coordinates into another software package using a different coordinate system.
So I need to know how Afni transforms the ijk to xyz, and back (xyz to ijk). I tried the black-box version (3dUndump to construct a 3D vol from these points, then 3dmaskdump with -ijk option to get the voxel indices. However, there is a rounding of the voxel coordinates inside afni (fractional voxel coordinates get rounded with loss of precision after the forward and backward transforms. So, I hope to do these transforms the old way, by using the matrix from the CT header and apply some matrix operations. I would need to know:
- How one can retrieve such a 4x4 matrix from the header (3dinfo CT generates a .geom line but not sure of the order if trying to organize the line in a 4x4;
- How is afni internally switching from ijk to xyz, and back (please provide formulas). My CT vol is in RPI orientation, but I can switch to any other with 3dresample -orient if required by these formulas.
Thank you very much, Octavian