# Transfrom parralel to a line

Operating system: Windows
Slicer version: 5.1.

Hello,

I have to orient a CT image according to two lines. So right now i manually transform-rotate image so that the image is oriented parallel to the first line in axial plane, and then I rotate the sagittal and coronal plane so that it is parallel to the other line.
Is there a way to script-automate this manual procedure: automatic transform-rotate image parallel to these two lines?

Thank you!

Could you please draw a sketch to illustrate how the new coordinate system axis directions are related to your two lines?

What is the clinical application? For example, if you need to compute ACPC transform then you can use the ACPC transform module for that.

It is for a very similar use.
I have a CT scan of lower extremity, where I want to project measurements to a coronal plane. Because lower extremity is usually positioned suboptimaly I need to adjust it to a reference plane: in transversal plane it has to be parallel to bicondlyar line, and sagittal and coronal plane have to be parallel to the mechanical line of the foot (Mikulicz line).
Original and repositioned images:

Reference lines:

From this position I project some other points and lines in the same coronal plane and make measurements in that plane. There could be an easier way to do it, but that’s what I came up with.

Based on these assumptions :

• the two lines need not intersect
• you want to rotate each slice view independently

This code snippet will rotate the Yellow slice view such that the two control points of line L are visible in this slice view :

``````lineNode = slicer.util.getNode("L")
p1 = lineNode.GetNthControlPointPositionWorld(0)
p2 = lineNode.GetNthControlPointPositionWorld(1)
normal = [0.0] * 3
vtk.vtkMath().Cross(p1, p2, normal)
sliceNode = slicer.app.layoutManager().sliceWidget("Yellow").sliceLogic().GetSliceNode()
sliceNode.SetSliceToRASByNTP(normal[0], normal[1], normal[2], p2[0], p2[1], p2[2], p1[0], p1[1], p1[2], 0)
``````

Please note that you may lose Left-Right and/or Inferior-Superior anatomical orientation, this is not predictable.