# How to do cross section with free angle?

**URL:** https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016
**Category:** Development
**Created:** [January 30, 2020, 3:57am UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016 "2020-01-30T03:57:23Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![Illusion](https://avatars.discourse-cdn.com/v4/letter/i/e19b73/32.png) [@Illusion](https://discourse.slicer.org/u/Illusion)
#### Post date: [January 30, 2020, 3:57am UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/1 "2020-01-30T03:57:23Z")

</div>

Slicer version: 4.10.2

How to use the slicer to do free-angle cross-section, not only the three anatomy planes?  
How could I get the cross-section like the several cross-sections in blue planes?

![Untitled](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/7/b79351190c09b24183806417c95514bb44ba0b01.png)  
Thank you very much!

---

<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 30, 2020, 4:02am UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/2 "2020-01-30T04:02:46Z")

</div>

There are many options, for example:

- Option A: Reformat module can be used to adjust angles of slice views using sliders
- Option B: Show reslice widget in slice view and then adjust reslice plane in 3D views:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/1/11220132d775341d8b38aecc844a09d50c6097bd.png)

- Option C: Use recent Slicer preview release, show slice intersections, and use Ctrl+Alt+Left-click-and-drag to rotate intersecting slice views around the slice intersection point.

---

<div class="post-metadata">

### Author: ![Illusion](https://avatars.discourse-cdn.com/v4/letter/i/e19b73/32.png) [@Illusion](https://discourse.slicer.org/u/Illusion)
#### Post date: [January 30, 2020, 4:18am UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/3 "2020-01-30T04:18:35Z")

</div>

Hi Andras,

Thank you very much for your help!

Could you please teach me which python package and API should I use to write python codes for getting multiple cross-sections automatically as desired?

---

<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 30, 2020, 4:31am UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/4 "2020-01-30T04:31:35Z")

</div>

I’m not sure what you mean. Would you like to show a number of slice views in a 3D view, rotated by different angles? What is the clinical application? Would you like to compute Cobb angle? Reslice the image along the spinal chord curve? …?

---

<div class="post-metadata">

### Author: ![Illusion](https://avatars.discourse-cdn.com/v4/letter/i/e19b73/32.png) [@Illusion](https://discourse.slicer.org/u/Illusion)
#### Post date: [January 30, 2020, 4:36am UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/5 "2020-01-30T04:36:25Z")

</div>

I would like to write codes in python, to get cross-sections just like the figure in my first post above.  
I.e., for each vertebra, I would like to get four cross-sections.

Assume I assign an array of starting points for each vertebra along with four rotation angles, how can I write python codes to get cross-sections and save the images?

---

<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 30, 2020, 4:44am UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/6 "2020-01-30T04:44:24Z")

</div>

You can switch to a layout that has at least as many slice views as you need (e.g., “Four over four” built-in layout, or a custom layout that you specify), set the slice view positions/orientations by modifying the matrix returned by `sliceNode.GetSliceToRAS()`, and show the slice views in 3D. You can then switch to any layout, the slices will remain visible in 3D view.

There are lots of related examples in [Slicer script repository](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository).

---

<div class="post-metadata">

### Author: ![Illusion](https://avatars.discourse-cdn.com/v4/letter/i/e19b73/32.png) [@Illusion](https://discourse.slicer.org/u/Illusion)
#### Post date: [March 9, 2020, 11:05pm UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/7 "2020-03-09T23:05:55Z")

</div>

Hi Iassoan,

I am able to manually control the reformat widget now. However, not accurate.

Could you please let me know what is the python function to program the position and angle of anatomy plane reformat widget?

Thank you very much!

---

<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: [March 9, 2020, 11:42pm UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/8 "2020-03-09T23:42:53Z")

</div>

As I wrote above, there are many examples of slice manipulations in the script repository, see for example, [this](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Change_slice_orientation).

---

<div class="post-metadata">

### Author: ![Illusion](https://avatars.discourse-cdn.com/v4/letter/i/e19b73/32.png) [@Illusion](https://discourse.slicer.org/u/Illusion)
#### Post date: [March 11, 2020, 3:02am UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/9 "2020-03-11T03:02:06Z")

</div>

Hi Iassoan,

I found a existing module “Reformat”, which can do exactly what I want.  
However, I was not able to find the source file in the Slicer installation folder.

I did a lot of search locally on the disk, and still cannot find the module find, even though I can run the module. 😇  
It seems that the file of the link below is not in the installation folder. [https://github.com/Slicer/Slicer/blob/master/Modules/Loadable/Reformat/qSlicerReformatModule.h](https://github.com/Slicer/Slicer/blob/master/Modules/Loadable/Reformat/qSlicerReformatModule.h)

Could you please let me know where to find the souce file of module Reformat such that I can debug the module?

Thank you very much!

---

<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: [March 11, 2020, 12:08pm UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/10 "2020-03-11T12:08:54Z")

</div>

You can find all the source files in the same folder. It is a C++ module, which is compiled into a dynamically loadable library. The source files are not used at runtime and so they are not included in the install package.

---

<div class="post-metadata">

### Author: ![Illusion](https://avatars.discourse-cdn.com/v4/letter/i/e19b73/32.png) [@Illusion](https://discourse.slicer.org/u/Illusion)
#### Post date: [March 11, 2020, 7:17pm UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/11 "2020-03-11T19:17:21Z")

</div>

Thank you for your help, Iassoan!  
I figured out how to do it. 😉

One last question, any link that demonstrated how to debug the C++ codes with Slicer API?

---

<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: [March 12, 2020, 10:34pm UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/12 "2020-03-12T22:34:35Z")

</div>

This topic should help. If you still have questions then let us know.

> [@Debugging step by step](https://discourse.slicer.org/t/debugging-step-by-step/9882):
>
> Hello, I created a C++ extension, which works quite fine but i never managed to make to debugger work. I tried with several IDE QtCreator, Kdevelop, Clion, I correctly set the CMAKE\_BUILD\_TYPE Flag to debug (for my extension and for 3D Slicer), and each time i can’t get breakpoints working. It seems that debug symbols are not generated. Am I missing something ?

---

<div class="post-metadata">

### Author: ![Alice](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@Alice](https://discourse.slicer.org/u/Alice)
#### Post date: [October 8, 2020, 2:34am UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/13 "2020-10-08T02:34:07Z")

</div>

Hi,I also encountered the same problem, I also need to extract a certain angle of section. Can you tell me how you solved it?

---

<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: [October 8, 2020, 5:04am UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/14 "2020-10-08T05:04:39Z")

</div>

Do these options work for you?

> [@How to do cross section with free angle?](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/2):
>
> There are many options, for example: Option A: Reformat module can be used to adjust angles of slice views using sliders Option B: Show reslice widget in slice view and then adjust reslice plane in 3D views: [image] Option C: Use recent Slicer preview release, show slice intersections, and use Ctrl+Alt+Left-click-and-drag to rotate intersecting slice views around the slice intersection point.

Since then we also added free slice rotation option by Ctrl/Cmd+Alt+Left-click-and-drag in slice views (around the slice intersection point, so you need to enable display of slice intersection in the toolbar, in the crosshair button’s drop-down menu).

You may also find “Valve view” module useful (provided by SlicerHeart extension), which allows rotating two orthogonal slice views around the plane normal of a third slice view.

If you want to reslice along a curve then you can use “Cross-section analysis” module (provided by SlicerVMTK extension).

You can find several examples for setting slice orientation from a Python script. If they don’t do what you want then let us know what you would like to achieve.

---

<div class="post-metadata">

### Author: ![Alice](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@Alice](https://discourse.slicer.org/u/Alice)
#### Post date: [November 4, 2020, 2:37am UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/15 "2020-11-04T02:37:43Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/9/d9675d1b70106bfd2d20f7ff9f90a32cf9bed3c8.png)  
This is my image.The module "Extract Centerline " just only shows the mean diameter , and the module “Airway Inspector” just calculates one airway,but I want to calculate several pairs of inner radius and outer radius along the centerline.

---

<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: [November 4, 2020, 2:42am UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/16 "2020-11-04T02:42:06Z")

</div>

The radius does not change much within a segment, so the mean value characterizes a branch quite well. But if you need more details then you can get the radius for each curve point from the output model node (stored in point data array).

What do you mean by inner and outer radius?

---

<div class="post-metadata">

### Author: ![Alice](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@Alice](https://discourse.slicer.org/u/Alice)
#### Post date: [November 4, 2020, 2:49am UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/17 "2020-11-04T02:49:17Z")

</div>

Is that? I will try it.  
Inner and outer diameter are the output of the module “Airway Inspector” , represent the airway’s inner diameter and outer diameter which contains the thickness of the airway wall.

---

<div class="post-metadata">

### Author: ![Alice](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@Alice](https://discourse.slicer.org/u/Alice)
#### Post date: [November 4, 2020, 3:00am UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/18 "2020-11-04T03:00:44Z")

</div>

What do you mean by “the output model node (stored in point data array)”? I just find the ID and coordinates of every point in each curve.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/7/37bd8b76083f0008bdefdea64561fdb77e111101.png)

---

<div class="post-metadata">

### Author: ![Team\_Python](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/team_python/32/69473_2.png) [@Team\_Python](https://discourse.slicer.org/u/Team_Python)
#### Post date: [February 27, 2024, 3:48pm UTC](https://discourse.slicer.org/t/how-to-do-cross-section-with-free-angle/10016/19 "2024-02-27T15:48:19Z")

</div>

### How to create cross sectional view (dentistry)?

Hello Sir I have heard about you that you work with DICOM. I have a question. I have been stuck on this task for several months, but I am not understanding how to proceed. I work in dentistry, and I want to use the Python programming language to extract individual teeth from DICOM images, similar to what is shown in this gif. But sir, I am very distressed. I have tried creating sagittal, coronal, axial, and panoramic X-ray images, but I am unable to achieve this. I am not able to understand it. Please guide me. I am waiting for your response. Thank you.
