# Rotation of image using python cuts off part of image

**URL:** <https://discourse.slicer.org/t/rotation-of-image-using-python-cuts-off-part-of-image/24310>\
**Category:** Support\
**Created:** [July 14, 2022, 12:08pm UTC](https://discourse.slicer.org/t/rotation-of-image-using-python-cuts-off-part-of-image/24310 "2022-07-14T12:08:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![KateDelb](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/katedelb/32/14981_2.png) [@KateDelb](https://discourse.slicer.org/u/KateDelb)\
**Post date:** [July 14, 2022, 12:08pm UTC](https://discourse.slicer.org/t/rotation-of-image-using-python-cuts-off-part-of-image/24310/1 "2022-07-14T12:08:14Z")

</div>

I have written a little script that rotates an image based on a transform (.tfm) that I’ve obtained from the Slicer GUI:

```auto
def resample(image, transform):
    # Output image Origin, Spacing, Size, Direction are taken from the reference
    # image in this call to Resample
    reference_image = image
    interpolator = sitk.sitkCosineWindowedSinc
    default_value = 100.0
    return sitk.Resample(image, reference_image, transform,
                         interpolator, default_value)

fet_180 = resample(fet, rotation_180)

```

Works perfectly, except for the fact that the images get cut off after the rotation. Example (zoomed out for clarity:  
Before rotation:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/2/725b8df0694bfc425acb14498415b44df2794e1e.png)

After Rotation:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/5/150d3c8816f0bee331dda7a9b4ea5dc096bfe0f7.png)

This doesn’t happen when rotating in the Slicer GUI itself, what can I do to fix this?
