scikit-surgerybk¶

Author: Thomas Dowrick
scikit-surgerybk is a Python library for interfacing with BK ultrasound machines, and 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-surgerybk supports Python 2.7 and Python 3.6/3.7/3.8.
Developing¶
Cloning¶
You can clone the repository using the following command:
git clone https://github.com/SciKit-Surgery/scikit-surgerybk
Linting¶
This code conforms to the PEP8 standard. Pylint can be used to analyse the code:
pip install pylint
pylint --rcfile=tests/pylintrc sksurgerybk
Installing¶
You can pip install directly from the repository as follows:
pip install git+https://github.com/SciKit-Surgery/scikit-surgerybk
Contributing¶
Please see the contributing guidelines.
Useful links¶
Licensing and copyright¶
Copyright 2019 University College London. scikit-surgerybk is released under the BSD-3 license. Please see the license file for details.
Acknowledgements¶
Supported by Wellcome and EPSRC.
Requirements for scikit-surgerybk¶
This is the software requirements file for scikit-surgerybk, part of the SNAPPY project. The requirements listed below should define what scikit-surgerybk 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¶
sksurgerybk package¶
Subpackages¶
sksurgerybk.interface package¶
This module sets the connection to the BK scanner
-
class
sksurgerybk.interface.bk5000.
BK5000
(timeout, frames_per_second)[source]¶ Bases:
object
This class sets the TCP connection with the BK scanner
-
clear_bytes_in_buffer
(start, end)[source]¶ Clear a set of bytes in bytearray buffer
Parameters: - start (integer) – Start index
- end (integer) – End integer
-
connect_to_host
(address, port)[source]¶ Connects the client to the host/serverself.
Implements a try/except block to catch potential errors.
Parameters: address(string): the IP address port(integer): the port
-
decode_image
()[source]¶ Process the stream of data received from the BK5000 and convert it into a numpy array which represents the ultrasound image.
Control bytes are 1, 4 and 27. Flipped control bytes (1s complement of control bytes) are 254, 251, 228. Any time a flipped control bytes occurs after a 27, the value should be flipped and the preceding 27 deleted. See page 9 of 142 in BK doc PS12640-44 for further details.
-
disconnect_from_host
()[source]¶ Disconnects the client from the host.
If the socket is already closed, a recv() call will throw an error. If it doesn’t, we can close the socket.
-
enable_rgb_output
()[source]¶ The ‘QUERY:GRAB_FRAME “ON”` gets the BK to stream greyscale data (e.g. 640 x 480 x 1),
some applications might want this in RGB format (640 x 480 x 3)
-
find_first_a_not_preceded_by_b
(start_pos, a, b)[source]¶ Find the first instance of ‘a’ in an array that isn’t preceded by ‘b’
Parameters: - start_pos (integer) – Index in array to begin search at
- a (integer) – Value to find
- b (integer) – Value not to precede a
Returns: Index of first a not preceded by b, -1 if none found
Return type: integer
-
generate_command_message
(message)[source]¶ Append 0x01 and 0x04 to start/end of message before sending
Parameters: message(string): the message to be sent
-
parse_scanarea_message
()[source]¶ Separate the scanarea response msssage into the separate components.
Message has format: <StartLineX>,<StartLineY>,<StartLineAngle>,<StartDepth>, <StopLineX>,<StopLineY>,<StopLineAngle>,<StopDepth>
Example message: DATA:B_GEOMETRY_SCANAREA:A 0.0017218,-0.000171398, 1.37236,0,-0.00174855,-0.000176821,1.77236,0.0203479;
-
parse_win_size_message
(message)[source]¶ Extrack the size of the US window from the response message
Message has format “DATA:US_WIN_SIZE 640,480;”
Parameters: message(string): the received message
-
receive_image
()[source]¶ Scan the incoming data stream to find the start and end of the image data.
See BK doc PS12640-44 for further details.
-
receive_response_message
(expected_size=1024)[source]¶ Receive a message
Stores it under the data class member
Parameters: expected_size(int): the receive message size in bytes
-
-
class
sksurgerybk.interface.bk5000.
BKOpenCV
(TCP_IP='128.16.0.3', TCP_PORT=7915, TIMEOUT=5, FPS=25)[source]¶ Bases:
object
Display BK data using OpenCV.
sksurgerybk.pyigtlink package¶
Created on Tue Nov 3 19:17:05 2015
@author: Daniel Hoyer Iversen
-
class
sksurgerybk.pyigtlink.pyIGTLink.
ImageMessage
(image, spacing=[1, 1, 1], timestamp=None, device_name='')[source]¶
-
class
sksurgerybk.pyigtlink.pyIGTLink.
ImageMessageMatlab
(image, dim, spacing=[1, 1, 1], timestamp=None)[source]¶
-
class
sksurgerybk.pyigtlink.pyIGTLink.
PyIGTLink
(port=18905, localServer=True, iface='eth0')[source]¶ Bases:
socketserver.TCPServer
For streaming data over TCP with IGTLink
-
class
sksurgerybk.pyigtlink.pyIGTLink.
TCPRequestHandler
(request, client_address, server)[source]¶ Bases:
socketserver.BaseRequestHandler
Help class for PyIGTLink
Module contents¶
scikit-surgerybk