# Rotation in DICOM data

**URL:** https://discourse.slicer.org/t/rotation-in-dicom-data/9693
**Category:** Support
**Created:** [January 2, 2020, 7:43pm UTC](https://discourse.slicer.org/t/rotation-in-dicom-data/9693 "2020-01-02T19:43:10Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![OJay](https://avatars.discourse-cdn.com/v4/letter/o/c5a1d2/32.png) [@OJay](https://discourse.slicer.org/u/OJay)
#### Post date: [January 2, 2020, 7:43pm UTC](https://discourse.slicer.org/t/rotation-in-dicom-data/9693/1 "2020-01-02T19:43:10Z")

</div>

Hi:)  
Is it possible to set in DICOM data two points to get a line and then rotate around this line?  
Best Regards,  
Ole

---

<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: [January 3, 2020, 1:30pm UTC](https://discourse.slicer.org/t/rotation-in-dicom-data/9693/2 "2020-01-03T13:30:05Z")

</div>

If you need to rotate slice views (for example, to explore structures around a tool trajectory): you can install SlicerIGT extension and use Volume reslice driver or PathExplorer modules. These modules are not trivial to use, so if you need help with then let us know.

If you need to rotate images or structures (change their physical orientation): you can follow [these instructions](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Rotate_a_node_around_a_specified_line). You can [put the code snippet into a scripted module](https://www.slicer.org/wiki/Documentation/Nightly/Training#PerkLab.27s_Slicer_bootcamp_training_materials) to make it more user-friendly (to not require typing and copy/pasting into the Python console).

---

<div class="post-metadata">

### Author: ![OJay](https://avatars.discourse-cdn.com/v4/letter/o/c5a1d2/32.png) [@OJay](https://discourse.slicer.org/u/OJay)
#### Post date: [January 7, 2020, 1:37pm UTC](https://discourse.slicer.org/t/rotation-in-dicom-data/9693/3 "2020-01-07T13:37:12Z")

</div>

Thank you very much for you information… i try a little bit its not so easy 😉

again one question… where i found a Surface Registration?  
I will merge a STL model on a cbct data set…

Thank you in advance,  
Ole

---

<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: [January 7, 2020, 1:56pm UTC](https://discourse.slicer.org/t/rotation-in-dicom-data/9693/4 "2020-01-07T13:56:24Z")

</div>

> [@OJay](#):
>
> Thank you very much for you information… i try a little bit its not so easy

Are you interested in rotating slice views or you need to change physical position/orientation of images?

> [@OJay](#):
>
> again one question… where i found a Surface Registration?  
> I will merge a STL model on a cbct data set…

Would you mind posting this in a separate topic? (this will be a start of a new discussion, unrelated to image or view rotation)

---

<div class="post-metadata">

### Author: ![OJay](https://avatars.discourse-cdn.com/v4/letter/o/c5a1d2/32.png) [@OJay](https://discourse.slicer.org/u/OJay)
#### Post date: [January 7, 2020, 2:16pm UTC](https://discourse.slicer.org/t/rotation-in-dicom-data/9693/5 "2020-01-07T14:16:43Z")

</div>

interested in rotating slice views (rotate around a bone)

thank you

---

<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: [January 7, 2020, 2:39pm UTC](https://discourse.slicer.org/t/rotation-in-dicom-data/9693/6 "2020-01-07T14:39:42Z")

</div>

In recent Slicer Preview Releases, you can easily rotate slice views by showing slice intersections (using dropdown menu of crosshair button in the toolbar), setting slice intersection position using Shift + mouse-move, then rotate slices using Ctrl + Alt + left-click-and-drag.

You can copy-paste this code snippet into the Python interactor for initial alignment based on a markups line:

```python
lineNode = getNode('L')

# Get direction vector of the line
import numpy as np
p1 = np.zeros(3)
p2 = np.zeros(3)
lineNode.GetNthControlPointPositionWorld(0, p1)
lineNode.GetNthControlPointPositionWorld(1, p2)
directionVector = p2-p1

# Position/orient slice views based on line position and direction
for axisIndex, viewName in enumerate(['Red', 'Green', 'Yellow']):
  sliceNode = slicer.app.layoutManager().sliceWidget(viewName).mrmlSliceNode()
  sliceNode.SetSliceToRASByNTP(directionVector[0], directionVector[1], directionVector[2], 1,0,0, p1[0], p1[1], p1[2], axisIndex)

```

---

<div class="post-metadata">

### Author: ![OJay](https://avatars.discourse-cdn.com/v4/letter/o/c5a1d2/32.png) [@OJay](https://discourse.slicer.org/u/OJay)
#### Post date: [January 8, 2020, 3:51pm UTC](https://discourse.slicer.org/t/rotation-in-dicom-data/9693/7 "2020-01-08T15:51:52Z")

</div>

Sorry its dont work… is a other way available?

---

<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: [January 8, 2020, 4:02pm UTC](https://discourse.slicer.org/t/rotation-in-dicom-data/9693/8 "2020-01-08T16:02:05Z")

</div>

I’ve tested this yesterday with a recent Slicer Preview Release and it worked well. If you have any trouble then please provide step-by-step description (or screen capture) of what you did, what you expected to happen, and what happened instead.

---

<div class="post-metadata">

### Author: ![OJay](https://avatars.discourse-cdn.com/v4/letter/o/c5a1d2/32.png) [@OJay](https://discourse.slicer.org/u/OJay)
#### Post date: [January 8, 2020, 4:47pm UTC](https://discourse.slicer.org/t/rotation-in-dicom-data/9693/9 "2020-01-08T16:47:59Z")

</div>

Ohhh yessss with the Preview Release version it is works!!! i had the older version…

Thanks!

---

<div class="post-metadata">

### Author: ![WangZhen1175701153](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/wangzhen1175701153/32/10396_2.png) [@WangZhen1175701153](https://discourse.slicer.org/u/WangZhen1175701153)
#### Post date: [April 7, 2021, 7:25am UTC](https://discourse.slicer.org/t/rotation-in-dicom-data/9693/10 "2021-04-07T07:25:38Z")

</div>

How do I get the node ‘L’?  
Sorry, I just started learning how to use 3DSlicer.

---

<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: [April 8, 2021, 4:06pm UTC](https://discourse.slicer.org/t/rotation-in-dicom-data/9693/11 "2021-04-08T16:06:48Z")

</div>

If you draw a line markup (choose to place a Line in the toolbar) then by default its name will be ‘L’. The code snippet uses that line as rotation axis.

---

<div class="post-metadata">

### Author: ![WangZhen1175701153](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/wangzhen1175701153/32/10396_2.png) [@WangZhen1175701153](https://discourse.slicer.org/u/WangZhen1175701153)
#### Post date: [April 9, 2021, 12:42am UTC](https://discourse.slicer.org/t/rotation-in-dicom-data/9693/13 "2021-04-09T00:42:10Z")

</div>

Thank you very much 🤣. I’ve looked at a number of script files that just use getNode () without explaining how Nodes are created.

---

<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: [April 9, 2021, 12:43am UTC](https://discourse.slicer.org/t/rotation-in-dicom-data/9693/14 "2021-04-09T00:43:15Z")

</div>

You can learn Slicer programming basics from [these tutorials](https://slicer.readthedocs.io/en/latest/developer_guide/api.html#tutorials).

---

<div class="post-metadata">

### Author: ![WangZhen1175701153](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/wangzhen1175701153/32/10396_2.png) [@WangZhen1175701153](https://discourse.slicer.org/u/WangZhen1175701153)
#### Post date: [April 9, 2021, 1:25am UTC](https://discourse.slicer.org/t/rotation-in-dicom-data/9693/15 "2021-04-09T01:25:32Z")

</div>

ok. 😀 Thank you for your help!!!
