# Resampling an Image

**URL:** <https://discourse.slicer.org/t/resampling-an-image/461>\
**Category:** Support\
**Tags:** transforms\
**Created:** [June 8, 2017, 6:24pm UTC](https://discourse.slicer.org/t/resampling-an-image/461 "2017-06-08T18:24:41Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahoover](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@ahoover](https://discourse.slicer.org/u/ahoover)\
**Post date:** [June 8, 2017, 6:24pm UTC](https://discourse.slicer.org/t/resampling-an-image/461/1 "2017-06-08T18:24:41Z")

</div>

When I resample an image in Slicer using the Resample Image (Brains) module and a transform I made using the Transform module, the image ends up correctly resampled except for its flipped around one axis. I’m assuming this is because of the RAS and LAS coordinate system, but I don’t know how to fix it. What is the best way to go about preventing this flip?

Thank you for your help.

---

<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:** [June 8, 2017, 7:00pm UTC](https://discourse.slicer.org/t/resampling-an-image/461/2 "2017-06-08T19:00:41Z")

</div>

Can you provide the exact steps (ideally demonstrated using the SampleData) and how you are looking at the data when you say it is flipped?

---

<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:** [June 8, 2017, 8:01pm UTC](https://discourse.slicer.org/t/resampling-an-image/461/3 "2017-06-08T20:01:25Z")

</div>

> [@ahoover](#):
>
> its flipped around one axis

Is it flipped when displayed in Slicer or when you load it in your own software? When you display an image in your own software, you must always take into account patient orientation and axis directions information that are stored in the image header.

Images are displayed correctly in all commonly used medical image computing software, such as 3D Slicer, ITK-Snap, or MITK. Images are often not displayed correctly in generic scientific visualization software, such as ParaView, 2D/microscopy-oriented software such as ImageJ/Fiji, and in other small custom single-project-use research software (various Matlab or Python scripts that were only tested on a limited set of images).

---

<div class="post-metadata">

**Author:** ![ahoover](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@ahoover](https://discourse.slicer.org/u/ahoover)\
**Post date:** [June 8, 2017, 8:25pm UTC](https://discourse.slicer.org/t/resampling-an-image/461/4 "2017-06-08T20:25:37Z")

</div>

I have a mri and nii scan that i want to co-register.

These are the steps I did.  
1.Uploaded both images  
2. Centered both images  
3. Save the centered images  
4. Used the transforms module to align the mri with the ct scan  
5. Saved the transform  
6. Tried to resample them with the resample (brains) module  
(the ct scan as the reference, the mri scan as the movable, my transform as the transform, and hit apply)  
However when I look at the resampled image in slicer the image is flipped. Specifically, the coronal window is flipped vertically. It’s as if the signs in the right column of my transform matrix were flipped. (I don’t know if this is related but I’ve noticed the signs of the right column of my transform matrix are flipped whenever I upload the transform in slicer however the magnitudes and all the other signs are unchanged)

---

<div class="post-metadata">

**Author:** ![ahoover](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@ahoover](https://discourse.slicer.org/u/ahoover)\
**Post date:** [June 8, 2017, 8:26pm UTC](https://discourse.slicer.org/t/resampling-an-image/461/5 "2017-06-08T20:26:08Z")

</div>

It’s flipped in 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:** [June 8, 2017, 9:48pm UTC](https://discourse.slicer.org/t/resampling-an-image/461/6 "2017-06-08T21:48:41Z")

</div>

Thanks for the info. In step 6 are you running the brains resample through  
slicer or externally? (Not sure why you need step 5 if you are running  
inside slicer).

---

<div class="post-metadata">

**Author:** ![ahoover](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@ahoover](https://discourse.slicer.org/u/ahoover)\
**Post date:** [June 9, 2017, 2:11am UTC](https://discourse.slicer.org/t/resampling-an-image/461/7 "2017-06-09T02:11:14Z")

</div>

Resampling in slicer. I’m doing everything in slicer but i just feel better about saving things as I go along. Do you have any idea why the signs in the right column are flipping?

---

<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:** [June 9, 2017, 4:06am UTC](https://discourse.slicer.org/t/resampling-an-image/461/8 "2017-06-09T04:06:22Z")

</div>

I guess you don’t see any image misalignment in Slicer as a result of resampling. Can you confirm?

Input images can have any orientation but outputs are often generated with standardized axis order and direction. As a result, you may see that the output image axes directions are different from the input image. It’s not a problem because voxels in the array are ordered accordingly.

---

<div class="post-metadata">

**Author:** ![ahoover](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@ahoover](https://discourse.slicer.org/u/ahoover)\
**Post date:** [June 9, 2017, 2:02pm UTC](https://discourse.slicer.org/t/resampling-an-image/461/9 "2017-06-09T14:02:39Z")

</div>

My problem is that the image still looks flipped over one axis in slicer. It’s the same project that you really helped me on yesterday with how to segment two images in slicer. When I hit apply for the segmentation in slicer, the segmentation done with the registered scan flips so half of the segmentation is upside down relative to the other half. I thought maybe if I resampled the image I wouldn’t have this problem, but resampling causes the image to appear flipped in slicer which I need not to be the case so that I can segment them together.

---

<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:** [June 9, 2017, 2:07pm UTC](https://discourse.slicer.org/t/resampling-an-image/461/10 "2017-06-09T14:07:21Z")

</div>

If the image appears flipped inside Slicer then it is probably a bug but we need to be able to reproduce the problem to be able to fix it. Would you be able to create a screen capture video so that we can see what exact steps did you follow?
