Difference between revisions of "Documentation/4.2/Developers/OpenIGTLinkIF"
Line 45: | Line 45: | ||
Now the connector is connected to the ReceiveServer. You can check it from the Connector list in the OpenIGTLink IF module. If it is connected, the "Status" of the connector must be "ON". | Now the connector is connected to the ReceiveServer. You can check it from the Connector list in the OpenIGTLink IF module. If it is connected, the "Status" of the connector must be "ON". | ||
+ | |||
+ | Next step is to create a linear transform node to export. You can create it from "Transform" module, or from the Python Interactor: | ||
+ | |||
+ | >>> tnode = slicer.vtkMRMLLinearTransformNode() | ||
+ | >>> slicer.mrmlScene.AddNode(tnode) | ||
+ | (vtkMRMLLinearTransformNode)0x125e6cf70 | ||
+ | >>> | ||
+ | |||
+ | If you created the transform node from the Transform module, you need to get the node object in the Python Interactor. To do so, open "Data" module, click the "Display MRML ID's" under the "Nodes" interface, and check the node ID written on the right end of the "Nodes" interface. If the transform node is the first node you created after launching 3D Slicer, the node ID is usually "vtkMRMLLinearTransformNode4". You can obtain the node object in the Python Interactor by using GetNodeByID() function: | ||
+ | |||
+ | >>> tnode = slicer.mrmlScene.GetNodeByID('vtkMRMLLinearTransformNode4') |
Revision as of 03:34, 15 November 2012
Home < Documentation < 4.2 < Developers < OpenIGTLinkIFThis page provides developer's information for 3D Slicer's OpenIGTLink IF module.
Contents
Create external OpenIGTLink server/client software
With the OpenIGTLink IF module, you can exchange various types of data (e.g. linear transforms and images) between 3D Slicer and external software over the local area network. We provide OpenIGTLink Library to support OpenIGTLink-compatible software. Please refer the Tutorial.
Control OpenIGTLink IF from Python module
You can use the OpenIGTLink IF module's features from 3D Slicer's Python interface. The features can be called from both Slicer Python Interactor (Python console) and Python module.
Requirements
- 3D Slicer 4.2 nightly build (November 10, 2012 or later) available at http://slicer.org/ (4.2.0 release version has an issue in initialization of the OpenIGTLinkIF module. If you use this version, you need to open the OpenIGTLinkIF module, before using the Python interface)
- OpenIGTLink Simulators available in NA-MIC wiki or the OpenIGTLink Library
Creating an OpenIGTLink connector node from Python Interactor
To establish an OpenIGTLink connection, first you need to create a OpenIGTLink connector node (vtkMRMLIGTLConnectorNode). From Python Interactor:
>>> cnode = slicer.vtkMRMLIGTLConnectorNode() >>> slicer.mrmlScene.AddNode(cnode) (vtkMRMLIGTLConnectorNode)0x125e6ce10
You may name the connector as follows:
>>> cnode.SetName('Connector1')
If the connector node is properly added to the scene, you could see it in the Connector list in the OpenIGTLink IF module.
Exporting a linear transform to external software (3D Slicer as a client)
Suppose the simulator files are in <working directory>.
First, we launch the "ReceiveServer" simulator from a terminal (or a command prompt on Windows) and ask to wait for a connection from the 3D Slicer at port # 18944.
$ cd <working directory> $ ./ReceiveServer 18944
Then open the Python Interactor and type in the following commands to configure the connector node as a client:
>>> cnode.SetTypeClient('localhost', 18944) 1
Make sure that cnode.SetTypeClient() function returns 1. Then, start the client by:
>>> cnode.Start() 1
Now the connector is connected to the ReceiveServer. You can check it from the Connector list in the OpenIGTLink IF module. If it is connected, the "Status" of the connector must be "ON".
Next step is to create a linear transform node to export. You can create it from "Transform" module, or from the Python Interactor:
>>> tnode = slicer.vtkMRMLLinearTransformNode() >>> slicer.mrmlScene.AddNode(tnode) (vtkMRMLLinearTransformNode)0x125e6cf70 >>>
If you created the transform node from the Transform module, you need to get the node object in the Python Interactor. To do so, open "Data" module, click the "Display MRML ID's" under the "Nodes" interface, and check the node ID written on the right end of the "Nodes" interface. If the transform node is the first node you created after launching 3D Slicer, the node ID is usually "vtkMRMLLinearTransformNode4". You can obtain the node object in the Python Interactor by using GetNodeByID() function:
>>> tnode = slicer.mrmlScene.GetNodeByID('vtkMRMLLinearTransformNode4')