Documentation/4.2/Developers/OpenIGTLinkIF

From Slicer Wiki
Jump to: navigation, search
Home < Documentation < 4.2 < Developers < OpenIGTLinkIF

This page provides developer's information for 3D Slicer's OpenIGTLink IF module.

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 (11/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".