Can you explain why you think that it should not be identity?
If it’s because you put it under a transform, then it’s normal, because the volume itself still has identity directions. You can either set the same transform as parent of the other volume, or you can harden the transform, which will “burn” the matrix in the volume directions and then you can use it the way you want. However, we typically simply use the transform hierarchy and the convenience functions to get the transform between objects when necessary.
The above code is identical to the C++ code of CopyOrientation.
So the only place could be wrong is where getting GetIJKToRASDirections and SetIJKToRASDirections.
This creation of a “matrix” caused the unexpected output: a list was created that referred to the same list 3 times. Effectively, the code did this: dirs = [v,v,v].
Instead, you need to provide unique values for all the 3x3 values in the matrix. Probably the simplest is to create it as a numpy array: dirs = np.eye(3).
Values will be overwritten anyway by calling GetIJKToRASDirections, so in this specific example, either np.zeros or np.eye works.
However, since a null-matrix is not a valid direction matrix, it is not good practice to store it in a variable called “direction”, even temporarily. np.eye creates an identity matrix, which is what you want as a default direction matrix; and its syntax is a bit simpler than np.zeros, too.