problem with loadTransformation

Questions about Anatomist manipulation

Moderators: denghien, riviere

Post Reply
pdeman
Posts: 39
Joined: Thu Sep 17, 2015 4:09 pm
Location: moving sometimes

problem with loadTransformation

Post by pdeman »

Hi,

I have a problem with loadTransformation.

I am loading different object:

Code: Select all

image1 = self.a.loadObject(self.template.volumes[0])
image2= self.a.loadObject(str(fichier))
self.a.execute('LoadReferentialFromHeader', objects=[image1,image2])
they are not coregistered in the window, but they should be (both in the mni).
I can solve this problem easily by hand, on the referential window I link both scanner-based ref by the identity and it works. they appear now coregistered.

now I am trying to do it by command line using loadTransformation.
I tried what's written here http://brainvisa.info/pyanatomist-4.5/s ... howto.html in apply transformation to object.

Code: Select all

all_trans = self.a.getTransformations()
trans_from_vols = []
for vol in (image1, image2):
     trans_from_vol = [t for t in all_trans if t.source() == vol.referential and not t.isGenerated()]
     # hope trans_from_vol1 contains just one transform
     # but if there are several, try to select the one going to
     # scanner-based
     if len(trans_from_vol) > 1:
         trans_from_vol_filt = [t for t in trans_from_vol if t.destination().header()['name'].startswith('Scanner-based anatomical coordinates')]
         if len(trans_from_vol_filt) == 1:
            trans_from_vol = trans_from_vol_filt
            if len(trans_from_vol) != 1:
              raise RuntimeError('could not find a non-ambiguous transform')
         trans_from_vols.append(trans_from_vol)

trans_from_vol1, trans_from_vol2 = trans_from_vols
self.a.execute('LoadTransformation',origin=trans_from_vol1[0],destination=trans_from_vol2[0],matrix=[0, 0, 0, 1, 0, 0,  0, 1, 0,  0, 0, 1])
I have this error:
self.a.execute('LoadTransformation',origin=trans_from_vol1[0],destination=trans_from_vol2[0],matrix=[0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1])
Id 176 doesn't correspond to a Referential
Referential id 176 not found
I tried with self.a.loadTransformation but I didn't get how it works

Code: Select all

self.a.execute('LoadTransformation',origin=trans_from_vol1[0],destination=trans_from_vol2[0],matrix=[0, 0, 0, 1, 0, 0,  0, 1, 0,  0, 0, 1])
is not working as well.

Do you have any idea ?

Cheers
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: problem with loadTransformation

Post by riviere »

Hi,
Oh yes, there is obviously a bug in this example: here LoadTransformation is used with transformations instead of referentials as source and destination. The correct line here would be:

Code: Select all

a.execute('LoadTransformation', origin=trans_from_vol1.destintation(),
          destination=trans_from_vol2.destination(),
          matrix=[0, 0, 0, 1, 0, 0,  0, 1, 0,  0, 0, 1])
(since we link the destination referentials of the scanner-based transformations)
Denis
pdeman
Posts: 39
Joined: Thu Sep 17, 2015 4:09 pm
Location: moving sometimes

Re: problem with loadTransformation

Post by pdeman »

perfect it works well !!
thanks
Post Reply