Copy 2D Markups Plane for other slices in CTP

Hello, I am trying to annotate my CTP data using Markups Plane. There are a total of 158 slices in my CT data. I want to create Markup Plane in only 1 slice and copy the markup for 3 slices above and 3 slices below of that slice. Is there a way to do that automatically? In that way, I don’t have to draw markup plane 7 times for 7 slices. I can draw just one markup plane and it will be automatically copied to 6 other slices (3 top and 3 below).
I know that I can use 3D ROI to cover multiple slices together. But I need the 2D markup plane for this project.
Please let me know if there is such option in slicer. Also, can I write a code in Python Interactor window to do this?

Normally you would use a 3D ROI for this.

If you really want to have 7 duplicate planes then you can write a short Python code snippet that this. The simplest is to add a keyboard shortcut for this, which calls your function that adds the 6 extra planes.

You can find all the examples that you will need in the script repository. You can get an introduction to Python scripting in 3D Slicer in the PerkLab Slicer Programming tutorial.

You can ask us here if you get stuck at any point.

1 Like

I tried to copy the markup plane control points using “GetNthControlPoint”, but it gives an error saying ‘vtkSlicerMarkupsModuleMRMLPython.vtkMRMLMarkupsPla’ object has no attribute ‘GetNthControlPoint’.
Also i tried using “GetNthFiducialPosition” which gives the same type of error.

Can you kindly help me to copy the control points of markup plane?

FYI, I am using slicer 4.11.20210226 version.

I was able to copy the control points using

p1=[0,0,0] #np.zeros(3)

f = getNode(‘F’) #F is the name of markups plane

f.GetNthControlPointPositionWorld(0, p1)
f.GetNthControlPointPositionWorld(1, p2)
f.GetNthControlPointPositionWorld(2, p3)

But trying to figure out, how to paste the control points using a new markup plane name.

[0,0,0] is an integer array. You must create a vector of floating-point values for example using np.zeros(3) as it is done in all the examples. [0.0, 0.0, 0.0] would work, too, but it is longer and you cannot do numerical array operations on it directly.

You can create a new node using the scene’s AddNewNodeByClass method. See the script repository for examples.

1 Like

Thanks a lot, Lasso. I was able to do what I wanted. But when I use the python interactor window, after closing the slicer app; I have to write the code again to work. Is there a way to save this change?

You can create a Python scripted module from this. See step-by-step instructions in the Slicer Programming tutorials.

1 Like

I did that using JupyterKernel. Thanks.