Howto get imageDirections from a ROI?

I want to create a volume from a ROI:

nodeName = "MyNewVolume"
imageSize = list(map(int, dim))  # the size of the ROI
voxelType=vtk.VTK_UNSIGNED_CHAR
imageOrigin = cn[0] # the origin of the ROI
imageSpacing = [1.0, 1.0, 1.0]
imageDirections = drts # the drts is directs of the ROI
fillVoxelValue = 0

# Create an empty image volume, filled with fillVoxelValue
imageData = vtk.vtkImageData()
imageData.SetDimensions(imageSize)
imageData.AllocateScalars(voxelType, 1)
imageData.GetPointData().GetScalars().Fill(fillVoxelValue)
# Create volume node
volumeNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLScalarVolumeNode", nodeName)
volumeNode.SetOrigin(imageOrigin)
volumeNode.SetSpacing(imageSpacing)
volumeNode.SetIJKToRASDirections(imageDirections)
volumeNode.SetAndObserveImageData(imageData)
volumeNode.CreateDefaultDisplayNodes()
volumeNode.CreateDefaultStorageNode()

but I got :point_down::

I guess it’s because of the problem of ‘imageDirections’, so–
Howto get imageDirections from a ROI?

You can get the image axis directions from the top-left 3x3 submatrix of the ObjectToWorldMatrix.