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])
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 tried with self.a.loadTransformation but I didn't get how it worksself.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
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])
Do you have any idea ?
Cheers