Closed yesulove closed 1 month ago
Here is a simple example:
>>> import ants
>>> fi = ants.image_read(ants.get_ants_data('r16'))
>>> mi = ants.image_read(ants.get_ants_data('r64'))
>>> mytx = ants.registration(fixed=fi, moving=mi, type_of_transform = 'SyN' )
>>> mytx['fwdtransforms']
['/var/folders/zd/9qflmdq95ks8q89wwk9461l80000gn/T/tmpieytk74h1Warp.nii.gz', '/var/folders/zd/9qflmdq95ks8q89wwk9461l80000gn/T/tmpieytk74h0GenericAffine.mat']
The mytx['fwdtransforms']
list is file names, you don't need to write them with write_transform, you can just copy them wherever you want them to live.
Now, mytx['fwdtransforms']
in this example has two entries because it does a 'SyN' registration. If I do a linear registration,
>>> mytx = ants.registration(fixed=fi, moving=mi, type_of_transform = 'Translation' )
>>> mytx['fwdtransforms']
['/var/folders/zd/9qflmdq95ks8q89wwk9461l80000gn/T/tmplh7jcjcl0GenericAffine.mat']
there is only the 0GenericAffine.mat
. The ants.create_jacobian_determinant_image function only works on warp images, not linear transforms.
Here is a simple example:
>>> import ants >>> fi = ants.image_read(ants.get_ants_data('r16')) >>> mi = ants.image_read(ants.get_ants_data('r64')) >>> mytx = ants.registration(fixed=fi, moving=mi, type_of_transform = 'SyN' ) >>> mytx['fwdtransforms'] ['/var/folders/zd/9qflmdq95ks8q89wwk9461l80000gn/T/tmpieytk74h1Warp.nii.gz', '/var/folders/zd/9qflmdq95ks8q89wwk9461l80000gn/T/tmpieytk74h0GenericAffine.mat']
The
mytx['fwdtransforms']
list is file names, you don't need to write them with write_transform, you can just copy them wherever you want them to live.Now,
mytx['fwdtransforms']
in this example has two entries because it does a 'SyN' registration. If I do a linear registration,>>> mytx = ants.registration(fixed=fi, moving=mi, type_of_transform = 'Translation' ) >>> mytx['fwdtransforms'] ['/var/folders/zd/9qflmdq95ks8q89wwk9461l80000gn/T/tmplh7jcjcl0GenericAffine.mat']
there is only the
0GenericAffine.mat
. The ants.create_jacobian_determinant_image function only works on warp images, not linear transforms.
Thank you very much. Your answer has solved my confusion!
Glad this was solved. I personally think it makes more sense to return actual transform classes but oh well. FYI - you could write it to another file by reading the transform first:
tx = ants.read_transform(trans[0])
ants.write_transform(tx,t+'.mat')
Glad this was solved. I personally think it makes more sense to return actual transform classes but oh well. FYI - you could write it to another file by reading the transform first:
tx = ants.read_transform(trans[0]) ants.write_transform(tx,t+'.mat')
Thank you very much. I was wondering why write_transform is not working. Your response made me realize that it was because we needed to read_transform first. Your reply is too timely hahaha!
1.code:
2.error1: