fepegar / torchio

Medical imaging toolkit for deep learning
https://torchio.org
Apache License 2.0
2.07k stars 240 forks source link

Inconsistency in euleur affine parametrisation between Affine and Motion transform #812

Open romainVala opened 2 years ago

romainVala commented 2 years ago

Is there an existing issue for this?

Problem summary

I would like the euler parameter (degree, translation) to be the same convention between the 2 transform : Motion and Affine

I know that this is not a real problem (to have different convention) because if one only use the Random version having a change in x or y or even a swap between x and y would not matter (because you randomly parse [-alpha +alpha] with the same range in all 3 directions (x,y,z)

But for consistency, I think it should be the same, and for more advance use it may becomes important

I just open the issue in case you could easily find the discrepency. (but for me this is quickly a nightmare this itk conventions issues ... I had hard time to solve it for my motion implementation ...)

Code for reproduction

import torchio as tio

suj = tio.datasets.Colin27()
tmotion = tio.RandomMotion(num_transforms=1)

suj_motion = tmotion(suj)
suj_motion.t1.save('colin_motion.nii')

hist = suj_motion.history[0]
deg, trans, times = hist.degrees['t1'],hist.translation['t1'],hist.times['t1'],

taff = tio.Affine(scales=(1,1,1), degrees=deg[0], translation=trans[0], center="image")
suj_aff=taff(suj)

suj_aff.t1.save('colin_affine.nii')

Actual outcome

I expect the motion image should be a mixt of tissue comming from the original position and from the new position (colin_affin.nii)

but I clearly see it is not the case

(Actually I compare with an other implementation of motion (the PR is comming soon ) and as both should produce the same artefact (for the same transient affine displacement) I notice it is not the case.

Error messages

No response

Expected outcome

I could add screen shot to show the problem but not sure if it helps ...

System info

No response

romainVala commented 2 years ago

I guess nobody cares ...

fepegar commented 2 years ago

Hi, @romainVala. Thanks for reporting! I'm going to reopen so this issue stays in the backlog, in case someone wants to tackle it one day.