scikit-surgerynditracker documentation

Source code is avaialble on GitHub.

scikit-surgerynditracker

Logo

GitHub CI test status Test coverage Documentation Status The SciKit-Surgery paper Follow scikit_surgery on twitter

scikit-surgerynditracker is a python interface for Northern Digital (NDI) trackers. It should work with Polaris Vicra, Spectra, and Vega optical trackers and Aurora electromagnetic trackers. Tracking data is output as NumPy arrays.

Author: Stephen Thompson

scikit-surgerynditracker is part of the SciKit-Surgery software project, developed at the Wellcome EPSRC Centre for Interventional and Surgical Sciences, part of University College London (UCL).

Installing

pip install scikit-surgerynditracker

Using

Configuration is done using Python libraries at instantiation. Invalid configuration should raise exceptions. Tracking data is returned in a set of lists, containing the port handles, timestamps, framenumbers, the tracking data and a tracking quality metric. By default tracking data is returned as a 4x4 NumPy array, though can be returned as a quaternion by changing the configuration.

from sksurgerynditracker.nditracker import NDITracker
SETTINGS = {
    "tracker type": "polaris",
    "romfiles" : ["../data/8700339.rom"]
        }
TRACKER = NDITracker(SETTINGS)

TRACKER.start_tracking()
port_handles, timestamps, framenumbers, tracking, quality = TRACKER.get_frame()
for t in tracking:
  print (t)
TRACKER.stop_tracking()
TRACKER.close()

See demo.py for a full example

Developing

Cloning

You can clone the repository using the following command:

git clone https://github.com/SciKit-Surgery/scikit-surgerynditracker

Running the tests

You can run the unit tests by installing and running tox:

pip install tox
tox

Contributing

Please see the contributing guidelines.

Acknowledgements

Supported by Wellcome and EPSRC.

NDI Tracking

Class implementing communication with NDI (Northern Digital) trackers

class sksurgerynditracker.nditracker.NDITracker(configuration)[source]

Bases: sksurgerycore.baseclasses.tracker.SKSBaseTracker

Class for communication with NDI trackers. Should support Polaris, Aurora, and Vega. Currently only tested with wireless tools on Vega

close()[source]

Closes the connection to the NDI Tracker and deletes the tracker device.

Raises:Exception – ValueError
get_frame()[source]

Gets a frame of tracking data from the NDI device.

Returns:port_numbers : list of port handles, one per tool

time_stamps : list of timestamps (cpu clock), one per tool

frame_numbers : list of framenumbers (tracker clock) one per tool

tracking : list of 4x4 tracking matrices, rotation and position, or if use_quaternions is true, a list of tracking quaternions, column 0-2 is x,y,z column 3-6 is the rotation as a quaternion.

tracking_quality : list the tracking quality, one per tool.

Note: The time stamp is based on the host computer clock. Read the following extract from NDI’s API Guide for advice on what to use: “Use the frame number, and not the host computer clock, to identify when data was collected. The frame number is incremented by 1 at a constant rate of 60 Hz. Associating a time from the host computer clock to replies from the system assumes that the duration of time between raw data collection and when the reply is received by the host computer is constant. This is not necessarily the case.”

get_tool_descriptions()[source]

Returns the port handles and tool descriptions

start_tracking()[source]

Tells the NDI devices to start tracking.

Raises:Exception – ValueError
stop_tracking()[source]

Tells the NDI devices to stop tracking.

Raises:Exception – ValueError
sksurgerynditracker.nditracker.int2byte()

S.pack(v1, v2, …) -> bytes

Return a bytes object containing values v1, v2, … packed according to the format string S.format. See help(struct) for more on format strings.