scikit-surgerytrackervisualisation

Logo

GitHub Actions CI status Test coverage Documentation Status The SciKit-Surgery paper https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg Follow scikit_surgery on twitter

Author: Stephen Thompson

scikit-surgerytrackervisualisation 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).

scikit-surgerytrackervisualisation supports Python 2.7 and Python 3.6.

scikit-surgerytrackervisualisation implements a basic interface for showing tracking output from a SciKit-Surgery tracker.

python scikit-surgerytrackervisualisation.py
python scikit-surgerytrackervisualisation.py --config config.json

Please explore the project structure, and implement your own functionality.

Developing

Cloning

You can clone the repository using the following command:

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

Running tests

Pytest is used for running unit tests:

pip install pytest
python -m pytest

Linting

This code conforms to the PEP8 standard. Pylint can be used to analyse the code:

pip install pylint
pylint --rcfile=tests/pylintrc scikit-surgerytrackervisualisation

Installing

You can pip install directly from the repository as follows:

pip install git+https://github.com/SciKit-Surgery/scikit-surgerytrackervisualisation

Contributing

Please see the contributing guidelines.

Acknowledgements

Supported by Wellcome and EPSRC.

Dependency Graph

digraph prof {
	ratio = fill;
	node [style=filled];
	"scikit-surgerytrackervisualisation" -> numpy;
	"scikit-surgerytrackervisualisation" -> "scikit-surgeryvtk" [color="0.515 0.762 0.762"];
	"scikit-surgerytrackervisualisation" -> "scikit-surgeryimage" [color="0.515 0.762 0.762"];
	"scikit-surgerytrackervisualisation" -> "scikit-surgerycore" [color="0.515 0.762 0.762"];
	"scikit-surgerytrackervisualisation" -> "scikit-surgeryutils" [color="0.515 0.762 0.762"];
	"scikit-surgerytrackervisualisation" -> "scikit-surgerynditracker" [color="0.515 0.762 0.762"];
	"scikit-surgerytrackervisualisation" -> "scikit-surgeryarucotracker" [color="0.515 0.762 0.762"];
	
	"scikit-surgeryvtk" -> "numpy";
	"scikit-surgeryvtk" -> "opencv-contrib-python";
	"scikit-surgeryvtk" -> "vtk";
	"scikit-surgeryvtk" -> "PySide2";
	"scikit-surgeryvtk" -> "scikit-surgeryimage" [color="0.515 0.762 0.762"];
	"scikit-surgeryvtk" -> "scikit-surgerycore" [color="0.515 0.762 0.762"];

	"scikit-surgeryimage" -> "numpy";
	"scikit-surgeryimage" -> "opencv-contrib-python";
	"scikit-surgeryimage" -> "scikit-surgerycore" [color="0.515 0.762 0.762"];

	"scikit-surgerycore" -> "numpy";
	
	"scikit-surgeryutils" -> "numpy";
	"scikit-surgeryutils" -> "opencv-contrib-python";
	"scikit-surgeryutils" -> "PySide2";
	"scikit-surgeryutils" -> "scikit-surgeryimage" [color="0.515 0.762 0.762"];
	"scikit-surgeryutils" -> "scikit-surgeryvtk" [color="0.515 0.762 0.762"];

	"scikit-surgerynditracker" -> ndicapi;
	"scikit-surgerynditracker" -> numpy;

	"scikit-surgeryarucotracker" -> numpy;
	"scikit-surgeryarucotracker" -> "opencv-contrib-python";
	"scikit-surgeryarucotracker" -> "scikit-surgerycore" [color="0.515 0.762 0.762"];

"scikit-surgerytrackervisualisation" [color="0.515 0.762 0.762"];
"scikit-surgeryvtk" [color="0.515 0.762 0.762"];
"scikit-surgeryutils"  [color="0.515 0.762 0.762"]; 
"scikit-surgerynditracker" [color="0.515 0.762 0.762"];
"scikit-surgeryarucotracker"[color="0.515 0.762 0.762"];
"scikit-surgeryimage"[color="0.515 0.762 0.762"];
"scikit-surgerycore"[color="0.515 0.762 0.762"];
}

The dependency graph

Requirements for scikit-surgerytrackervisualisation

This is the software requirements file for scikit-surgerytrackervisualisation, part of the SNAPPY project. The requirements listed below should define what scikit-surgerytrackervisualisation does. Each requirement can be matched to a unit test that checks whether the requirement is met.

Requirements

ID Description Test
0000 Module has a help page pylint, see tests/pylint.rc and tox.ini
0001 Functions are documented pylint, see tests/pylint.rc and tox.ini
0002 Package has a version number No test yet, handled by git.

latest

sksurgerytrackervisualisation package

Subpackages
sksurgerytrackervisualisation.algorithms package
Submodules
sksurgerytrackervisualisation.algorithms.algorithms module

Algorithms used by the trackervisualisation module

sksurgerytrackervisualisation.algorithms.algorithms.configure_tracker(config)[source]

Configures the tracking system. :param: A dictionary containing configuration data :return: The tracker object :raises: KeyError if no tracker entry in config

sksurgerytrackervisualisation.algorithms.algorithms.make_offset_matrix(model_config)[source]

generates an offset (or handeye) matrix

Param:Model configuration
Returns:If valid offset specified, returns a 4x4 offset matrix, if no offset, returns identity.
Raises:ValueError
sksurgerytrackervisualisation.algorithms.algorithms.np2vtk(mat)[source]

Converts a Numpy array to a vtk matrix :param: the number array, should be 4x4 :return: a vtk 4x4 matrix :raises: ValueError when matrix is not 4x4

sksurgerytrackervisualisation.algorithms.algorithms.populate_models(model_config)[source]
Parses a model configuration dictionary, returning

a list of vtk actors and associated port handles

param:model config a list of dictionaries, one for each model dictionary entries are: name : a descriptive name port handle : the port handle of the associated tracker load : True if model is to be loaded from file filename : if load is true the filename to load from source : supported values are cylinder, sphere, cone colour : the rgb colour to use for the actor height : the height of the cylinder or cone radius : the diameter of the cylinder, cone, or sphere
Returns:a list of dictionaries, one for each model
Returns:port_handles
Returns:actors
Returns:transform_managers
Raises:KeyError if asked to load model without filename
sksurgerytrackervisualisation.algorithms.background_image module

A class to provide the background image

class sksurgerytrackervisualisation.algorithms.background_image.OverlayBackground(config)[source]

Bases: object

Provides the background image for the overlay window.

next_image()[source]

Returns a background image. The behaviour is determined by the configuration dictionary used at init.

sksurgerytrackervisualisation.algorithms.icp module

Algorithms for doing Iterative Closest Point

sksurgerytrackervisualisation.algorithms.icp.vtk_icp(source, target, locator=None, max_iterations=100, max_landmarks=1000, check_mean_distance=False, maximum_mean_distance=0.001)[source]

An iterative closest point algorithm, delegating to vtk. Target is a point set, source is a point cloud

Module contents
sksurgerytrackervisualisation.overlay_app package
Submodules
sksurgerytrackervisualisation.overlay_app.overlay module

Main loop for tracking visualisation

class sksurgerytrackervisualisation.overlay_app.overlay.OverlayApp(config)[source]

Bases: sksurgeryutils.common_overlay_apps.OverlayBaseApp

Inherits from OverlayBaseApp, adding code to move vtk models based on input from a scikitsurgery tracker. Adds a function to detect a key press event, (“g”) and add points to a point cloud.

key_press_event(_obj_not_used, _ev_not_used)[source]

Handles a key press event

update()[source]

Update the background renderer with a new frame, move the model and render

Module contents
sksurgerytrackervisualisation.shapes package
Submodules
sksurgerytrackervisualisation.shapes.cone module

VTK pipeline to represent a surface model via a vtkPolyData.

class sksurgerytrackervisualisation.shapes.cone.VTKConeModel(height, radius, colour, name, visibility=True, opacity=1.0)[source]

Bases: sksurgeryvtk.models.vtk_surface_model.VTKSurfaceModel

Class to create a VTK surface model of a cone.

sksurgerytrackervisualisation.shapes.dynamic_point_cloud module

Class to represent a point cloud via a vtkPolyData, with the ability to dynamically add points

class sksurgerytrackervisualisation.shapes.dynamic_point_cloud.VTKDynamicPointCloud(colour, visibility=True, opacity=1.0)[source]

Bases: sksurgeryvtk.models.vtk_base_model.VTKBaseModel

Class to represent a point cloud via a vtkPolyData, with the ability to dynamically add points

add_point(point)[source]

Adds a point to the point cloud and updates the vtk actor to show the complete point cloud

Param:A 3 tuple representing the point coordinate
get_polydata()[source]

Returns a polydata consisting of the poind cloud

sksurgerytrackervisualisation.shapes.sphere module

VTK pipeline to represent a surface model via a vtkPolyData.

class sksurgerytrackervisualisation.shapes.sphere.VTKSphereModel(radius, colour, name, visibility=True, opacity=1.0)[source]

Bases: sksurgeryvtk.models.vtk_surface_model.VTKSurfaceModel

Class to create a VTK surface model of a sphere.

Module contents
sksurgerytrackervisualisation.ui package
Submodules
sksurgerytrackervisualisation.ui.sksurgerytrackervisualisation_cl module

Command line processing

sksurgerytrackervisualisation.ui.sksurgerytrackervisualisation_cl.main(args=None)[source]

Entry point for scikit-surgerytrackervisualisation application

sksurgerytrackervisualisation.ui.sksurgerytrackervisualisation_demo module

Tracker visualisation demo module

sksurgerytrackervisualisation.ui.sksurgerytrackervisualisation_demo.run(configfile)[source]

Run the application

Module contents

scikit-surgerytrackervisualisation

Module contents

scikit-surgerytrackervisualisation