# Cross Sectional Area of a Ring

**URL:** <https://discourse.slicer.org/t/cross-sectional-area-of-a-ring/1015>\
**Category:** Support\
**Created:** [September 6, 2017, 5:54pm UTC](https://discourse.slicer.org/t/cross-sectional-area-of-a-ring/1015 "2017-09-06T17:54:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![victoria.rose](https://avatars.discourse-cdn.com/v4/letter/v/2bfe46/32.png) [@victoria.rose](https://discourse.slicer.org/u/victoria.rose)\
**Post date:** [September 6, 2017, 5:54pm UTC](https://discourse.slicer.org/t/cross-sectional-area-of-a-ring/1015/1 "2017-09-06T17:54:45Z")

</div>

I am looking to calculate the cross sectional area at multiple points around the ring (I tried to mark where I would like to slice the ring and measure the area using pairs of fiducials in the image below).

I am not sure what the best method is as the orientation of the slice is constantly changing, so I’m just looking for an idea of what add-on or method would be best. Thank you!

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/e/0ebb246889d2b85c9f1cb84b30ccebe398acad4e.jpeg)

---

<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:** [September 6, 2017, 11:41pm UTC](https://discourse.slicer.org/t/cross-sectional-area-of-a-ring/1015/2 "2017-09-06T23:41:48Z")

</div>

You can define a curved path and reslice the image along that path as shown in this video:

Once you have the slice views in correct orientation, you can use the ruler tool (available in the toolbar) to measure diameter.

---

<div class="post-metadata">

**Author:** ![victoria.rose](https://avatars.discourse-cdn.com/v4/letter/v/2bfe46/32.png) [@victoria.rose](https://discourse.slicer.org/u/victoria.rose)\
**Post date:** [September 12, 2017, 2:12pm UTC](https://discourse.slicer.org/t/cross-sectional-area-of-a-ring/1015/3 "2017-09-12T14:12:45Z")

</div>

Perfect that is exactly what I was looking for!

I want to loop through screen shots for each frame of a created path (~30). Is it possible to code a loop taking snapshots and labeling them in the Python interactor?

Thanks!

---

<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:** [September 12, 2017, 3:30pm UTC](https://discourse.slicer.org/t/cross-sectional-area-of-a-ring/1015/4 "2017-09-12T15:30:51Z")

</div>

It’s easy to create screen captures from scripts, see examples in the script repository:  
[https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Capture](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Capture)

If you are interested in Python scripting, you could modify the Endoscopy module to save each timepoint’s transform into a Sequence module creates a sequence node and saves transforms into it). After that you can use the ScreenCapture module’s `sequence` animation mode to record a movie.

THe implementation would be probably about 20-30 lines of code in [Endoscopy.py](http://Endoscopy.py). You can have a look at [SequenceRegistration](https://github.com/moselhy/SlicerSequenceRegistration) module for an example how to create a sequence node and store transforms in it. I would be happy to help if you stuck at any point with the implementation.

---

<div class="post-metadata">

**Author:** ![victoria.rose](https://avatars.discourse-cdn.com/v4/letter/v/2bfe46/32.png) [@victoria.rose](https://discourse.slicer.org/u/victoria.rose)\
**Post date:** [September 13, 2017, 2:50pm UTC](https://discourse.slicer.org/t/cross-sectional-area-of-a-ring/1015/5 "2017-09-13T14:50:42Z")

</div>

Thanks for the code links, they were very helpful! Although I’m sure that is a much more elegant way to accomplish what I need, I am very new to Python and Slicer so I wrote a basic script to take images (and slice location) at specified points of the transform:

```
lm = slicer.app.layoutManager()
yellow = lm.sliceWidget('Yellow')
yellowLogic = yellow.sliceLogic()
height = []

layoutName = 'Yellow'
imagePathPattern = 'C:/image-%d.png'
count = 25

slicer.modules.endoscopy.widgetRepresentation().self().frameSlider.value = 0
for step in range(count+1):
    image = qt.QPixmap.grabWidget(view).toImage()
    image.save(imagePathPattern % step)
    slicer.modules.endoscopy.widgetRepresentation().self().frameSlider.value = slicer.modules.endoscopy.widgetRepresentation().self().frameSlider.value + 1
    view.forceRender()
    height.append(yellowLogic.GetSliceOffset())

print height

```

I am sure it’s rough code but it gets the job done. Thanks again!
