How to get the point of a 3D model based on the fiducial position

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get the point of a 3D model based on the fiducial position

Pietro Nardelli
Hi guys,

I have a 3D model and a few fiducials placed on it. From the position of each fiducial, I'd like to extract the point of the 3D model on which the fiducial was placed. Is there a simple way to do it? I know that I could use the vtk.vtkCellPicker() function, but I'm not really sure how to use it within Slicer.

Thank you very much for your help,
Pietro

_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.
Reply | Threaded
Open this post in threaded view
|

Re: How to get the point of a 3D model based on the fiducial position

Aucoin, Nicole
Hi Pietro,

The model displayable manager keeps track of the last picked point on a
model, and the fiducial list keeps track of the model node id where the
fiducial was placed. I just tried a few things in the python console[1],
and the model displayable manager only exposes GetPickedNodeID to
python, but not GetPickedCellID, GetPickedPointID. If you're working in
C++ you can get at those values though, and it might be possible to
modify the header file to expose them via python.
The model dipslayable manager also has public access to the Pick method,
which will set those IDs above. You can call it with an x,y location
manually, or you can call the GetCellPicker or GetPointPicker methods
(again, not from python).
I'd suggest looking at the Pick method to see how Slicer translates from
x,y to model points:
http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Libs/MRML/DisplayableManager/vtkMRMLModelDisplayableManager.cxx?revision=23145&view=markup

at line 2002.

Hope this helps,
Nicole


[1]
fidList = getNode('F')
modelNodeID = fidList.GetNthFiducialAssociatedNodeID(0)
modelNode = getNode(modelNodeID)

lm = slicer.app.layoutManager()
for v in range(lm.threeDViewCount):
  td = lm.threeDWidget(v)
  ms = vtk.vtkCollection()
  td.getDisplayableManagers(ms)
  for i in range(ms.GetNumberOfItems()):
   m = ms.GetItemAsObject(i)
   if m.GetClassName() == "vtkMRMLModelDisplayableManager":
     print m
     print "Picked node ID = ", m.GetPickedNodeID()

On 6/3/14 12:47 PM, Pietro Nardelli wrote:

> Hi guys,
>
> I have a 3D model and a few fiducials placed on it. From the position
> of each fiducial, I'd like to extract the point of the 3D model on
> which the fiducial was placed. Is there a simple way to do it? I know
> that I could use the vtk.vtkCellPicker() function, but I'm not really
> sure how to use it within Slicer.
>
> Thank you very much for your help,
> Pietro
>
>
> _______________________________________________
> slicer-devel mailing list
> [hidden email]
> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
> To unsubscribe: send email to [hidden email] with unsubscribe as the subject
> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ

_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

Reply | Threaded
Open this post in threaded view
|

Re: How to get the point of a 3D model based on the fiducial position

Pietro Nardelli
Thank you very much Nicole. I will let you know if that works!!

Thanks again,
Pietro


On Tue, Jun 3, 2014 at 9:14 PM, Nicole Aucoin <[hidden email]> wrote:
Hi Pietro,

The model displayable manager keeps track of the last picked point on a model, and the fiducial list keeps track of the model node id where the fiducial was placed. I just tried a few things in the python console[1], and the model displayable manager only exposes GetPickedNodeID to python, but not GetPickedCellID, GetPickedPointID. If you're working in C++ you can get at those values though, and it might be possible to modify the header file to expose them via python.
The model dipslayable manager also has public access to the Pick method, which will set those IDs above. You can call it with an x,y location manually, or you can call the GetCellPicker or GetPointPicker methods (again, not from python).
I'd suggest looking at the Pick method to see how Slicer translates from x,y to model points:
http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Libs/MRML/DisplayableManager/vtkMRMLModelDisplayableManager.cxx?revision=23145&view=markup

at line 2002.

Hope this helps,
Nicole


[1]
fidList = getNode('F')
modelNodeID = fidList.GetNthFiducialAssociatedNodeID(0)
modelNode = getNode(modelNodeID)

lm = slicer.app.layoutManager()
for v in range(lm.threeDViewCount):
 td = lm.threeDWidget(v)
 ms = vtk.vtkCollection()
 td.getDisplayableManagers(ms)
 for i in range(ms.GetNumberOfItems()):
  m = ms.GetItemAsObject(i)
  if m.GetClassName() == "vtkMRMLModelDisplayableManager":
    print m
    print "Picked node ID = ", m.GetPickedNodeID()


On 6/3/14 12:47 PM, Pietro Nardelli wrote:
Hi guys,

I have a 3D model and a few fiducials placed on it. From the position of each fiducial, I'd like to extract the point of the 3D model on which the fiducial was placed. Is there a simple way to do it? I know that I could use the vtk.vtkCellPicker() function, but I'm not really sure how to use it within Slicer.

Thank you very much for your help,
Pietro


_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ



The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.



_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.