# Resample image volume along user-defined plane

**URL:** <https://discourse.slicer.org/t/resample-image-volume-along-user-defined-plane/37146>\
**Category:** Support\
**Created:** [July 2, 2024, 11:37am UTC](https://discourse.slicer.org/t/resample-image-volume-along-user-defined-plane/37146 "2024-07-02T11:37:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![1000\_tiny\_slices](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/1000_tiny_slices/32/79313_2.png) [@1000\_tiny\_slices](https://discourse.slicer.org/u/1000_tiny_slices)\
**Post date:** [July 2, 2024, 11:37am UTC](https://discourse.slicer.org/t/resample-image-volume-along-user-defined-plane/37146/1 "2024-07-02T11:37:33Z")

</div>

I would like to transform and resample my CT volume so that a user-defined plane becomes one of the orthogonal slices. I used to do this in AVIZO by defining points, best-fitting a plane to those points and then resampling the image volume with the plane as a reference object. How can I go about doing something like this efficiently in 3D Slicer?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 5, 2024, 4:32pm UTC](https://discourse.slicer.org/t/resample-image-volume-along-user-defined-plane/37146/2 "2024-07-05T16:32:27Z")

</div>

See discussion here: [Non Orthogonal reslice - #2 by pieper](https://discourse.slicer.org/t/non-orthogonal-reslice/37213/2)

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [July 5, 2024, 5:08pm UTC](https://discourse.slicer.org/t/resample-image-volume-along-user-defined-plane/37146/3 "2024-07-05T17:08:24Z")

</div>

Try also ‘Curved planar reformat’ module with a curve using only 2 control points as a line. Use a much greater ‘Slice size’ parameter than the default to better understand the result. You’ll have a cropped volume along the line with the slice views reformatted along the line as an axis. I don’t know at all what would be the result with AVIZO, just worth a try.

---

<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 6, 2024, 1:21am UTC](https://discourse.slicer.org/t/resample-image-volume-along-user-defined-plane/37146/4 "2024-07-06T01:21:48Z")

</div>

You can use [this code snippet](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#extract-slice-from-volume) to set up a markup ROI node from plane node and use this ROI to resample the volume. The code snippet extracts a single slice but it can be easily modified to extract more slices by modifying the extents (last two numbers in `imageData.SetExtent(...)`).

---

<div class="post-metadata">

**Author:** ![1000\_tiny\_slices](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/1000_tiny_slices/32/79313_2.png) [@1000\_tiny\_slices](https://discourse.slicer.org/u/1000_tiny_slices)\
**Post date:** [July 10, 2024, 5:46pm UTC](https://discourse.slicer.org/t/resample-image-volume-along-user-defined-plane/37146/5 "2024-07-10T17:46:02Z")

</div>

Thanks so much, this community is awesome! This is my preferred solution for me because it’s most similar to my previous workflow (I didn’t have to manually drag and rotate). However, it requires the Python console. I don’t code Python, so I was thankful for the instructions about modifying code in the repository.

For anyone wanting more info about this solution, I defined an anatomical reference plane that sits about in the middle of the head (dividing it into top and bottom halves).

The set extent command is in reference to that plane. For the coordinate system of my scan, the second to last number in that line of code defines the number of slices that will be resampled below my reference plane and the last number defines the number of slices that will be resampled above my reference.

---

<div class="post-metadata">

**Author:** ![1000\_tiny\_slices](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/1000_tiny_slices/32/79313_2.png) [@1000\_tiny\_slices](https://discourse.slicer.org/u/1000_tiny_slices)\
**Post date:** [July 10, 2024, 5:52pm UTC](https://discourse.slicer.org/t/resample-image-volume-along-user-defined-plane/37146/6 "2024-07-10T17:52:15Z")

</div>

Thanks so much, this community is awesome!

This solution has the advantage of being more user-friendly because all of the user interface options. I don’t prefer it because the plane I am trying to display can be difficult to define precisely by dragging and rotating.

This is also a great solution, just depends on how precise you need your reference plane to be and how different the location/orientation of the begining and target ending volumes.

---

<div class="post-metadata">

**Author:** ![1000\_tiny\_slices](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/1000_tiny_slices/32/79313_2.png) [@1000\_tiny\_slices](https://discourse.slicer.org/u/1000_tiny_slices)\
**Post date:** [July 16, 2024, 1:39pm UTC](https://discourse.slicer.org/t/resample-image-volume-along-user-defined-plane/37146/7 "2024-07-16T13:39:25Z")

</div>

Could this block of code be modified to set the fill value for the resampled volume?

---

<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, 2024, 6:19pm UTC](https://discourse.slicer.org/t/resample-image-volume-along-user-defined-plane/37146/8 "2024-07-16T18:19:10Z")

</div>

Yes, you can specify the fill value in the `parameters` variable. See how to get the list of parameter names [here](https://slicer.readthedocs.io/en/latest/developer_guide/python_faq.html#get-list-of-parameter-names).
