Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The rotation given by Random Affine not accurate #1053

Closed
1 task done
zhilothebest opened this issue Mar 14, 2023 · 5 comments
Closed
1 task done

The rotation given by Random Affine not accurate #1053

zhilothebest opened this issue Mar 14, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@zhilothebest
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Bug summary

When I ask torchio to run a random affine with rotations between -5 to +5 degrees, I get a much wider degree rotation, probably something in the ~20+ degree range, and it appears more like a skew than a true rotation

Code for reproduction

img = [ CT scan] #in tio.Subject

transform = tio.RandomAffine(scales=(1,1,1,1,1,1),
                                 degrees=(0,0,0,0,-5,5), 
                                 center = 'image',
                                 image_interpolation='bspline',
                                 label_interpolation = 'bspline',
                                 default_pad_value = 'mean',
                                p=1)

formed = transform(img)
formed = np.moveaxis(formed.image.numpy(), [3,0],[0,3])

imshow(formed[slice])

Actual outcome

original image
original image

transformed image
image

Pictures to show the outcome.

Error messages

No response

Expected outcome

Ideally, if it was truly rotations around the Z axis's image center, the circle should maintain its shape as a circle and not be deformed.

System info

No response

@zhilothebest zhilothebest added the bug Something isn't working label Mar 14, 2023
@romainVala
Copy link
Contributor

Hello

that sound weird, I do not reproduce with for instance with
suj =tio.datasets.mni.Colin27()

I would say it comes from your image (can you share it ?)
may be the z axis is not was you think

@zhilothebest
Copy link
Author

Sadly, I am unable to share the full data file due to agreements between the owner of the dataset and I. But would love help in how to implement in any other way. Ive tried isolating with x and y axis but , y axis rotates along the j index and x axis rotates along the I index.

@romainVala
Copy link
Contributor

what is the shape of the data, can you report a print of the affine

@zhilothebest
Copy link
Author

zhilothebest commented Mar 15, 2023

image

the shapes have extra axis's for an external slicer I am using instead of matplotlib.

@zhilothebest
Copy link
Author

The affines were in the incorrect order. That fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants