# Copy 2D Markups Plane for other slices in CTP

**URL:** <https://discourse.slicer.org/t/copy-2d-markups-plane-for-other-slices-in-ctp/18770>\
**Category:** Support\
**Tags:** annotations\
**Created:** [July 16, 2021, 6:01pm UTC](https://discourse.slicer.org/t/copy-2d-markups-plane-for-other-slices-in-ctp/18770 "2021-07-16T18:01:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dhruba](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@Dhruba](https://discourse.slicer.org/u/Dhruba)\
**Post date:** [July 16, 2021, 6:01pm UTC](https://discourse.slicer.org/t/copy-2d-markups-plane-for-other-slices-in-ctp/18770/1 "2021-07-16T18:01:47Z")

</div>

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?

 ![Capture1](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/7/67094291a908b97202ca7ad9247ef415d34c4a46.png)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 16, 2021, 8:42pm UTC](https://discourse.slicer.org/t/copy-2d-markups-plane-for-other-slices-in-ctp/18770/2 "2021-07-16T20:42:29Z")

</div>

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](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html). You can get an [introduction to Python scripting in 3D Slicer in the PerkLab Slicer Programming tutorial](https://slicer.readthedocs.io/en/latest/developer_guide/api.html#tutorials).

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

---

<div class="post-metadata">

**Author:** ![Dhruba](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@Dhruba](https://discourse.slicer.org/u/Dhruba)\
**Post date:** [July 18, 2021, 5:04pm UTC](https://discourse.slicer.org/t/copy-2d-markups-plane-for-other-slices-in-ctp/18770/3 "2021-07-18T17:04:25Z")

</div>

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.

 ![1](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/4/64902c3e1a7c17eadf45da88074f4ff2a508595b.png)

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

---

<div class="post-metadata">

**Author:** ![Dhruba](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@Dhruba](https://discourse.slicer.org/u/Dhruba)\
**Post date:** [July 18, 2021, 5:27pm UTC](https://discourse.slicer.org/t/copy-2d-markups-plane-for-other-slices-in-ctp/18770/4 "2021-07-18T17:27:38Z")

</div>

FYI, I am using slicer 4.11.20210226 version.

---

<div class="post-metadata">

**Author:** ![Dhruba](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@Dhruba](https://discourse.slicer.org/u/Dhruba)\
**Post date:** [July 18, 2021, 5:57pm UTC](https://discourse.slicer.org/t/copy-2d-markups-plane-for-other-slices-in-ctp/18770/5 "2021-07-18T17:57:33Z")

</div>

I was able to copy the control points using

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

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.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 18, 2021, 6:56pm UTC](https://discourse.slicer.org/t/copy-2d-markups-plane-for-other-slices-in-ctp/18770/6 "2021-07-18T18:56:12Z")

</div>

`[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.

---

<div class="post-metadata">

**Author:** ![Dhruba](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@Dhruba](https://discourse.slicer.org/u/Dhruba)\
**Post date:** [July 18, 2021, 8:45pm UTC](https://discourse.slicer.org/t/copy-2d-markups-plane-for-other-slices-in-ctp/18770/7 "2021-07-18T20:45:23Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 19, 2021, 11:55am UTC](https://discourse.slicer.org/t/copy-2d-markups-plane-for-other-slices-in-ctp/18770/8 "2021-07-19T11:55:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dhruba](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@Dhruba](https://discourse.slicer.org/u/Dhruba)\
**Post date:** [July 19, 2021, 6:33pm UTC](https://discourse.slicer.org/t/copy-2d-markups-plane-for-other-slices-in-ctp/18770/9 "2021-07-19T18:33:23Z")

</div>

I did that using JupyterKernel. Thanks.
