linkCursorLastClickedPosition() in BrainVISA 4.6?

Questions about Anatomist manipulation

Moderators: riviere, denghien

francois
Posts: 61
Joined: Tue Jul 25, 2017 9:37 am

linkCursorLastClickedPosition() in BrainVISA 4.6?

Postby francois » Tue Apr 10, 2018 11:08 am

Hello,

I'm trying to understand differences of behavior of the anatomist API between BrainVISA 4.5 and 4.6.

With 4.6, linkCursorLastClickedPosition() seems the return positions in the referential currently selected in the view.
I have two views of the same volume, one with the referential "t1mri native" selected, the other one with the referential "Talairach-ACPC-Anatomist" referential selected. If I click on one view, call linkCursorLastClickedPosition(), click on the same point in the other view, call linkCursorLastClickedPosition(), I get two completely different positions. This is illustrated in the screen capture and console output below.
https://www.dropbox.com/s/yrkxyz44apweg ... n.gif?dl=0

Code: Select all

>>> self.a.linkCursorLastClickedPosition()
<soma.aims.AimsVector_FLOAT_3 object at 0xca12d40>
[b](3.1346323490142822, 2.8059873580932617, 101.33295440673828)[/b]
Position : -94.6721, -147.751, 5.3333, 0
>>> self.a.centralRef.getInfo()
'ObjectInfo'
{ 4 : { 'axes_orientation' : [ 'right-left', 'anterior-posterior', 'top-bottom' ], 'dimension_count' : 3, 'direct_referential' : 0, 'name' : [b]'Talairach-AC/PC-Anatomist'[/b], 'type' : 'Referential', 'uuid' : 'a2a820ac-a686-461e-bcf8-856400740a6c' } }
{'direct_referential': 0, 'uuid': 'a2a820ac-a686-461e-bcf8-856400740a6c', 'axes_orientation': ['right-left', 'anterior-posterior', 'top-bottom'], 'dimension_count': 3, 'type': 'Referential', 'name': 'Talairach-AC/PC-Anatomist'}

>>> self.a.linkCursorLastClickedPosition()
<soma.aims.AimsVector_FLOAT_3 object at 0xca12e60>
[b](-94.67205047607422, -147.7505340576172, 5.3333001136779785)[/b]
>>> self.a.centralRef.getInfo()
'ObjectInfo'
{ 4 : { 'axes_orientation' : [ 'right-left', 'anterior-posterior', 'top-bottom' ], 'dimension_count' : 3, 'direct_referential' : 0, 'name' : [b]'Talairach-AC/PC-Anatomist'[/b], 'type' : 'Referential', 'uuid' : 'a2a820ac-a686-461e-bcf8-856400740a6c' } }
{'direct_referential': 0, 'uuid': 'a2a820ac-a686-461e-bcf8-856400740a6c', 'axes_orientation': ['right-left', 'anterior-posterior', 'top-bottom'], 'dimension_count': 3, 'type': 'Referential', 'name': 'Talairach-AC/PC-Anatomist'}


However, this behavior is contradicting the API documentation:
http://brainvisa.info/pyanatomist/sphin ... edPosition
According to the documentation, linkCursorLastClickedPosition() is supposed to always return the positions relative to the central referential, which is the same in both cases.

This would be OK by itself, but when calling linkCursorLastClickedPosition with a specific referential in argument, eg. linkCursorLastClickedPosition(self.dispObj['T1pre'].getReferential()).items(), it returns coordinates that do not correspond to anything...

Is there an issue at this level? Has this changed in BrainVISA 4.6?

Thanks
Francois

francois
Posts: 61
Joined: Tue Jul 25, 2017 9:37 am

Re: linkCursorLastClickedPosition() in BrainVISA 4.6?

Postby francois » Tue Apr 10, 2018 1:52 pm

I could fix quickly the code we have if I knew what referential is used by linkCursorLastClickedPosition().

How do I get the view that was clicked last (used by linkCursorLastClickedPosition)?
And/or: How do I get the referential used in this view?

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

Re: linkCursorLastClickedPosition() in BrainVISA 4.6?

Postby riviere » Tue Apr 10, 2018 7:08 pm

Hi François,
You're right, there seems to be a bug here. I'll investigate.
Denis

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

Re: linkCursorLastClickedPosition() in BrainVISA 4.6?

Postby riviere » Wed Apr 11, 2018 12:17 am

Hi,
OK this was actually a bug introduced in 4.6 when the code was changed to handle objects (volumes) with an arbitrary number of dimensions.
I have just fixed it in the sources, it will be available in the next update (we'll try to make it sooner than 2 years away this time...)
Denis

francois
Posts: 61
Joined: Tue Jul 25, 2017 9:37 am

Re: linkCursorLastClickedPosition() in BrainVISA 4.6?

Postby francois » Wed Apr 11, 2018 10:22 am

Thanks for looking into this.

What do we do before that?
Could you think of a quick workaround? Something that would re-convert to the appropriate coordinate system after calling linkCursorLastClickedPosition()?
We have a few people actively waiting for me to fix IntrAnat here...

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

Re: linkCursorLastClickedPosition() in BrainVISA 4.6?

Postby riviere » Wed Apr 11, 2018 11:01 am

Hi,
Well, it depends on what you are doing and how you are using things. The bug was actually in storing the click coordinates, so after it is done, it's too late, the referential information is lost. I see 2 alternatives:
* if you know in which window the click has been done, you can query the position in a specific window (window.getPosition())
* listen clicks on your side and storing their coordinates on your own. This can be done using an event handler. See this example. You will have to take the referential of the click coordinates into account (using the referential of the clicked window).
Denis

francois
Posts: 61
Joined: Tue Jul 25, 2017 9:37 am

Re: linkCursorLastClickedPosition() in BrainVISA 4.6?

Postby francois » Wed Apr 11, 2018 4:54 pm

Ok, thanks for the suggestions.
For a very quick fix: can I assume that if I call linkCursorLastClickedPosition() without parameters, it will always return the coordinates in the referential that is currently selected in the clicked window? Or is there a risk for the coordinates to be totally random?

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

Re: linkCursorLastClickedPosition() in BrainVISA 4.6?

Postby riviere » Wed Apr 11, 2018 5:26 pm

I guess the bug did take coordinates in the window referential, and says they are in the "central" (red) referential.
So if you know which window has been used to select the point, the right referential is the one assigned to the window at the time of the click. In practice it might have been changed after that by the user (but maybe this is blocked in Intranat).
Anyway if you know which window the cursor position has to be taken from, you're saved, using the 1st solution I suggested: get the window, get its window.position(), get its referential (window.getReferential()), then you can find a transformation to any other referential, ex: a.getTransformation(window.getReferential(), a.centralReferential()) and use it to transform coordinates. linkCursorLastClickedPosition() is mainly useful when you don't know which window to query the cursor position in.
Denis

francois
Posts: 61
Joined: Tue Jul 25, 2017 9:37 am

Re: linkCursorLastClickedPosition() in BrainVISA 4.6?

Postby francois » Wed Apr 11, 2018 5:46 pm

We have multiple windows and no indication on which one was clicked, so linkCursorLastClickedPosition() was what we needed.

But it could be OK if I could enforce one given referential in all the windows and then convert all the coordinates accordingly.
How can I disable the ability of the users to change the referential on the different windows?

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

Re: linkCursorLastClickedPosition() in BrainVISA 4.6?

Postby riviere » Wed Apr 11, 2018 6:06 pm

If the windows are all in the same windows group (especially if there are no groups defined...) then you can query any of them, the cursor is linked between all windows in the group, so its position should be the same in all of them (possibly seen from different referentials).

francois
Posts: 61
Joined: Tue Jul 25, 2017 9:37 am

Re: linkCursorLastClickedPosition() in BrainVISA 4.6?

Postby francois » Thu Apr 12, 2018 8:41 am

Is is possible to disable the ability of the user to change the referential for each window (by clicking on the colored bar on top of the view)?

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

Re: linkCursorLastClickedPosition() in BrainVISA 4.6?

Postby riviere » Thu Apr 12, 2018 9:09 am

The simplest way is to hide the referential button (the color bar), or all buttons around the window if you also want to fix controls etc.


Return to “Anatomist”

Who is online

Users browsing this forum: No registered users and 2 guests