sksurgerybk.interface.bk5000 module¶
This module sets the connection to the BK scanner
-
class
sksurgerybk.interface.bk5000.BK5000(timeout, frames_per_second)[source]¶ Bases:
objectThis 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:
objectDisplay BK data using OpenCV.