Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. # set values for output image
  2. # image size
  3. imageExtent = (int(extX), int(extY), int(extZ), 1, 1, 1)
  4. outImage.setImageExtent(imageExtent)
  5. # intensity range
  6. outImage.setMinVoxelValue(float(wCenter)-float(wWidth))
  7. outImage.setMaxVoxelValue(float(wCenter)+float(wWidth))
  8. # spacing
  9. outImage.setVoxelSize(int(voxelSpacingXY[0]), int(voxelSpacingXY[1]), int(voxelSpacingZ))
  10. # orientation and spacing
  11. oX = [float(imageOrientationPatient[0]),float(imageOrientationPatient[1]),float(imageOrientationPatient[2])]
  12. oY = [float(imageOrientationPatient[3]),float(imageOrientationPatient[4]),float(imageOrientationPatient[5])]
  13. oZ = cross(oX, oY)
  14. s = matrix([[float(voxelSpacingXY[0]), 0, 0, 0], [0, float(voxelSpacingXY[1]), 0, 0], [0, 0, float(voxelSpacingZ), 0], [0, 0, 0, 1]])
  15. r = matrix([[oX[0],oY[0],oZ[0],0], [oX[1],oY[1],oZ[1], 0], [oX[2],oY[2],oZ[2],0], [0,0,0,1]])
  16. t = matrix([[1., 0, 0, float(imagePositionPatient[0])], [0, 1, 0, float(imagePositionPatient[1])], [0, 0, 1, float(imagePositionPatient[2])], [0, 0, 0, 1]])
  17.  
  18. wm = t * r * s
  19.  
  20. outImage.setVoxelToWorldMatrix(wm)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement