# Read Prostate MR image failed

**URL:** <https://discourse.slicer.org/t/read-prostate-mr-image-failed/3423>\
**Category:** Support\
**Created:** [July 9, 2018, 12:30pm UTC](https://discourse.slicer.org/t/read-prostate-mr-image-failed/3423 "2018-07-09T12:30:36Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![zgk110](https://avatars.discourse-cdn.com/v4/letter/z/ed8c4c/32.png) [@zgk110](https://discourse.slicer.org/u/zgk110)\
**Post date:** [July 9, 2018, 12:30pm UTC](https://discourse.slicer.org/t/read-prostate-mr-image-failed/3423/1 "2018-07-09T12:30:37Z")

</div>

Operating system:Windows 64 bit  
Slicer version:4.8.1  
Expected behavior:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/e/4edd81d321755af049fe9246d5ddc5662af55aa0.jpeg)  
Actual behavior:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/3/b34d205c06fa2878d4e8b9d14512afec51608a56.jpeg)

Hello, i am trying to read a prostate image by 3D slicer, however, when i open it, it seems some of the images is not complete and the rotation looks like being mistake, so i wonder if there are some solutions for that.  
Thanks a lot.

---

<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 10, 2018, 2:53am UTC](https://discourse.slicer.org/t/read-prostate-mr-image-failed/3423/2 "2018-07-10T02:53:37Z")

</div>

This looks perfect. MRI images are often acquired with orientation that is not aligned with anatomical axes.

If you prefer, you can adjust slice views from the default (anatomical) orientation to image acquisition axes orientation: open slice view controller, click double-arrow to show more options, click views link, and click _Rotate to volume_ button.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/b/5b6815359e7127db64baa7f52eb47e2b95e434bb.png)

---

<div class="post-metadata">

**Author:** ![zgk110](https://avatars.discourse-cdn.com/v4/letter/z/ed8c4c/32.png) [@zgk110](https://discourse.slicer.org/u/zgk110)\
**Post date:** [July 10, 2018, 5:58am UTC](https://discourse.slicer.org/t/read-prostate-mr-image-failed/3423/3 "2018-07-10T05:58:08Z")

</div>

Really appreciate for your help.  
Well, the MR image display seems work well, however, I also want to annotate the ROI region and get the center coordinates of the region and export them for future research (deep learning analysis et.). I have tried this module, and the exported coordinates(red rectangle, voxel coordinate) is just as below:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/8/38e9c7e8748a9031a4bbe811984e321eddcf0090.png)  
I use the SimpleItk (python) to convert the voxel coordinate to world coordinate, the code is just as :  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/6/962e44c3bc7f77b4df020139a2a71376ef44f547.png)  
The world coordinate by using SimpleItk is (88,-35,31), but in fact the true world coordinate is :  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/4/84134f9ea69f3ebe9dc25a191948ac8ad39c522f.png)

So i am confused where i am wrong, or some other ways to directly export the right world coordinates ?  
Thanks a lot.

---

<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 10, 2018, 6:24am UTC](https://discourse.slicer.org/t/read-prostate-mr-image-failed/3423/4 "2018-07-10T06:24:55Z")

</div>

The code snippet above ignores image orientation and therefore the computed physical coordinates are incorrect. The world\_xyz computation formula looks suspicious, too (you cannot subtract physical coordinates origin\_xyz from voxel coordinates center\_xyz). You either need to fix the formula (it would be something like origin\_xyz + voxel\_ijk \* spacing \* direction) or use `TransformIndexToPhysicalPoint` method (or one of its variants).

Also note that Slicer uses RAS as world coordinates, while ITK uses LPS (so you may need to multiply physical coordinates by diag(-1, -1, 1, 1) matrix), and if you access arrays in numpy then you may also need to deal with Fortran/C index order.

---

<div class="post-metadata">

**Author:** ![zgk110](https://avatars.discourse-cdn.com/v4/letter/z/ed8c4c/32.png) [@zgk110](https://discourse.slicer.org/u/zgk110)\
**Post date:** [July 10, 2018, 9:03am UTC](https://discourse.slicer.org/t/read-prostate-mr-image-failed/3423/5 "2018-07-10T09:03:02Z")

</div>

Thanks a lot for your help.

Anyway, what is the meaning of the operation ’ rotate to volume plane’, I have many other MR images to handle, and I want to process these image previously by a script.  
I wonder if there are some script function in SimpleITK to do this operation in bulk.

---

<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 10, 2018, 2:38pm UTC](https://discourse.slicer.org/t/read-prostate-mr-image-failed/3423/6 "2018-07-10T14:38:50Z")

</div>

> [@zgk110](#):
>
> what is the meaning of the operation ’ rotate to volume plane

Reorient slice views to match direction of image axes.

> [@zgk110](#):
>
> I wonder if there are some script function in SimpleITK to do this operation in bulk.

All operations that you can do on the GUI are available from Python - some of them use MRML library, some use module logic, and some may be accessible using SimpleITK. We can give more specific advice if you tell what operations you plan to do.

---

<div class="post-metadata">

**Author:** ![zgk110](https://avatars.discourse-cdn.com/v4/letter/z/ed8c4c/32.png) [@zgk110](https://discourse.slicer.org/u/zgk110)\
**Post date:** [September 15, 2018, 11:07am UTC](https://discourse.slicer.org/t/read-prostate-mr-image-failed/3423/7 "2018-09-15T11:07:47Z")

</div>

> [@lassoan](#):
>
> We can give more specific advice if you tell what operations you plan to do.

Hello, is there any example codes of ‘rotate MRI images to volume plane’ operation by python, can you show me some examples, 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:** [September 15, 2018, 11:00pm UTC](https://discourse.slicer.org/t/read-prostate-mr-image-failed/3423/8 "2018-09-15T23:00:33Z")

</div>

> [@zgk110](#):
>
> is there any example codes of ‘rotate MRI images to volume plane’ operation by python

See this code snippet in the script repository:

[https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Rotate\_slice\_views\_to\_volume\_plane](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Rotate_slice_views_to_volume_plane)

---

<div class="post-metadata">

**Author:** ![zgk110](https://avatars.discourse-cdn.com/v4/letter/z/ed8c4c/32.png) [@zgk110](https://discourse.slicer.org/u/zgk110)\
**Post date:** [September 22, 2018, 4:55pm UTC](https://discourse.slicer.org/t/read-prostate-mr-image-failed/3423/9 "2018-09-22T16:55:27Z")

</div>

Hi , How to save the transformed (‘rotate to volume plane’ ) volume in GUI?  
I have tried the "rename the current volume’’ and then save it, however when i open it again it seems that the transformed volume not changed.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/a/0a3ab9aa80ddf0c22a0af22ba398d7abdf04d791.png)

Meanwhile, i also want to save the plane by python, the code is as below in .slicerrc.py , and i want to know how can i get the transformed volume and save it through python.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/4/c48d774bfd4f765c505f26093912b2c90a67259a.png)

---

<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 23, 2018, 12:54pm UTC](https://discourse.slicer.org/t/read-prostate-mr-image-failed/3423/10 "2018-09-23T12:54:21Z")

</div>

“Rotate to volume plane” rotates slice view plane to match orientation of volume axes. The volume is not transformed. Why would you like to rotate the volume?
