Export single MPR slice to DICOM

This comment is too long and complicated and so most people will not understand what you mean. Instead, you could change the loop to:

for row in range(4):
            for col in [0, 1]: # invert second axis
                roiTransformMatrix.SetElement(row, col, -1 * roiTransformMatrix.GetElement(row,col))

(If this leads to undesired flip then use [1, 2].)

But even better, if you want simpler, safer code, then you can apply a rotation to the sliceToRas transform (you can replace RotateX by RotateY or RotateZ if you want to rotate along a different axis):

roiTransform = vtk.vtkTransform()
roiTransform.Concatenate(sliceTransformMatrix)
roiTransform.RotateX(180)
roi.SetAndObserveObjectToNodeMatrix(roiTransform.GetMatrix())

As a general rule: in medical imaging the “F word” (flip) is taboo. Always rotate instead, except the very special cases when you actually need to mirror one side of the patient to the other (e.g., correct deformity by mirroring healthy side of the patient to the diseased side).

1 Like