ANTsX / ANTsR

R interface to the ANTs biomedical image processing library
https://antsx.github.io/ANTsR
Apache License 2.0
127 stars 35 forks source link

Apply an affine transform to points. #207

Closed muratmaga closed 6 years ago

muratmaga commented 6 years ago

Hi all,

Sorry to bother y'all with this. But I am utterly confused. There is a volume on which I did collected landmarks in Slicer (original.fcsv). I rigidly registered this volume to a reference in AntsR using the antsRegistration and saved the resultant affine fwdtransform (tranform.mat) as well as the warped moving image.

If I import the original.fcsv and apply the affine transform in slicer to it, everything lines up (final.fcsv) correctly with respect to the transformed image. But I want to do this programmatically in AntsR. This is what I tried with the antsApplyTransformsToPoints

lms=Morpho::read.fcsv('original.fcsv') transform='transform.mat' lms=t(t(lms) * c(-1, -1, 1)) #this is for RAS2LPS conversion.

setting the whichtoinvert to T or F makes no difference below

new.pts=antsApplyTransformsToPoints(dim = 3, points = lms, transformlist = transform)

new.pts[1:5,] Morpho::read.fcsv('final.fcsv')[1:5,]

obviously they are not the same. Can someone show me the correct way of doing this?

I attached the original landmark set, the affine transform I am trying to apply and what the coordinates should be after if the transformation is correctly applied. Images are too big to attach, but can upload somewhere else, and if they are useful.

files.zip

stnava commented 6 years ago

Just upload heavily downsampled versions. The images define the reference spaces etc. so are needed to understand the issue.

On Wed, Mar 14, 2018 at 1:55 AM muratmaga notifications@github.com wrote:

Hi all,

Sorry to bother y'all with this. But I am utterly confused. There is a volume on which I did collected landmarks in Slicer (original.fcsv). I rigidly registered this volume to a reference in AntsR using the antsRegistration and saved the resultant affine fwdtransform (tranform.mat) as well as the warped moving image.

If I import the original.fcsv and apply the affine transform in slicer to it, everything lines up (final.fcsv) correctly with respect to the transformed image. But I want to do this programmatically in AntsR. This is what I tried with the antsApplyTransformsToPoints

lms=Morpho::read.fcsv('original.fcsv') transform='transform.mat' lms=t(t(lms) * c(-1, -1, 1)) #this is for RAS2LPS conversion.

setting the whichtoinvert to T or F makes no difference below

new.pts=antsApplyTransformsToPoints(dim = 3, points = lms, transformlist = transform)

new.pts[1:5,] Morpho::read.fcsv('final.fcsv')[1:5,]

obviously they are not the same. Can someone show me the correct way of doing this?

I attached the original landmark set, the affine transform I am trying to apply and what the coordinates should be after if the transformation is correctly applied. Images are too big to attach, but can upload somewhere else, and if they are useful.

files.zip https://github.com/ANTsX/ANTsR/files/1809738/files.zip

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ANTsX/ANTsR/issues/207, or mute the thread https://github.com/notifications/unsubscribe-auth/AATyfs8y9YnIxExsfd_L1rA76orHcM0Aks5teLDNgaJpZM4Sp4Hf .

--

brian

muratmaga commented 6 years ago

Got it working now. Thanks.

stnava commented 6 years ago

Ok .... What was the solution?

On Wed, Mar 14, 2018 at 5:38 PM muratmaga notifications@github.com wrote:

Got it working now. Thanks.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/ANTsX/ANTsR/issues/207#issuecomment-373183563, or mute the thread https://github.com/notifications/unsubscribe-auth/AATyfsbn_oH3O9aa_SMuFoJH2Ly8kvMBks5teY3OgaJpZM4Sp4Hf .

--

brian

muratmaga commented 6 years ago

I am not entirely clear. I think there was a duplication of the mat files names with respect to the landmarks files and after a while they went out of sync. So it worked for some but didn’t others, which got me completely confused. Deleted everthing, re-ran and all lines up well now.

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10


From: stnava notifications@github.com Sent: Wednesday, March 14, 2018 2:43:22 PM To: ANTsX/ANTsR Cc: muratmaga; State change Subject: Re: [ANTsX/ANTsR] Apply an affine transform to points. (#207)

Ok .... What was the solution?

On Wed, Mar 14, 2018 at 5:38 PM muratmaga notifications@github.com wrote:

Got it working now. Thanks.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/ANTsX/ANTsR/issues/207#issuecomment-373183563, or mute the thread https://github.com/notifications/unsubscribe-auth/AATyfsbn_oH3O9aa_SMuFoJH2Ly8kvMBks5teY3OgaJpZM4Sp4Hf .

--

brian

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FANTsX%2FANTsR%2Fissues%2F207%23issuecomment-373184859&data=02%7C01%7C%7C17a84bc9db8247c5bbf908d589f49d3f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636566606057867597&sdata=hO%2BxFaAkFb4mq5iRgnG7ahxaYw2Xl5ZD%2BTsyUo3WR4I%3D&reserved=0, or mute the threadhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAUTJFFPooZR3J8cPJavq482qQ6XjKqC3ks5teY76gaJpZM4Sp4Hf&data=02%7C01%7C%7C17a84bc9db8247c5bbf908d589f49d3f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636566606057867597&sdata=KG1UnKFp7RIQnGrKPuNYfNMK7OGa9ODbN0skWIKHcRo%3D&reserved=0.