Skip to content

osirix.osirix_utilities

Provide access to the core OsiriX objects: 2D/3D viewers and the database (browser).

Example usage
import osirix

port = 50051    # You can use any unused port
domain = "localhost"
osirix_service = osirix.osirix_utilities.OsirixService(domain=domain, port=port)

Osirix

Bases: OsirixBase

Provides access functionality to core OsiriX objects (2D/3D viewers and Dicom browser).

Note that it is better not to use this class directly, unless you know what you are doing. There is a global instance of this class, set-up according to the OsiriXgrpc plugin configuration, as described in the main __init__.py module.

__osirix_cache_object_for_uid__(uid)

Return an object for a particular UID

Parameters:

Name Type Description Default
uid str

The UID for which to obtain the object

required

Returns:

Name Type Description
id

The object.

__osirix_cache_objects__()

Return an object for a particular UID

Returns:

Name Type Description
Dict Dict

All objects keyed by the uid: {uid: object}

__osirix_cache_uids__()

Return a list of UIDs available to osirixgrpc

Returns:

Name Type Description
List List[str]

The list of available UIDs.

current_browser()

Return an instance of the current Dicom database browser.

Note that it is better not use this method directly. Use the following instead:

import osirix
browser = osirix.current_browser()

Returns:

Type Description
BrowserController

The main Dicom browser instance.

displayed_2d_viewers()

Return all displayed 2D viewer instances.

Note that it is better not use this method directly. Use the following instead:

import osirix
viewers = osirix.displayed_2d_viewers()

Returns:

Type Description
List[ViewerController, ...]

A list of 2D viewer instances.

displayed_vr_controllers()

Return all displayed 3D viewer instances.

Note that it is better not use this method directly. Use the following instead:

import osirix
vr_controllers = osirix.displayed_vr_controllers()

Returns:

Type Description
List[VRController, ...]

A list of 3D viewer instances.

frontmost_viewer()

Return an instance of the front-most 2D viewer.

If there are more than one, look for the viewer highlighted by a red boundary. Note that it is better not use this method directly. Use the following instead:

import osirix
viewer = osirix.frontmost_viewer()

Returns:

Type Description
ViewerController

The front-most 2D viewer.

frontmost_vr_controller()

Return an instance of the front-most 3D viewer.

Note that it is better not use this method directly. Use the following instead:

import osirix
vr_controller = osirix.frontmost_vr_controller()

Returns:

Type Description
VRController

The front-most 3D viewer.

osirix_version()

Return the current version of OsiriX being linked to.

Note that it is better not use this method directly. Use the following instead:

import osirix
version = osirix.osirix_version()

Returns:

Name Type Description
str str

The current OsiriX version.

str str

The bundle name (e.g. "OsiriX MD")

OsirixService

Bases: object

Create and manage an OsiriX gRPC service (stub).

Attributes:

Name Type Description
domain str

The domain with which to establish the connection. Currently, only "127.0.0.1" is supported (localhost). Default is "127.0.0.1".

port int

The port number with which to establish the connection. Default is 50051.

max_send_message_length int

The maximum number of bytes permitted in a send message. Default is 500000000 (500 MB).

max_receive_message_length int

The maximum number of bytes permitted in a receive message. Default is 500000000 (500 MB).

osirix_service_stub OsiriXServiceStub

The service stub used to send gRPC messages to the OsiriXgrpc server. None if no connection established.

channel Channel

An insecure gRPC channel configuration.

check_connection()

Check that a connection with OsiriX is established.

Returns:

Type Description
bool

True if a connection is established.

start_service()

Start the insecure client service.

Raises:

Type Description
GrpcException

Occurs when something goes wrong trying to set up the connection.

stop_service()

Stop the insecure client service.