0

I apologize and thank you Ori I will have to edit my question since I wasn't so clear. What I try to do is to calculate the new origin for new direction. The images belong to the same patient, same study, T2 and ADC.

import SimpleITK as sitk

imgA.GetDirection()
#Output: (-0.999538415823011, 0.030367178765256148, 0.0008886504859559863, -0.027416885735734243, -0.8890565329641168, -0.45697575114895145, -0.013087003880921242, -0.4567891369632855, 0.8894787086615201)

imgB.GetDirection()
#Output: (-0.9995384158328267, 0.027856498678410543, -0.012123150711662286, -0.02525107640664108, -0.9836508068710097, -0.17830724539872503, -0.016891963021188904, -0.17791881750784957, 0.9839001755539741)

imgA.SetDirection(imgB.GetDirection())

new_origin = ???
imgA.SetOrigin(new_origin)

Let's just take SimpleITK's DicomOrient for example.

import SimpleITK as sitk

ITK_RAS =  sitk.ReadImage('T2.nii.gz')
ITK_RAS.GetOrigin() 
#Output: (189.03330993652344, 222.32667541503906, -19.254230499267578)
ITK_RAS.GetDirection()
#Output: (-0.999538415823011, 0.030367178765256148, 0.0008886504859559863, -0.027416885735734243, -0.8890565329641168, -0.45697575114895145, -0.013087003880921242, -0.4567891369632855, 0.8894787086615201)

Now I will set the orientation at 'LPS'

ITK_LPS = sitk.DicomOrient(ITK_RAS,'LPS')
ITK_RAS.GetOrigin()
#Output:(-198.18648803662407, -143.8383927044643, -206.9871484534283)
ITK_RAS.GetDirection()
#Output: (0.999538415823011, -0.030367178765256148, 0.0008886504859559863, 0.027416885735734243, 0.8890565329641168, -0.45697575114895145, 0.013087003880921242, 0.4567891369632855, 0.8894787086615201)

Since DicomOrient can calculate the new Origin, I believe there is a way to calculate it for any given direction, but I haven't found how? I still try to learn SimpleITK.

HarryKa
  • 1
  • 1
  • I think you need to provide more images and information because I'm having trouble understanding what your desired output would be. What do you mean by not changing the spacing? Draw arrows and/or put text on your image(s) using powerpoint and include that in your question if you need to. Also include imports. – Ori Yarden PhD Jul 28 '23 at 20:59

0 Answers0