Skip to content

osirix.browser_controller

Provides access to core functionality of the OsiriX database.

There should only ever be one, but it is OK to create multiple pyOsiriX instances, they will just contiain the same osirixrpc_uid.

Example usage
import osirix

database = osirix.current_browser()  # Get the current browser instance
images_path = "/path/to/dicoms"  # Define the location of the images
database.copy_files_into_database(images_path)  # Load the images (on separate process).

BrowserController

Bases: OsirixBase

copy_files_into_database(files)

Copy files into the Osirix database.

Note that this will always copy files, rather than copy by link, therefore doubling the memory requirements. It is safe to delete the source Dicom data after import, if you wish to do so.

Parameters:

Name Type Description Default
files List[str]

The list of files to copy, as absolute paths.

required
Example usage
database = osirix.current_browser()
images_path = "/path/to/dicoms"
database.copy_files_into_database(images_path)

database_selection()

Queries the user selection of Dicom images.

Returns:

Type Description
List[DicomStudy]

The selected Dicom study instances

List[DicomSeries]

The selected Dicom series instances

Example usage
database = osirix.current_browser()
studies, series = database.database_selection()

open_viewer_2d(dicom_images)

Open a 2D viewer for an array of osirix.dicom.DicomImage instances.

Note that images will be loaded in the order in which they are presented as input here. Use the properties of DicomImage to ensure that they are loaded in order (e.g. sorted by the slice_location or instance_number properties).

Parameters:

Name Type Description Default
dicom_images NDArray

The array of images to display. Must be one dimensional and have at least one element.

required

Returns:

Type Description
ViewerController

The resulting new viewer controller.

Raises:

Type Description
ValueError

When the number of images in dicom_images is less than 1.

ValueError

When dicom_images is multidimensional.

ValueError

When instances other than DicomImage are provided in dicom_images.

Example usage
database = osirix.current_browser()
studies, series = database.database_selection()
if len(series) == 0:
    raise ValueError("No dicom series selected.")
database.open_viewer_2d(series[0].sorted_images())

open_viewer_4d(dicom_images)

Open a 4D viewer for an array of arrays of osirix.dicom.DicomImage instances.

As per the open_viewer_2d method, each frames will be presented in the order in which the DicomImage instances are presented to the function.

Note that no pre-checks are performed to ensure OsiriX can actually display the data (e.g. same slice locations are provided for each frame).

Parameters:

Name Type Description Default
dicom_images NDArray

An array of shape (N_frames, N_images).

required

Returns:

Type Description
ViewerController

The resulting new viewer controller.

Raises:

Type Description
ValueError

When N_frames is less than 2.

ValueError

When N_images is less than 1.

ValueError

When dicom_images shape is not 2-dimensional.

ValueError

When instances other than DicomImage are provided in the dicom_images.

Example usage
database = osirix.current_browser()
studies, series = database.database_selection()
if len(series) < 2:
    raise ValueError("Need at least two selected series.")
database.open_viewer_4d(np.array([s.sorted_images() for s in series]))