# How to adjust the distorted image?

**URL:** <https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817>\
**Category:** Support\
**Created:** [August 3, 2017, 5:15pm UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817 "2017-08-03T17:15:34Z")\
**Posts on this page:** 20\
**Page:** 2

<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 23, 2017, 2:50pm UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/21 "2017-10-23T14:50:08Z")

</div>

For nii files I think you should just resample the image, for example using Crop volume module.

---

<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:** [October 23, 2017, 5:35pm UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/22 "2017-10-23T17:35:44Z")

</div>

Hi doc-xie -

If you have the original dicom, you can look for the Gantry Tilt header (0018,1120) but it’s not a required tag so your data may not have it [1]. If you know the tilt you can make linear transform to correct the shear. If you don’t know the tilt exactly you could probably estimate visually, maybe by looking at the table. Do you know how do this? If not we can give instructions.

The solution I added to the DICOM module looks at the image positions at each slice, which are required by the standard, and creates a nonlinear transform that fixes the tilt and also handles a few other situations like missing slices. But it really only works on the original DICOM objects, not on data that’s been converted to nifti.

Best,  
Steve

[1] [http://dicom.nema.org/medical/dicom/current/output/html/part03.html#sect\_C.8.2](http://dicom.nema.org/medical/dicom/current/output/html/part03.html#sect_C.8.2)

---

<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 23, 2017, 7:02pm UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/23 "2017-10-23T19:02:28Z")

</div>

@doc-xie Do you have a nifti file that has shear in its image header?

---

<div class="post-metadata">

**Author:** ![doc-xie](https://avatars.discourse-cdn.com/v4/letter/d/c77e96/32.png) [@doc-xie](https://discourse.slicer.org/u/doc-xie)\
**Post date:** [October 24, 2017, 1:17am UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/24 "2017-10-24T01:17:31Z")

</div>

Thanks a lot,Professor Steve!  
I am so sorry,after I transform the .nii file to original format,the data have not the Gantry Tilt and I do not know how to recognize it.  
Would you like give me the instructions?  
Otherwise,the link you give me can not be opened correctly.  
Best,  
Doc-xie

---

<div class="post-metadata">

**Author:** ![doc-xie](https://avatars.discourse-cdn.com/v4/letter/d/c77e96/32.png) [@doc-xie](https://discourse.slicer.org/u/doc-xie)\
**Post date:** [October 24, 2017, 1:20am UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/25 "2017-10-24T01:20:18Z")

</div>

Yes,Professor Lassoan!  
My distored images have not be adjusted correctly,so the problem confused me for a long time.  
I can send the data to you if need,  
Thanks!  
Doc-xie

---

<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 24, 2017, 1:23am UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/26 "2017-10-24T01:23:10Z")

</div>

If you have old data that you imported earlier versions of Slicer or other software that cannot handle gantry tilt then there is not much you can do. Probably you have to discard the nii files and go back and reimport them from DICOM and probably resample the volume if you need the volume on a rectilinear grid.

---

<div class="post-metadata">

**Author:** ![doc-xie](https://avatars.discourse-cdn.com/v4/letter/d/c77e96/32.png) [@doc-xie](https://discourse.slicer.org/u/doc-xie)\
**Post date:** [October 24, 2017, 3:54am UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/27 "2017-10-24T03:54:48Z")

</div>

Thanks a lot,Professor Lassoan!  
After I import the original data,the value of the Gantry Tilt is 20.9. So what we know from this is the data transformed from .nii file can not be used again,especially to be adjusted for disformation. About the Gantry Tilt,what should I do in the next?  
Best wishes!  
Doc-xie

---

<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 24, 2017, 1:06pm UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/28 "2017-10-24T13:06:02Z")

</div>

The Gantry Tilt angle DICOM tag is for display purposes only. Accurate slice positions are defined by the slice position and axis directions DICOM tags. You may be able to compute an approximate transformation matrix from the Gantry Tilt tag, but it won’t be completely accurate (angle is rounded to one decimal, so you may get up to a few pixel error) and you may need some experimentation to get the rotation axis and direction right. Therefore, I would recommend to re-import the images from DICOM with a recent nightly version of Slicer (that computes the accurate image acquisition transformation matrix).

---

<div class="post-metadata">

**Author:** ![doc-xie](https://avatars.discourse-cdn.com/v4/letter/d/c77e96/32.png) [@doc-xie](https://discourse.slicer.org/u/doc-xie)\
**Post date:** [October 24, 2017, 1:37pm UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/29 "2017-10-24T13:37:50Z")

</div>

Thanks you very much!  
The version of 3D Slicer I used is new Nightly(2017-10-22),need I download some extensions for this transformation?  
If I finish adjustment with Transform module,which value should to be corrected?  
Would you like show me the specific steps because I am a new learner?😄😄  
Best,  
doc-xie

---

<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:** [October 24, 2017, 5:21pm UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/30 "2017-10-24T17:21:45Z")

</div>

Hi doc-xie -

The gantry tilt is a shear transform along the scan axis, which can be described with an off-diagonal entry in an otherwise identity linear transform. I just tried this on the case Andras shared with me, so it should work for your case too. I confirmed that at least visually this gives identical results to the DICOM-based approach (using the image position and orientation tags) that is in the current Nightly builds.

The basic steps are:

1. calculate the sine of the tilt angle. In my case, tag 0018,1120 was -8.5, so in the python console I typed:

```auto
import math
math.sin(math.radians(-8.5))

```

which gave the answer -0.14780941112961063

1. In the transforms module I created a linear transform and applied it to the CT

2. in the second row of the third column I changed the number from 0 to -.15

And it looks good.

The rationale for this from a linear algebra point of view is that the second row third column controls how the Anterior coordinate changes as a function of the Superior direction. Here it’s saying that for each mm increment anteriorly, the image data should be shifted back by .15 mm.

Visually, here is the volume without the transform:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/f/1fc75fd76b781a7eab8f6c4df63c4768f72a5ca7.jpeg)

And here it is with the transform:

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

And for reference here is the same data loaded in the Nightly build where the transform came from the DICOM directly.

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

Let me know if this doesn’t work for you - we want to get all these coordinate mappings correct!

Best,  
Steve

---

<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:** [October 24, 2017, 5:37pm UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/31 "2017-10-24T17:37:06Z")

</div>

Follow up: comparing closely between the gantry tilt shear matrix method described above and the dicom image position/orientation method from the nightly I still see some residual differences (possibly the kinds of errors Andras mentioined). I’m pretty sure the dicom method in the Nightly is correct but be very careful making any measurements on gantry tilted data.

---

<div class="post-metadata">

**Author:** ![doc-xie](https://avatars.discourse-cdn.com/v4/letter/d/c77e96/32.png) [@doc-xie](https://discourse.slicer.org/u/doc-xie)\
**Post date:** [October 26, 2017, 7:26am UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/32 "2017-10-26T07:26:29Z")

</div>

Thank you for your detailed introduction,I will try it.  
Best wishes!  
Doc-xie!

---

<div class="post-metadata">

**Author:** ![doc-xie](https://avatars.discourse-cdn.com/v4/letter/d/c77e96/32.png) [@doc-xie](https://discourse.slicer.org/u/doc-xie)\
**Post date:** [October 28, 2017, 2:02pm UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/33 "2017-10-28T14:02:08Z")

</div>

The problem has been solved successfully with your advice!  
Thanks a lot!  
Have a good weekend!  
Doc-die.

---

<div class="post-metadata">

**Author:** ![doc-xie](https://avatars.discourse-cdn.com/v4/letter/d/c77e96/32.png) [@doc-xie](https://discourse.slicer.org/u/doc-xie)\
**Post date:** [November 8, 2017, 2:40am UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/34 "2017-11-08T02:40:01Z")

</div>

Hello,Steve!  
A very intresting problem about the transform module.  
When I check a normal brain CT scan(Fig 1),

 ![1](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/2/f27b3b00f4373da3b07620191bef98f121af2875.jpeg)  
the gantry tilt is 24.6(Fig 2) ![2](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/3/23eb065b53c8c62a7267803bfd2ca2ec05984cb1.jpeg),  
so after i changed the Transform Matrix,the coronal view displayed unnormally and the 3D view distored obviously(Fig 3).  
 ![3](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/1/318567e03a49ff149646d9ed2f26bddeb7ddc639.jpeg)  
What is the reason about this and whether the Value of the GantryDetectorTilt is right?  
Best wished!  
Doc-xie

---

<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 8, 2017, 2:52pm UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/35 "2017-11-08T14:52:45Z")

</div>

As we explained before, GantryDetectionTilt field indicates that the image was acquired with gantry tilt, but it is not to be used for determining the image geometry. For example, it may be possible that the CT scanner saves the image as a Cartesian volume. The image transformation mechanism that is available in recent nightly versions does not use GantryDetectionTilt field and should handle all cases correctly regardless the volume is saved as a sheared or a Cartesian volume.

---

<div class="post-metadata">

**Author:** ![doc-xie](https://avatars.discourse-cdn.com/v4/letter/d/c77e96/32.png) [@doc-xie](https://discourse.slicer.org/u/doc-xie)\
**Post date:** [November 9, 2017, 3:21am UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/36 "2017-11-09T03:21:51Z")

</div>

Thaks,Professor Lassoan.  
But how to estimate the deformation degree of the volume and how to adjust the distorted image in recent nightly version correctly?  
Doc-xie

---

<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:** [November 9, 2017, 11:56am UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/37 "2017-11-09T11:56:20Z")

</div>

Hi Doc-xie -

Did you try importing and loading the dicom files through the dicom module? This should automatically create the nonlinear transform based on the per-slice geometry. It would be good know if this works for your data - it is a much simpler process.

Best,  
Steve

---

<div class="post-metadata">

**Author:** ![doc-xie](https://avatars.discourse-cdn.com/v4/letter/d/c77e96/32.png) [@doc-xie](https://discourse.slicer.org/u/doc-xie)\
**Post date:** [November 10, 2017, 8:03am UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/38 "2017-11-10T08:03:48Z")

</div>

Thanks a lot!  
What I want to know is whether I should check every Gantry tilt of every volume in order to estimate the deformation degreee,or the value of the Gantry tilt can be shown automatically?Another question,does the value of the Gantry tilt should be adjusted for the reconstruction correctly?  
Best wishes!  
Doc xie

---

<div class="post-metadata">

**Author:** ![laura\_rodriguez](https://avatars.discourse-cdn.com/v4/letter/l/e495f1/32.png) [@laura\_rodriguez](https://discourse.slicer.org/u/laura_rodriguez)\
**Post date:** [November 10, 2017, 10:04am UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/39 "2017-11-10T10:04:11Z")

</div>

Hi everyone,

I am pretty new working with 3D slicer, but I use to work with Mimics (I was using it since 2005), so please be patient…

I have a lot of distorsion with my dicom data, I can see perfectly well in axial view but the image is complete distorted in sagittal and coronal view, it is like some kind of unit problem. But I do not know how to fix it. There is no tilt in effect. They seem to be very wide… I was having a look to the dicom parameters but they look ok to me.

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

I hope you can help me

These are the DICOM image parameters

Study Date: 20100801  
Acquisition Date: 20100801  
Image Date: 20100801  
Study Time: 103821  
Acquisition Time: 104048  
Image Time: 104050.398998  
Accession Number: 0006050  
Modality: CT  
Manufacturer: Philips  
Institution Name: APHP.Pitie PrGRENIER  
Institution Address: PARIS 13  
Refering Physician’s Name: DR HUYNH  
Station Name: HOST-200029  
Study Description:   
Series Description: OS  
Institutional Dept. Name: RADIOLOGIE  
Manufacturer’s Model Name: iCT 128  
Patient Name: MEMBRE SUP^ANCIEN  
Patient Date of Birth: 20000101  
Patient Sex: O  
Scan Options: HELIX  
Slice Thickness: 1.00  
KVP: 140  
Spacing Between Slices: 0.5  
Data Collection Diameter: 500  
Software Version: 3.0.1  
Protocol Name: EPAULE/Orthoped  
Reconstruction Diameter: 269  
Gantry/Detector Tilt: 0  
Table Height: 51.000000  
Rotation Direction: CW  
X-ray Tube Current: 99  
Exposure: 351  
Filter Type: F  
Convolution Kernel: F  
Patient Position: HFS  
Study Instance UID: 1.2.840.113704.1.111.3252.1280651812.6  
Series Instance UID: 1.2.276.0.45.45.2.51.3.23084206062387.20131211.112340001  
Study ID: 7185  
Series Number: 2  
Image Number: 0  
Image Position Patient: -100.174\111.531\214.8  
Image Orientation Patient: 1\0\0\0\1\0  
Frame of Reference UID: 1.2.840.113704.1.111.3040.1280651919.3  
Slice Location: 5.80  
Photometric Interpretation: MONOCHROME2  
Pixel Spacing: 0.35026\0.35026  
Window Center: 00600\00600  
Window Width: 02000\02000

It should have to be something like this other image I am sending to you. Can you see the difference? Bone are thinner

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

If I can fix this “little” things and I would like to teach my students who to work with 3dslicer.

---

<div class="post-metadata">

**Author:** ![doc-xie](https://avatars.discourse-cdn.com/v4/letter/d/c77e96/32.png) [@doc-xie](https://discourse.slicer.org/u/doc-xie)\
**Post date:** [November 10, 2017, 1:14pm UTC](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817/40 "2017-11-10T13:14:55Z")

</div>

Hello!  
The problem is the same with me.The value of the Gantry/Detector Tilt is 0,but the image is distorted, what is the reason about this? How to estimate the deformation degree?  
If we want to adjust the distorted image,which value can be referenced to?  
Best wishes!  
Doc-xie

[Previous page](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817.md?page=1)

[Next page](https://discourse.slicer.org/t/how-to-adjust-the-distorted-image/817.md?page=3)
