Operators#

Please also see Holoscan SDK Python API for additional operators that are exposed in this module.

BundleConfigNames([preproc_name, ...])

This object holds the name of relevant config items used in a MONAI Bundle.

ClaraVizOperator(fragment, *args, **kwargs)

This operator uses Clara Viz to provide interactive view of a 3D volume including segmentation mask.

DICOMDataLoaderOperator(fragment, *args[, ...])

This operator loads DICOM studies into memory from a folder of DICOM instance files.

DICOMEncapsulatedPDFWriterOperator(fragment, ...)

Class to write DICOM Encapsulated PDF Instance with provided PDF bytes in memory.

DICOMSegmentationWriterOperator(fragment, ...)

This operator writes out a DICOM Segmentation Part 10 file to disk

DICOMSeriesSelectorOperator(fragment, *args)

This operator selects a list of DICOM Series in a DICOM Study for a given set of selection rules.

DICOMSeriesToVolumeOperator(fragment, *args)

This operator converts an instance of DICOMSeries into an Image object.

DICOMTextSRWriterOperator(fragment, *args, ...)

Class to write DICOM Text SR Instance with provided text input.

EquipmentInfo([manufacturer, ...])

Class encapsulating attributes required for DICOM Equipment Module.

InferenceOperator(fragment, *args, **kwargs)

The base operator for operators that perform AI inference.

IOMapping(label, data_type, storage_type)

This object holds an I/O definition for an operator.

ModelInfo([creator, name, version, uid])

Class encapsulating AI model information, according to IHE AI Results (AIR) Rev 1.1.

MonaiBundleInferenceOperator(fragment, ...)

This inference operator automates the inference operation for a given MONAI Bundle.

MonaiSegInferenceOperator(fragment, *args, ...)

This segmentation operator uses MONAI transforms and performs Simple or Sliding Window Inference.

PNGConverterOperator(fragment, *args, ...)

This operator writes out a 3D Volumetric Image to to a file folder in a slice by slice manner.

PublisherOperator(*args, input_folder, ...)

This Operator publishes the input and segment mask images for the 3rd party Render Server.

STLConversionOperator(fragment, *args, ...)

Converts volumetric image to surface mesh in STL format.

STLConverter(*args, **kwargs)

Converts volumetric image to surface mesh in STL

NiftiDataLoader(fragment, *args, input_path, ...)

This operator reads a nifti image, extracts the numpy array and forwards it to the next operator

class monai.deploy.operators.BundleConfigNames(preproc_name='preprocessing', postproc_name='postprocessing', inferer_name='inferer', config_names='inference')[source]

Bases: object

This object holds the name of relevant config items used in a MONAI Bundle.

Creates an object holding the names of relevant config items in a MONAI Bundle.

This object holds the names of the config items in a MONAI Bundle that will need to be parsed by the inference operator for automating the object creations and inference. Defaults values are provided per conversion, so the arguments only need to be set as needed.

Parameters:
  • preproc_name (str, optional) – Name of the config item for pre-processing transforms. Defaults to “preprocessing”.

  • postproc_name (str, optional) – Name of the config item for post-processing transforms. Defaults to “postprocessing”.

  • inferer_name (str, optional) – Name of the config item for inferer. Defaults to “inferer”.

  • config_names (List[str], optional) – Name of config file(s) in the Bundle for parsing. Defaults to [“inference”]. File ext must be .json.

__init__(preproc_name='preprocessing', postproc_name='postprocessing', inferer_name='inferer', config_names='inference')[source]

Creates an object holding the names of relevant config items in a MONAI Bundle.

This object holds the names of the config items in a MONAI Bundle that will need to be parsed by the inference operator for automating the object creations and inference. Defaults values are provided per conversion, so the arguments only need to be set as needed.

Parameters:
  • preproc_name (str, optional) – Name of the config item for pre-processing transforms. Defaults to “preprocessing”.

  • postproc_name (str, optional) – Name of the config item for post-processing transforms. Defaults to “postprocessing”.

  • inferer_name (str, optional) – Name of the config item for inferer. Defaults to “inferer”.

  • config_names (List[str], optional) – Name of config file(s) in the Bundle for parsing. Defaults to [“inference”]. File ext must be .json.

class monai.deploy.operators.ClaraVizOperator(fragment, *args, **kwargs)[source]

Bases: Operator

This operator uses Clara Viz to provide interactive view of a 3D volume including segmentation mask.

Named input(s):

image: Image object of the input image, including key metadata, e.g. pixel spacings and orientations. seg_image: Image object of the segmentation image derived from the input image.

Constructor of the operator.

Parameters:

fragment (Fragment) – An instance of the Application class which is derived from Fragment.

class OperatorType(self: holoscan.core._core.OperatorBase.OperatorType, value: int)

Bases: pybind11_object

Enum class for operator types used by the executor.

  • NATIVE: Native operator.

  • GXF: GXF operator.

  • VIRTUAL: Virtual operator. (for internal use, not intended for use by application authors)

Members:

NATIVE

GXF

VIRTUAL

property name
__init__(fragment, *args, **kwargs)[source]

Constructor of the operator.

Parameters:

fragment (Fragment) – An instance of the Application class which is derived from Fragment.

add_arg(*args, **kwargs)

Overloaded function.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.Arg) -> None

Add an argument to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ArgList) -> None

Add a list of arguments to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, **kwargs) -> None

Add arguments to the component via Python kwargs.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ConditionBase) -> None

  2. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ResourceBase) -> None

Add a condition or resource to the Operator.

This can be used to add a condition or resource to an operator after it has already been constructed.

Parameters#

argholoscan.core.Condition or holoscan.core.Resource

The condition or resource to add.

add_dynamic_flow(*args, **kwargs)

Overloaded function.

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flow: holoscan.core._core.FlowInfo) -> None

  2. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flows: list[holoscan.core._core.FlowInfo]) -> None

  3. add_dynamic_flow(self: holoscan.core._core.OperatorBase, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

Add a dynamic flow from this operator to another operator.

Parameters#

next_opholoscan.core.Operator

The downstream operator to connect to.

next_input_port_namestr, optional

The name of the input port on the downstream operator to connect to. If not specified, the first available input port will be used.

Notes#

This method has several overloads to support different ways of creating dynamic flows:

  1. add_dynamic_flow(next_op: Operator, next_input_port_name: str = ‘’) - Basic connection using default output port. This is the simplest form for connecting

    two operators when you only need to specify the destination.

  2. add_dynamic_flow(curr_output_port_name: str, next_op: Operator, next_input_port_name: str = ‘’) - Connection with explicit output port specification. Use this when the source operator has

    multiple output ports and you need to specify which one to use.

  3. add_dynamic_flow(flow: FlowInfo) - Connection using a FlowInfo object, which encapsulates all connection details including:

    • Source operator and its output port specification

    • Destination operator and its input port specification

    • Port names and associated IOSpecs

    • This is useful for complex connections or when reusing connection patterns.

  4. add_dynamic_flow(flows: List[FlowInfo]) - Batch connection using multiple FlowInfo objects. Use this to set up multiple

    connections in a single call, which is more efficient than making multiple individual connections.

The FlowInfo class provides a complete description of a flow connection between operators, including all port specifications and naming. It’s particularly useful when you need to:

  • Store and reuse connection patterns

  • Create complex routing configurations

  • Handle dynamic port specifications

  • Manage multiple connections systematically

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, curr_output_port_name: str, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

property args

The list of arguments associated with the component.

Returns#

arglist : holoscan.core.ArgList

property async_condition

The internal asynchronous condition for the operator.

This property provides access to the internal asynchronous condition for the operator, which controls the scheduling of the operator’s compute method.

Returns#

conditionholoscan.conditions.AsynchronousCondition

An instance of holoscan.conditions.AsynchronousCondition that is the internal asynchronous condition for the operator.

Notes#

This object is only accessible after the executor has called Operator.initialize() via run() or run_async(). If accessed during Application.compose(), it will return None.

compute(op_input, op_output, context)[source]

Displays the input image and segmentation mask

Parameters:
  • op_input (InputContext) – An input context for the operator.

  • op_output (OutputContext) – An output context for the operator.

  • context (ExecutionContext) – An execution context for the operator.

property conditions

Conditions associated with the operator.

property description

YAML formatted string describing the operator.

enable_metadata(self: holoscan.core._core.OperatorBase, enable: bool) None

Configure whether or not the metadata feature is enabled for this operator. If it is not set, the default value will be determined by the enable_metadata setting from the Fragment that this operator belongs to.

property execution_context

The execution context for the operator.

This property provides access to the execution context of the operator, which contains information about the current execution environment including scheduling details.

Returns#

holoscan.core.ExecutionContext

The execution context object for this operator.

find_all_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) list[holoscan.core._core.FlowInfo]

Find all flow info objects in the operator’s next flows that match a given condition.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

list[holoscan.core.FlowInfo]

List of matching FlowInfo objects.

find_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) holoscan.core._core.FlowInfo

Find a flow info in the operator’s next flows based on a given predicate.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

holoscan.core.FlowInfo or None

The first matching FlowInfo object, or None if not found.

property fragment

The fragment (holoscan.core.Fragment) that the operator belongs to.

property id

The identifier of the component.

The identifier is initially set to -1, and will become a valid value when the component is initialized.

With the default executor (holoscan.gxf.GXFExecutor), the identifier is set to the GXF component ID.

Returns#

id : int

initialize()

Default implementation of initialize

property is_metadata_enabled

Boolean indicating whether the fragment this operator belongs to has metadata transmission enabled.

property metadata

The metadata dictionary (holoscan.core.MetadataDictionary) associated with the operator.

property metadata_policy

The metadata policy (holoscan.core.MetadataPolicy) associated with the operator.

The supported policies are:

  • MetadataPolicy.REJECT: Reject the new value if the key already exists

  • MetadataPolicy.UPDATE: Replace existing value with the new one if the key already exists

  • MetadataPolicy.INPLACE_UPDATE: Update the value stored within an existing MetadataObject in-place if the key already exists (in contrast to UPDATE which always replaces the existing MetadataObject with a new one).

  • MetadataPolicy.RAISE: Raise an exception if the key already exists

property name

The name of the operator.

property next_flows

Get the list of flow information for connections to downstream operators.

Returns#

list[holoscan.core.FlowInfo]

List of flow information objects describing connections to downstream operators.

property operator_type

The operator type.

holoscan.core.Operator.OperatorType enum representing the type of the operator. The two types currently implemented are native and GXF.

queue_policy(self: holoscan.core._core.OperatorBase, port_name: str, port_type: holoscan.core._core.IOSpec.IOType = <IOType.INPUT: 0>, policy: holoscan.core._core.IOSpec.QueuePolicy = <QueuePolicy.FAULT: 2>) None

Set the queue policy to be used by an input (or output) port’s receiver (or transmitter).

Parameters#

port_namestr

The name of the port.

port_typeIOSpec.IOType, optional

Enum indicating whether port_name corresponds to an input port or output port.

policyIOSpec.QueuePolicy, optional

The queue policy to set. Valid values are:

  • QueuePolicy.POP : If the queue is full, pop the oldest item, then add the new one.

  • QueuePolicy.REJECT : If the queue is full, reject (discard) the new item.

  • QueuePolicy.FAULT : If the queue is full, log a warning and reject the new item.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

receiver(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Receiver]

Get the receiver used by an input port.

Parameters#

port_namestr

The name of the input port.

Returns#

receiverholoscan.resources.Receiver

The receiver used by this input port. Will be None if the port does not exist.

resource(self: holoscan.core._core.OperatorBase, name: str) object | None

Resources associated with the operator.

Parameters#

namestr

The name of the resource to retrieve

Returns#

holoscan.core.Resource or None

The resource with the given name. If no resource with the given name is found, None is returned.

property resources

Resources associated with the operator.

service(self: object, service_type: type, id: str = '') object

Retrieve a registered fragment service through the component’s fragment.

This method delegates to the fragment’s service() method to retrieve a previously registered fragment service by its type and optional identifier. Returns None if no fragment service is found with the specified type and identifier.

Parameters#

service_typetype

The type of the fragment service to retrieve. Must be a type that inherits from Resource or FragmentService.

idstr, optional

The identifier of the fragment service. If empty, retrieves by service type only. For Resources, this would typically be the resource’s name.

Returns#

object or None

The fragment service instance of the requested type, or None if not found. If the service wraps a Resource and a Resource type is requested, the unwrapped Resource instance is returned.

Raises#

RuntimeError

If the component has no associated fragment or if the fragment’s service method cannot be accessed.

Notes#

This is a convenience method that internally calls the fragment’s service() method. For services that wrap Resources, the method will automatically unwrap and return the Resource if a Resource type is requested.

setup(spec)[source]

Default implementation of setup method.

property spec

The operator spec (holoscan.core.OperatorSpec) associated with the operator.

start()

Default implementation of start

stop()

Default implementation of stop

stop_execution(self: holoscan.core._core.OperatorBase) None

Stop the execution of the operator.

This method is used to stop the execution of the operator by setting the internal async condition to EVENT_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operator will not be scheduled for execution (the compute() method will not be called).

Note that executing this method does not trigger the operator’s stop() method. The stop() method is called only when the scheduler deactivates all operators together.

transmitter(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Transmitter]

Get the transmitter used by an output port.

Parameters#

port_namestr

The name of the output port.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

class monai.deploy.operators.DICOMDataLoaderOperator(fragment, *args, input_folder=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/monai-deploy-app-sdk/checkouts/stable/docs/source/input'), output_name='dicom_study_list', must_load=True, **kwargs)[source]

Bases: Operator

This operator loads DICOM studies into memory from a folder of DICOM instance files.

Named Input:
input_folder: Path to the folder containing DICOM instance files. Optional and not requiring input.

If present, data from this input will be used as the input folder of DICOM instance files.

Name Output:

dicom_study_list: A list of DICOMStudy objects in memory. The name can be changed via attribute, output_name.

Creates an instance of this class.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • input_folder (Path) – Folder containing DICOM instance files to load from. Defaults to input in the current working directory. Can be overridden by via the named input receiving from other’s output.

  • output_name (str) – The name for the output, which is list of DICOMStudy objects. Defaults to dicom_study_list, and if None or blank passed in.

  • must_load (bool) – If true, raise exception if no study is loaded. Defaults to True.

class OperatorType(self: holoscan.core._core.OperatorBase.OperatorType, value: int)

Bases: pybind11_object

Enum class for operator types used by the executor.

  • NATIVE: Native operator.

  • GXF: GXF operator.

  • VIRTUAL: Virtual operator. (for internal use, not intended for use by application authors)

Members:

NATIVE

GXF

VIRTUAL

property name
__init__(fragment, *args, input_folder=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/monai-deploy-app-sdk/checkouts/stable/docs/source/input'), output_name='dicom_study_list', must_load=True, **kwargs)[source]

Creates an instance of this class.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • input_folder (Path) – Folder containing DICOM instance files to load from. Defaults to input in the current working directory. Can be overridden by via the named input receiving from other’s output.

  • output_name (str) – The name for the output, which is list of DICOMStudy objects. Defaults to dicom_study_list, and if None or blank passed in.

  • must_load (bool) – If true, raise exception if no study is loaded. Defaults to True.

add_arg(*args, **kwargs)

Overloaded function.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.Arg) -> None

Add an argument to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ArgList) -> None

Add a list of arguments to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, **kwargs) -> None

Add arguments to the component via Python kwargs.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ConditionBase) -> None

  2. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ResourceBase) -> None

Add a condition or resource to the Operator.

This can be used to add a condition or resource to an operator after it has already been constructed.

Parameters#

argholoscan.core.Condition or holoscan.core.Resource

The condition or resource to add.

add_dynamic_flow(*args, **kwargs)

Overloaded function.

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flow: holoscan.core._core.FlowInfo) -> None

  2. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flows: list[holoscan.core._core.FlowInfo]) -> None

  3. add_dynamic_flow(self: holoscan.core._core.OperatorBase, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

Add a dynamic flow from this operator to another operator.

Parameters#

next_opholoscan.core.Operator

The downstream operator to connect to.

next_input_port_namestr, optional

The name of the input port on the downstream operator to connect to. If not specified, the first available input port will be used.

Notes#

This method has several overloads to support different ways of creating dynamic flows:

  1. add_dynamic_flow(next_op: Operator, next_input_port_name: str = ‘’) - Basic connection using default output port. This is the simplest form for connecting

    two operators when you only need to specify the destination.

  2. add_dynamic_flow(curr_output_port_name: str, next_op: Operator, next_input_port_name: str = ‘’) - Connection with explicit output port specification. Use this when the source operator has

    multiple output ports and you need to specify which one to use.

  3. add_dynamic_flow(flow: FlowInfo) - Connection using a FlowInfo object, which encapsulates all connection details including:

    • Source operator and its output port specification

    • Destination operator and its input port specification

    • Port names and associated IOSpecs

    • This is useful for complex connections or when reusing connection patterns.

  4. add_dynamic_flow(flows: List[FlowInfo]) - Batch connection using multiple FlowInfo objects. Use this to set up multiple

    connections in a single call, which is more efficient than making multiple individual connections.

The FlowInfo class provides a complete description of a flow connection between operators, including all port specifications and naming. It’s particularly useful when you need to:

  • Store and reuse connection patterns

  • Create complex routing configurations

  • Handle dynamic port specifications

  • Manage multiple connections systematically

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, curr_output_port_name: str, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

property args

The list of arguments associated with the component.

Returns#

arglist : holoscan.core.ArgList

property async_condition

The internal asynchronous condition for the operator.

This property provides access to the internal asynchronous condition for the operator, which controls the scheduling of the operator’s compute method.

Returns#

conditionholoscan.conditions.AsynchronousCondition

An instance of holoscan.conditions.AsynchronousCondition that is the internal asynchronous condition for the operator.

Notes#

This object is only accessible after the executor has called Operator.initialize() via run() or run_async(). If accessed during Application.compose(), it will return None.

compute(op_input, op_output, context)[source]

Performs computation for this operator and handlesI/O.

property conditions

Conditions associated with the operator.

property description

YAML formatted string describing the operator.

enable_metadata(self: holoscan.core._core.OperatorBase, enable: bool) None

Configure whether or not the metadata feature is enabled for this operator. If it is not set, the default value will be determined by the enable_metadata setting from the Fragment that this operator belongs to.

property execution_context

The execution context for the operator.

This property provides access to the execution context of the operator, which contains information about the current execution environment including scheduling details.

Returns#

holoscan.core.ExecutionContext

The execution context object for this operator.

find_all_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) list[holoscan.core._core.FlowInfo]

Find all flow info objects in the operator’s next flows that match a given condition.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

list[holoscan.core.FlowInfo]

List of matching FlowInfo objects.

find_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) holoscan.core._core.FlowInfo

Find a flow info in the operator’s next flows based on a given predicate.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

holoscan.core.FlowInfo or None

The first matching FlowInfo object, or None if not found.

property fragment

The fragment (holoscan.core.Fragment) that the operator belongs to.

property id

The identifier of the component.

The identifier is initially set to -1, and will become a valid value when the component is initialized.

With the default executor (holoscan.gxf.GXFExecutor), the identifier is set to the GXF component ID.

Returns#

id : int

initialize()

Default implementation of initialize

property is_metadata_enabled

Boolean indicating whether the fragment this operator belongs to has metadata transmission enabled.

load_data_to_studies(input_path)[source]

Load DICOM data from files into DICOMStudy objects in a list.

It scans through the input directory for all SOP instances. It groups them by a collection of studies where each study contains one or more series. This method returns a list of studies. If there is no studies loaded, an exception will be thrown if set to must load.

Parameters:

input_path (Path) – The folder containing DICOM instance files.

Returns:

List of DICOMStudy.

Return type:

List[DICOMStudy]

Raises:
  • ValueError – If the folder to load files from does not exist.

  • ItemNotExistsError – If no studies loaded and must_load is True.

property metadata

The metadata dictionary (holoscan.core.MetadataDictionary) associated with the operator.

property metadata_policy

The metadata policy (holoscan.core.MetadataPolicy) associated with the operator.

The supported policies are:

  • MetadataPolicy.REJECT: Reject the new value if the key already exists

  • MetadataPolicy.UPDATE: Replace existing value with the new one if the key already exists

  • MetadataPolicy.INPLACE_UPDATE: Update the value stored within an existing MetadataObject in-place if the key already exists (in contrast to UPDATE which always replaces the existing MetadataObject with a new one).

  • MetadataPolicy.RAISE: Raise an exception if the key already exists

property name

The name of the operator.

property next_flows

Get the list of flow information for connections to downstream operators.

Returns#

list[holoscan.core.FlowInfo]

List of flow information objects describing connections to downstream operators.

property operator_type

The operator type.

holoscan.core.Operator.OperatorType enum representing the type of the operator. The two types currently implemented are native and GXF.

populate_series_attributes(series, sop_instance)[source]

Populates series level attributes in the study data structure.

Parameters:
  • study – A DICOM Series instance that needs to be filled-in with series level attribute values

  • sop_instance – A sample DICOM SOP Instance that contains the list of attributed which will be parsed

populate_study_attributes(study, sop_instance)[source]

Populates study level attributes in the study data structure.

Parameters:
  • study – A DICOM Study instance that needs to be filled-in with study level attribute values

  • sop_instance – A sample DICOM SOP Instance that contains the list of attributed which will be parsed

queue_policy(self: holoscan.core._core.OperatorBase, port_name: str, port_type: holoscan.core._core.IOSpec.IOType = <IOType.INPUT: 0>, policy: holoscan.core._core.IOSpec.QueuePolicy = <QueuePolicy.FAULT: 2>) None

Set the queue policy to be used by an input (or output) port’s receiver (or transmitter).

Parameters#

port_namestr

The name of the port.

port_typeIOSpec.IOType, optional

Enum indicating whether port_name corresponds to an input port or output port.

policyIOSpec.QueuePolicy, optional

The queue policy to set. Valid values are:

  • QueuePolicy.POP : If the queue is full, pop the oldest item, then add the new one.

  • QueuePolicy.REJECT : If the queue is full, reject (discard) the new item.

  • QueuePolicy.FAULT : If the queue is full, log a warning and reject the new item.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

receiver(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Receiver]

Get the receiver used by an input port.

Parameters#

port_namestr

The name of the input port.

Returns#

receiverholoscan.resources.Receiver

The receiver used by this input port. Will be None if the port does not exist.

resource(self: holoscan.core._core.OperatorBase, name: str) object | None

Resources associated with the operator.

Parameters#

namestr

The name of the resource to retrieve

Returns#

holoscan.core.Resource or None

The resource with the given name. If no resource with the given name is found, None is returned.

property resources

Resources associated with the operator.

service(self: object, service_type: type, id: str = '') object

Retrieve a registered fragment service through the component’s fragment.

This method delegates to the fragment’s service() method to retrieve a previously registered fragment service by its type and optional identifier. Returns None if no fragment service is found with the specified type and identifier.

Parameters#

service_typetype

The type of the fragment service to retrieve. Must be a type that inherits from Resource or FragmentService.

idstr, optional

The identifier of the fragment service. If empty, retrieves by service type only. For Resources, this would typically be the resource’s name.

Returns#

object or None

The fragment service instance of the requested type, or None if not found. If the service wraps a Resource and a Resource type is requested, the unwrapped Resource instance is returned.

Raises#

RuntimeError

If the component has no associated fragment or if the fragment’s service method cannot be accessed.

Notes#

This is a convenience method that internally calls the fragment’s service() method. For services that wrap Resources, the method will automatically unwrap and return the Resource if a Resource type is requested.

setup(spec)[source]

Default implementation of setup method.

property spec

The operator spec (holoscan.core.OperatorSpec) associated with the operator.

start()

Default implementation of start

stop()

Default implementation of stop

stop_execution(self: holoscan.core._core.OperatorBase) None

Stop the execution of the operator.

This method is used to stop the execution of the operator by setting the internal async condition to EVENT_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operator will not be scheduled for execution (the compute() method will not be called).

Note that executing this method does not trigger the operator’s stop() method. The stop() method is called only when the scheduler deactivates all operators together.

transmitter(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Transmitter]

Get the transmitter used by an output port.

Parameters#

port_namestr

The name of the output port.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

class monai.deploy.operators.DICOMEncapsulatedPDFWriterOperator(fragment, *args, output_folder, model_info=None, equipment_info=None, copy_tags=True, custom_tags=None, **kwargs)[source]

Bases: Operator

Class to write DICOM Encapsulated PDF Instance with provided PDF bytes in memory.

Named inputs:

pdf_bytes: Bytes of the the PDF content. study_selected_series_list: Optional, DICOM series for copying metadata from.

Named output:

None

File output:

Generated DICOM instance file in the provided output folder.

Class to write DICOM Encapsulated PDF Instance with PDF bytes in memory or in a file.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • output_folder (str or Path) – The folder for saving the generated DICOM instance file.

  • copy_tags (bool) – True, default, for copying DICOM attributes from a provided DICOMSeries. If True and no DICOMSeries obj provided, runtime exception is thrown.

  • model_info (ModelInfo) – Object encapsulating model creator, name, version and UID.

  • equipment_info (EquipmentInfo, optional) – Object encapsulating info for DICOM Equipment Module. Defaults to None.

  • custom_tags (Dict[str, str], optional) – Dictionary for setting custom DICOM tags using Keywords and str values only. Defaults to None.

Raises:

ValueError – If copy_tags is true and no DICOMSeries object provided, or if PDF bytes cannot be found in memory or loaded from the file.

class OperatorType(self: holoscan.core._core.OperatorBase.OperatorType, value: int)

Bases: pybind11_object

Enum class for operator types used by the executor.

  • NATIVE: Native operator.

  • GXF: GXF operator.

  • VIRTUAL: Virtual operator. (for internal use, not intended for use by application authors)

Members:

NATIVE

GXF

VIRTUAL

property name
__init__(fragment, *args, output_folder, model_info=None, equipment_info=None, copy_tags=True, custom_tags=None, **kwargs)[source]

Class to write DICOM Encapsulated PDF Instance with PDF bytes in memory or in a file.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • output_folder (str or Path) – The folder for saving the generated DICOM instance file.

  • copy_tags (bool) – True, default, for copying DICOM attributes from a provided DICOMSeries. If True and no DICOMSeries obj provided, runtime exception is thrown.

  • model_info (ModelInfo) – Object encapsulating model creator, name, version and UID.

  • equipment_info (EquipmentInfo, optional) – Object encapsulating info for DICOM Equipment Module. Defaults to None.

  • custom_tags (Dict[str, str], optional) – Dictionary for setting custom DICOM tags using Keywords and str values only. Defaults to None.

Raises:

ValueError – If copy_tags is true and no DICOMSeries object provided, or if PDF bytes cannot be found in memory or loaded from the file.

add_arg(*args, **kwargs)

Overloaded function.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.Arg) -> None

Add an argument to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ArgList) -> None

Add a list of arguments to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, **kwargs) -> None

Add arguments to the component via Python kwargs.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ConditionBase) -> None

  2. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ResourceBase) -> None

Add a condition or resource to the Operator.

This can be used to add a condition or resource to an operator after it has already been constructed.

Parameters#

argholoscan.core.Condition or holoscan.core.Resource

The condition or resource to add.

add_dynamic_flow(*args, **kwargs)

Overloaded function.

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flow: holoscan.core._core.FlowInfo) -> None

  2. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flows: list[holoscan.core._core.FlowInfo]) -> None

  3. add_dynamic_flow(self: holoscan.core._core.OperatorBase, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

Add a dynamic flow from this operator to another operator.

Parameters#

next_opholoscan.core.Operator

The downstream operator to connect to.

next_input_port_namestr, optional

The name of the input port on the downstream operator to connect to. If not specified, the first available input port will be used.

Notes#

This method has several overloads to support different ways of creating dynamic flows:

  1. add_dynamic_flow(next_op: Operator, next_input_port_name: str = ‘’) - Basic connection using default output port. This is the simplest form for connecting

    two operators when you only need to specify the destination.

  2. add_dynamic_flow(curr_output_port_name: str, next_op: Operator, next_input_port_name: str = ‘’) - Connection with explicit output port specification. Use this when the source operator has

    multiple output ports and you need to specify which one to use.

  3. add_dynamic_flow(flow: FlowInfo) - Connection using a FlowInfo object, which encapsulates all connection details including:

    • Source operator and its output port specification

    • Destination operator and its input port specification

    • Port names and associated IOSpecs

    • This is useful for complex connections or when reusing connection patterns.

  4. add_dynamic_flow(flows: List[FlowInfo]) - Batch connection using multiple FlowInfo objects. Use this to set up multiple

    connections in a single call, which is more efficient than making multiple individual connections.

The FlowInfo class provides a complete description of a flow connection between operators, including all port specifications and naming. It’s particularly useful when you need to:

  • Store and reuse connection patterns

  • Create complex routing configurations

  • Handle dynamic port specifications

  • Manage multiple connections systematically

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, curr_output_port_name: str, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

property args

The list of arguments associated with the component.

Returns#

arglist : holoscan.core.ArgList

property async_condition

The internal asynchronous condition for the operator.

This property provides access to the internal asynchronous condition for the operator, which controls the scheduling of the operator’s compute method.

Returns#

conditionholoscan.conditions.AsynchronousCondition

An instance of holoscan.conditions.AsynchronousCondition that is the internal asynchronous condition for the operator.

Notes#

This object is only accessible after the executor has called Operator.initialize() via run() or run_async(). If accessed during Application.compose(), it will return None.

compute(op_input, op_output, context)[source]

Performs computation for this operator and handles I/O.

For now, only a single result content is supported, which could be in bytes or a path to the PDF file. The DICOM series used during inference is optional, but is required if the copy_tags is true indicating the generated DICOM object needs to copy study level metadata.

When there are multiple selected series in the input, the first series’ containing study will be used for retrieving DICOM Study module attributes, e.g. StudyInstanceUID.

Raises:
  • FileNotFoundError – When bytes are not in the input, and the file is not given or found.

  • ValueError – Input bytes and PDF file not in the input, or no DICOM series when required.

  • IOError – If fails to get the bytes of the PDF

property conditions

Conditions associated with the operator.

property description

YAML formatted string describing the operator.

enable_metadata(self: holoscan.core._core.OperatorBase, enable: bool) None

Configure whether or not the metadata feature is enabled for this operator. If it is not set, the default value will be determined by the enable_metadata setting from the Fragment that this operator belongs to.

property execution_context

The execution context for the operator.

This property provides access to the execution context of the operator, which contains information about the current execution environment including scheduling details.

Returns#

holoscan.core.ExecutionContext

The execution context object for this operator.

find_all_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) list[holoscan.core._core.FlowInfo]

Find all flow info objects in the operator’s next flows that match a given condition.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

list[holoscan.core.FlowInfo]

List of matching FlowInfo objects.

find_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) holoscan.core._core.FlowInfo

Find a flow info in the operator’s next flows based on a given predicate.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

holoscan.core.FlowInfo or None

The first matching FlowInfo object, or None if not found.

property fragment

The fragment (holoscan.core.Fragment) that the operator belongs to.

property id

The identifier of the component.

The identifier is initially set to -1, and will become a valid value when the component is initialized.

With the default executor (holoscan.gxf.GXFExecutor), the identifier is set to the GXF component ID.

Returns#

id : int

initialize()

Default implementation of initialize

property is_metadata_enabled

Boolean indicating whether the fragment this operator belongs to has metadata transmission enabled.

property metadata

The metadata dictionary (holoscan.core.MetadataDictionary) associated with the operator.

property metadata_policy

The metadata policy (holoscan.core.MetadataPolicy) associated with the operator.

The supported policies are:

  • MetadataPolicy.REJECT: Reject the new value if the key already exists

  • MetadataPolicy.UPDATE: Replace existing value with the new one if the key already exists

  • MetadataPolicy.INPLACE_UPDATE: Update the value stored within an existing MetadataObject in-place if the key already exists (in contrast to UPDATE which always replaces the existing MetadataObject with a new one).

  • MetadataPolicy.RAISE: Raise an exception if the key already exists

property name

The name of the operator.

property next_flows

Get the list of flow information for connections to downstream operators.

Returns#

list[holoscan.core.FlowInfo]

List of flow information objects describing connections to downstream operators.

property operator_type

The operator type.

holoscan.core.Operator.OperatorType enum representing the type of the operator. The two types currently implemented are native and GXF.

queue_policy(self: holoscan.core._core.OperatorBase, port_name: str, port_type: holoscan.core._core.IOSpec.IOType = <IOType.INPUT: 0>, policy: holoscan.core._core.IOSpec.QueuePolicy = <QueuePolicy.FAULT: 2>) None

Set the queue policy to be used by an input (or output) port’s receiver (or transmitter).

Parameters#

port_namestr

The name of the port.

port_typeIOSpec.IOType, optional

Enum indicating whether port_name corresponds to an input port or output port.

policyIOSpec.QueuePolicy, optional

The queue policy to set. Valid values are:

  • QueuePolicy.POP : If the queue is full, pop the oldest item, then add the new one.

  • QueuePolicy.REJECT : If the queue is full, reject (discard) the new item.

  • QueuePolicy.FAULT : If the queue is full, log a warning and reject the new item.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

receiver(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Receiver]

Get the receiver used by an input port.

Parameters#

port_namestr

The name of the input port.

Returns#

receiverholoscan.resources.Receiver

The receiver used by this input port. Will be None if the port does not exist.

resource(self: holoscan.core._core.OperatorBase, name: str) object | None

Resources associated with the operator.

Parameters#

namestr

The name of the resource to retrieve

Returns#

holoscan.core.Resource or None

The resource with the given name. If no resource with the given name is found, None is returned.

property resources

Resources associated with the operator.

service(self: object, service_type: type, id: str = '') object

Retrieve a registered fragment service through the component’s fragment.

This method delegates to the fragment’s service() method to retrieve a previously registered fragment service by its type and optional identifier. Returns None if no fragment service is found with the specified type and identifier.

Parameters#

service_typetype

The type of the fragment service to retrieve. Must be a type that inherits from Resource or FragmentService.

idstr, optional

The identifier of the fragment service. If empty, retrieves by service type only. For Resources, this would typically be the resource’s name.

Returns#

object or None

The fragment service instance of the requested type, or None if not found. If the service wraps a Resource and a Resource type is requested, the unwrapped Resource instance is returned.

Raises#

RuntimeError

If the component has no associated fragment or if the fragment’s service method cannot be accessed.

Notes#

This is a convenience method that internally calls the fragment’s service() method. For services that wrap Resources, the method will automatically unwrap and return the Resource if a Resource type is requested.

setup(spec)[source]

Set up the named input(s), and output(s) if applicable.

This operator does not have an output for the next operator, rather file output only.

Parameters:

spec (OperatorSpec) – The Operator specification for inputs and outputs etc.

property spec

The operator spec (holoscan.core.OperatorSpec) associated with the operator.

start()

Default implementation of start

stop()

Default implementation of stop

stop_execution(self: holoscan.core._core.OperatorBase) None

Stop the execution of the operator.

This method is used to stop the execution of the operator by setting the internal async condition to EVENT_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operator will not be scheduled for execution (the compute() method will not be called).

Note that executing this method does not trigger the operator’s stop() method. The stop() method is called only when the scheduler deactivates all operators together.

transmitter(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Transmitter]

Get the transmitter used by an output port.

Parameters#

port_namestr

The name of the output port.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

write(content_bytes, dicom_series, output_dir)[source]

Writes DICOM object

Parameters:
  • content_bytes (bytes) – Content bytes of PDF

  • dicom_series (DicomSeries) – DicomSeries object encapsulating the original series.

  • output_dir (Path) – Folder path for saving the generated file.

class monai.deploy.operators.DICOMSegmentationWriterOperator(fragment, *args, segment_descriptions, output_folder, model_info=None, custom_tags=None, omit_empty_frames=True, **kwargs)[source]

Bases: Operator

This operator writes out a DICOM Segmentation Part 10 file to disk

Named inputs:

seg_image: The Image object of the segment. study_selected_series_list: The DICOM series from which the segment was derived. output_folder: Optional, folder for file output, overriding what is set on the object.

Named output:

None

File output:

Generated DICOM instance file in the output folder set on this object or optional input.

Instantiates the DICOM Seg Writer instance with optional list of segment label strings.

Each unique, non-zero integer value in the segmentation image represents a segment that must be described by an item of the segment descriptions list with the corresponding segment number. Items in the list must be arranged starting at segment number 1 and increasing by 1.

For example, in the CT Spleen Segmentation application, the whole image background has a value of 0, and the Spleen segment of value 1. This then only requires the caller to pass in a list containing a segment description, which is used as label for the Spleen in the DICOM Seg instance.

Note: this interface is subject to change. It is planned that a new object will encapsulate the segment label information, including label value, name, description etc.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • segment_descriptions (List[SegmentDescription]) – List[SegmentDescription] Object encapsulating the description of each segment present in the segmentation.

  • output_folder (Path) – Folder for file output, overridden by named input on compute. Defaults to current working dir’s child folder, output.

  • model_info (ModelInfo, optional) – Object encapsulating model creator, name, version and UID.

  • custom_tags (Optional[Dict[str, str]]) – Optional[Dict[str, str]], optional Dictionary for setting custom DICOM tags using Keywords and str values only

  • omit_empty_frames (bool) – bool, optional Whether to omit frames that contain no segmented pixels from the output segmentation. Defaults to True, same as the underlying lib API.

class OperatorType(self: holoscan.core._core.OperatorBase.OperatorType, value: int)

Bases: pybind11_object

Enum class for operator types used by the executor.

  • NATIVE: Native operator.

  • GXF: GXF operator.

  • VIRTUAL: Virtual operator. (for internal use, not intended for use by application authors)

Members:

NATIVE

GXF

VIRTUAL

property name
__init__(fragment, *args, segment_descriptions, output_folder, model_info=None, custom_tags=None, omit_empty_frames=True, **kwargs)[source]

Instantiates the DICOM Seg Writer instance with optional list of segment label strings.

Each unique, non-zero integer value in the segmentation image represents a segment that must be described by an item of the segment descriptions list with the corresponding segment number. Items in the list must be arranged starting at segment number 1 and increasing by 1.

For example, in the CT Spleen Segmentation application, the whole image background has a value of 0, and the Spleen segment of value 1. This then only requires the caller to pass in a list containing a segment description, which is used as label for the Spleen in the DICOM Seg instance.

Note: this interface is subject to change. It is planned that a new object will encapsulate the segment label information, including label value, name, description etc.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • segment_descriptions (List[SegmentDescription]) – List[SegmentDescription] Object encapsulating the description of each segment present in the segmentation.

  • output_folder (Path) – Folder for file output, overridden by named input on compute. Defaults to current working dir’s child folder, output.

  • model_info (ModelInfo, optional) – Object encapsulating model creator, name, version and UID.

  • custom_tags (Optional[Dict[str, str]]) – Optional[Dict[str, str]], optional Dictionary for setting custom DICOM tags using Keywords and str values only

  • omit_empty_frames (bool) – bool, optional Whether to omit frames that contain no segmented pixels from the output segmentation. Defaults to True, same as the underlying lib API.

add_arg(*args, **kwargs)

Overloaded function.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.Arg) -> None

Add an argument to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ArgList) -> None

Add a list of arguments to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, **kwargs) -> None

Add arguments to the component via Python kwargs.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ConditionBase) -> None

  2. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ResourceBase) -> None

Add a condition or resource to the Operator.

This can be used to add a condition or resource to an operator after it has already been constructed.

Parameters#

argholoscan.core.Condition or holoscan.core.Resource

The condition or resource to add.

add_dynamic_flow(*args, **kwargs)

Overloaded function.

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flow: holoscan.core._core.FlowInfo) -> None

  2. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flows: list[holoscan.core._core.FlowInfo]) -> None

  3. add_dynamic_flow(self: holoscan.core._core.OperatorBase, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

Add a dynamic flow from this operator to another operator.

Parameters#

next_opholoscan.core.Operator

The downstream operator to connect to.

next_input_port_namestr, optional

The name of the input port on the downstream operator to connect to. If not specified, the first available input port will be used.

Notes#

This method has several overloads to support different ways of creating dynamic flows:

  1. add_dynamic_flow(next_op: Operator, next_input_port_name: str = ‘’) - Basic connection using default output port. This is the simplest form for connecting

    two operators when you only need to specify the destination.

  2. add_dynamic_flow(curr_output_port_name: str, next_op: Operator, next_input_port_name: str = ‘’) - Connection with explicit output port specification. Use this when the source operator has

    multiple output ports and you need to specify which one to use.

  3. add_dynamic_flow(flow: FlowInfo) - Connection using a FlowInfo object, which encapsulates all connection details including:

    • Source operator and its output port specification

    • Destination operator and its input port specification

    • Port names and associated IOSpecs

    • This is useful for complex connections or when reusing connection patterns.

  4. add_dynamic_flow(flows: List[FlowInfo]) - Batch connection using multiple FlowInfo objects. Use this to set up multiple

    connections in a single call, which is more efficient than making multiple individual connections.

The FlowInfo class provides a complete description of a flow connection between operators, including all port specifications and naming. It’s particularly useful when you need to:

  • Store and reuse connection patterns

  • Create complex routing configurations

  • Handle dynamic port specifications

  • Manage multiple connections systematically

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, curr_output_port_name: str, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

property args

The list of arguments associated with the component.

Returns#

arglist : holoscan.core.ArgList

property async_condition

The internal asynchronous condition for the operator.

This property provides access to the internal asynchronous condition for the operator, which controls the scheduling of the operator’s compute method.

Returns#

conditionholoscan.conditions.AsynchronousCondition

An instance of holoscan.conditions.AsynchronousCondition that is the internal asynchronous condition for the operator.

Notes#

This object is only accessible after the executor has called Operator.initialize() via run() or run_async(). If accessed during Application.compose(), it will return None.

compute(op_input, op_output, context)[source]

Performs computation for this operator and handles I/O.

For now, only a single segmentation image object or file is supported and the selected DICOM series for inference is required, because the DICOM Seg IOD needs to refer to original instance. When there are multiple selected series in the input, the first series’ containing study will be used for retrieving DICOM Study module attributes, e.g. StudyInstanceUID.

Raises:
  • FileNotFoundError – When image object not in the input, and segmentation image file not found either.

  • ValueError – Neither image object nor image file’s folder is in the input, or no selected series.

property conditions

Conditions associated with the operator.

property description

YAML formatted string describing the operator.

enable_metadata(self: holoscan.core._core.OperatorBase, enable: bool) None

Configure whether or not the metadata feature is enabled for this operator. If it is not set, the default value will be determined by the enable_metadata setting from the Fragment that this operator belongs to.

property execution_context

The execution context for the operator.

This property provides access to the execution context of the operator, which contains information about the current execution environment including scheduling details.

Returns#

holoscan.core.ExecutionContext

The execution context object for this operator.

find_all_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) list[holoscan.core._core.FlowInfo]

Find all flow info objects in the operator’s next flows that match a given condition.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

list[holoscan.core.FlowInfo]

List of matching FlowInfo objects.

find_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) holoscan.core._core.FlowInfo

Find a flow info in the operator’s next flows based on a given predicate.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

holoscan.core.FlowInfo or None

The first matching FlowInfo object, or None if not found.

property fragment

The fragment (holoscan.core.Fragment) that the operator belongs to.

property id

The identifier of the component.

The identifier is initially set to -1, and will become a valid value when the component is initialized.

With the default executor (holoscan.gxf.GXFExecutor), the identifier is set to the GXF component ID.

Returns#

id : int

initialize()

Default implementation of initialize

property is_metadata_enabled

Boolean indicating whether the fragment this operator belongs to has metadata transmission enabled.

property metadata

The metadata dictionary (holoscan.core.MetadataDictionary) associated with the operator.

property metadata_policy

The metadata policy (holoscan.core.MetadataPolicy) associated with the operator.

The supported policies are:

  • MetadataPolicy.REJECT: Reject the new value if the key already exists

  • MetadataPolicy.UPDATE: Replace existing value with the new one if the key already exists

  • MetadataPolicy.INPLACE_UPDATE: Update the value stored within an existing MetadataObject in-place if the key already exists (in contrast to UPDATE which always replaces the existing MetadataObject with a new one).

  • MetadataPolicy.RAISE: Raise an exception if the key already exists

property name

The name of the operator.

property next_flows

Get the list of flow information for connections to downstream operators.

Returns#

list[holoscan.core.FlowInfo]

List of flow information objects describing connections to downstream operators.

property operator_type

The operator type.

holoscan.core.Operator.OperatorType enum representing the type of the operator. The two types currently implemented are native and GXF.

queue_policy(self: holoscan.core._core.OperatorBase, port_name: str, port_type: holoscan.core._core.IOSpec.IOType = <IOType.INPUT: 0>, policy: holoscan.core._core.IOSpec.QueuePolicy = <QueuePolicy.FAULT: 2>) None

Set the queue policy to be used by an input (or output) port’s receiver (or transmitter).

Parameters#

port_namestr

The name of the port.

port_typeIOSpec.IOType, optional

Enum indicating whether port_name corresponds to an input port or output port.

policyIOSpec.QueuePolicy, optional

The queue policy to set. Valid values are:

  • QueuePolicy.POP : If the queue is full, pop the oldest item, then add the new one.

  • QueuePolicy.REJECT : If the queue is full, reject (discard) the new item.

  • QueuePolicy.FAULT : If the queue is full, log a warning and reject the new item.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

receiver(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Receiver]

Get the receiver used by an input port.

Parameters#

port_namestr

The name of the input port.

Returns#

receiverholoscan.resources.Receiver

The receiver used by this input port. Will be None if the port does not exist.

resource(self: holoscan.core._core.OperatorBase, name: str) object | None

Resources associated with the operator.

Parameters#

namestr

The name of the resource to retrieve

Returns#

holoscan.core.Resource or None

The resource with the given name. If no resource with the given name is found, None is returned.

property resources

Resources associated with the operator.

select_input_file(input_folder, extensions=['.nii', '.nii.gz', '.mhd'])[source]

Select the input files based on supported extensions.

Parameters:
  • input_folder (string) – the path of the folder containing the input file(s)

  • extensions (array) – the supported file formats identified by the extensions.

Returns:

The path of the selected file ext (string): The extension of the selected file

Return type:

file_path (string)

service(self: object, service_type: type, id: str = '') object

Retrieve a registered fragment service through the component’s fragment.

This method delegates to the fragment’s service() method to retrieve a previously registered fragment service by its type and optional identifier. Returns None if no fragment service is found with the specified type and identifier.

Parameters#

service_typetype

The type of the fragment service to retrieve. Must be a type that inherits from Resource or FragmentService.

idstr, optional

The identifier of the fragment service. If empty, retrieves by service type only. For Resources, this would typically be the resource’s name.

Returns#

object or None

The fragment service instance of the requested type, or None if not found. If the service wraps a Resource and a Resource type is requested, the unwrapped Resource instance is returned.

Raises#

RuntimeError

If the component has no associated fragment or if the fragment’s service method cannot be accessed.

Notes#

This is a convenience method that internally calls the fragment’s service() method. For services that wrap Resources, the method will automatically unwrap and return the Resource if a Resource type is requested.

setup(spec)[source]

Set up the named input(s), and output(s) if applicable, aka ports.

Parameters:

spec (OperatorSpec) – The Operator specification for inputs and outputs etc.

property spec

The operator spec (holoscan.core.OperatorSpec) associated with the operator.

start()

Default implementation of start

stop()

Default implementation of stop

stop_execution(self: holoscan.core._core.OperatorBase) None

Stop the execution of the operator.

This method is used to stop the execution of the operator by setting the internal async condition to EVENT_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operator will not be scheduled for execution (the compute() method will not be called).

Note that executing this method does not trigger the operator’s stop() method. The stop() method is called only when the scheduler deactivates all operators together.

transmitter(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Transmitter]

Get the transmitter used by an output port.

Parameters#

port_namestr

The name of the output port.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

class monai.deploy.operators.DICOMSeriesSelectorOperator(fragment, *args, rules='', all_matched=False, sort_by_sop_instance_count=False, **kwargs)[source]

Bases: Operator

This operator selects a list of DICOM Series in a DICOM Study for a given set of selection rules.

Named input:

dicom_study_list: A list of DICOMStudy objects.

Named output:

study_selected_series_list: A list of StudySelectedSeries objects. Downstream receiver optional.

This class can be considered a base class, and a derived class can override the ‘filter’ function with custom logic.

In its default implementation, this class
  1. selects a series or all matched series within the scope of a study in a list of studies

  2. uses rules defined in JSON string, see below for details

  3. supports DICOM Study and Series module attribute matching

  4. supports multiple named selections, in the scope of each DICOM study

  5. outputs a list of StudySelectedSeries objects, as well as a flat list of SelectedSeries (to be deprecated)

The selection rules are defined in JSON,
  1. attribute “selections” value is a list of selections

  2. each selection has a “name”, and its “conditions” value is a list of matching criteria

  3. each condition uses the implicit equal operator; in addition, the following are supported:
    • regex, relational, and range matching for float and int types

    • regex matching for str type

    • inclusion and exclusion matching for set type

    • image orientation check for the ImageOrientationPatient tag

  4. DICOM attribute keywords are used, and only for those defined as DICOMStudy and DICOMSeries properties

An example selection rules: {

“selections”: [
{

“name”: “CT Series 1”, “conditions”: {

“StudyDescription”: “(?i)^Spleen”, “Modality”: “(?i)CT”, “SeriesDescription”: “(?i)^No series description|(.*?)”

}

}, {

“name”: “CT Series 2”, “conditions”: {

“Modality”: “CT”, “BodyPartExamined”: “Abdomen”, “SeriesDescription” : “Not to be matched. For illustration only.”

}

}, {

“name”: “CT Series 3”, “conditions”: {

“StudyDescription”: “(.*?)”, “Modality”: “(?i)CT”, “ImageType”: [“PRIMARY”, “ORIGINAL”, “AXIAL”], “SliceThickness”: [3, 5]

}

}, {

“name”: “CT Series 4”, “conditions”: {

“StudyDescription”: “(.*?)”, “Modality”: “(?i)CT”, “ImageOrientationPatient”: “Axial”, “SliceThickness”: [2, “>”]

}

}, {

“name”: “CT Series 5”, “conditions”: {

“StudyDescription”: “(.*?)”, “Modality”: “(?i)CT”, “ImageType”: [“PRIMARY”, “!SECONDARY”]

}

}

]

}

Instantiate an instance.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • rules (Text) – Selection rules in JSON string.

  • all_matched (bool) – Gets all matched series in a study. Defaults to False for first match only.

  • sort_by_sop_instance_count (bool) – If all_matched = True and multiple series are matched, sorts the matched series in

  • # (descending SOP instance count (i.e. the first Series in the returned List[StudySelectedSeries] will have the highest)

  • sorting. (of DICOM images); Defaults to False for no)

class OperatorType(self: holoscan.core._core.OperatorBase.OperatorType, value: int)

Bases: pybind11_object

Enum class for operator types used by the executor.

  • NATIVE: Native operator.

  • GXF: GXF operator.

  • VIRTUAL: Virtual operator. (for internal use, not intended for use by application authors)

Members:

NATIVE

GXF

VIRTUAL

property name
__init__(fragment, *args, rules='', all_matched=False, sort_by_sop_instance_count=False, **kwargs)[source]

Instantiate an instance.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • rules (Text) – Selection rules in JSON string.

  • all_matched (bool) – Gets all matched series in a study. Defaults to False for first match only.

  • sort_by_sop_instance_count (bool) – If all_matched = True and multiple series are matched, sorts the matched series in

  • # (descending SOP instance count (i.e. the first Series in the returned List[StudySelectedSeries] will have the highest)

  • sorting. (of DICOM images); Defaults to False for no)

add_arg(*args, **kwargs)

Overloaded function.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.Arg) -> None

Add an argument to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ArgList) -> None

Add a list of arguments to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, **kwargs) -> None

Add arguments to the component via Python kwargs.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ConditionBase) -> None

  2. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ResourceBase) -> None

Add a condition or resource to the Operator.

This can be used to add a condition or resource to an operator after it has already been constructed.

Parameters#

argholoscan.core.Condition or holoscan.core.Resource

The condition or resource to add.

add_dynamic_flow(*args, **kwargs)

Overloaded function.

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flow: holoscan.core._core.FlowInfo) -> None

  2. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flows: list[holoscan.core._core.FlowInfo]) -> None

  3. add_dynamic_flow(self: holoscan.core._core.OperatorBase, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

Add a dynamic flow from this operator to another operator.

Parameters#

next_opholoscan.core.Operator

The downstream operator to connect to.

next_input_port_namestr, optional

The name of the input port on the downstream operator to connect to. If not specified, the first available input port will be used.

Notes#

This method has several overloads to support different ways of creating dynamic flows:

  1. add_dynamic_flow(next_op: Operator, next_input_port_name: str = ‘’) - Basic connection using default output port. This is the simplest form for connecting

    two operators when you only need to specify the destination.

  2. add_dynamic_flow(curr_output_port_name: str, next_op: Operator, next_input_port_name: str = ‘’) - Connection with explicit output port specification. Use this when the source operator has

    multiple output ports and you need to specify which one to use.

  3. add_dynamic_flow(flow: FlowInfo) - Connection using a FlowInfo object, which encapsulates all connection details including:

    • Source operator and its output port specification

    • Destination operator and its input port specification

    • Port names and associated IOSpecs

    • This is useful for complex connections or when reusing connection patterns.

  4. add_dynamic_flow(flows: List[FlowInfo]) - Batch connection using multiple FlowInfo objects. Use this to set up multiple

    connections in a single call, which is more efficient than making multiple individual connections.

The FlowInfo class provides a complete description of a flow connection between operators, including all port specifications and naming. It’s particularly useful when you need to:

  • Store and reuse connection patterns

  • Create complex routing configurations

  • Handle dynamic port specifications

  • Manage multiple connections systematically

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, curr_output_port_name: str, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

property args

The list of arguments associated with the component.

Returns#

arglist : holoscan.core.ArgList

property async_condition

The internal asynchronous condition for the operator.

This property provides access to the internal asynchronous condition for the operator, which controls the scheduling of the operator’s compute method.

Returns#

conditionholoscan.conditions.AsynchronousCondition

An instance of holoscan.conditions.AsynchronousCondition that is the internal asynchronous condition for the operator.

Notes#

This object is only accessible after the executor has called Operator.initialize() via run() or run_async(). If accessed during Application.compose(), it will return None.

compute(op_input, op_output, context)[source]

Performs computation for this operator.

property conditions

Conditions associated with the operator.

property description

YAML formatted string describing the operator.

enable_metadata(self: holoscan.core._core.OperatorBase, enable: bool) None

Configure whether or not the metadata feature is enabled for this operator. If it is not set, the default value will be determined by the enable_metadata setting from the Fragment that this operator belongs to.

property execution_context

The execution context for the operator.

This property provides access to the execution context of the operator, which contains information about the current execution environment including scheduling details.

Returns#

holoscan.core.ExecutionContext

The execution context object for this operator.

filter(selection_rules, dicom_study_list, all_matched=False, sort_by_sop_instance_count=False)[source]

Selects the series with the given matching rules.

If rules object is None, all series will be returned with series instance UID as the selection name.

Supported matching logic:

Float + Int: exact matching, relational matching, range matching, and regex matching String: matches case insensitive, if fails then tries RegEx search String array (set): inclusive and exclusive (via !) matching as subsets, case insensitive ImageOrientationPatient tag: image orientation (Axial, Coronal, Sagittal) matching

Parameters:
  • selection_rules (object) – JSON object containing the matching rules.

  • dicom_study_list (list) – A list of DICOMStudy objects.

  • all_matched (bool) – Gets all matched series in a study. Defaults to False for first match only.

  • sort_by_sop_instance_count (bool) – If all_matched = True and multiple series are matched, sorts the matched series in

  • # (descending SOP instance count (i.e. the first Series in the returned List[StudySelectedSeries] will have the highest)

  • sorting. (of DICOM images); Defaults to False for no)

Returns:

A list of objects of type StudySelectedSeries.

Return type:

list

Raises:

ValueError – If the selection_rules object does not contain “selections” attribute.

find_all_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) list[holoscan.core._core.FlowInfo]

Find all flow info objects in the operator’s next flows that match a given condition.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

list[holoscan.core.FlowInfo]

List of matching FlowInfo objects.

find_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) holoscan.core._core.FlowInfo

Find a flow info in the operator’s next flows based on a given predicate.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

holoscan.core.FlowInfo or None

The first matching FlowInfo object, or None if not found.

property fragment

The fragment (holoscan.core.Fragment) that the operator belongs to.

property id

The identifier of the component.

The identifier is initially set to -1, and will become a valid value when the component is initialized.

With the default executor (holoscan.gxf.GXFExecutor), the identifier is set to the GXF component ID.

Returns#

id : int

initialize()

Default implementation of initialize

property is_metadata_enabled

Boolean indicating whether the fragment this operator belongs to has metadata transmission enabled.

property metadata

The metadata dictionary (holoscan.core.MetadataDictionary) associated with the operator.

property metadata_policy

The metadata policy (holoscan.core.MetadataPolicy) associated with the operator.

The supported policies are:

  • MetadataPolicy.REJECT: Reject the new value if the key already exists

  • MetadataPolicy.UPDATE: Replace existing value with the new one if the key already exists

  • MetadataPolicy.INPLACE_UPDATE: Update the value stored within an existing MetadataObject in-place if the key already exists (in contrast to UPDATE which always replaces the existing MetadataObject with a new one).

  • MetadataPolicy.RAISE: Raise an exception if the key already exists

property name

The name of the operator.

property next_flows

Get the list of flow information for connections to downstream operators.

Returns#

list[holoscan.core.FlowInfo]

List of flow information objects describing connections to downstream operators.

property operator_type

The operator type.

holoscan.core.Operator.OperatorType enum representing the type of the operator. The two types currently implemented are native and GXF.

queue_policy(self: holoscan.core._core.OperatorBase, port_name: str, port_type: holoscan.core._core.IOSpec.IOType = <IOType.INPUT: 0>, policy: holoscan.core._core.IOSpec.QueuePolicy = <QueuePolicy.FAULT: 2>) None

Set the queue policy to be used by an input (or output) port’s receiver (or transmitter).

Parameters#

port_namestr

The name of the port.

port_typeIOSpec.IOType, optional

Enum indicating whether port_name corresponds to an input port or output port.

policyIOSpec.QueuePolicy, optional

The queue policy to set. Valid values are:

  • QueuePolicy.POP : If the queue is full, pop the oldest item, then add the new one.

  • QueuePolicy.REJECT : If the queue is full, reject (discard) the new item.

  • QueuePolicy.FAULT : If the queue is full, log a warning and reject the new item.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

receiver(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Receiver]

Get the receiver used by an input port.

Parameters#

port_namestr

The name of the input port.

Returns#

receiverholoscan.resources.Receiver

The receiver used by this input port. Will be None if the port does not exist.

resource(self: holoscan.core._core.OperatorBase, name: str) object | None

Resources associated with the operator.

Parameters#

namestr

The name of the resource to retrieve

Returns#

holoscan.core.Resource or None

The resource with the given name. If no resource with the given name is found, None is returned.

property resources

Resources associated with the operator.

service(self: object, service_type: type, id: str = '') object

Retrieve a registered fragment service through the component’s fragment.

This method delegates to the fragment’s service() method to retrieve a previously registered fragment service by its type and optional identifier. Returns None if no fragment service is found with the specified type and identifier.

Parameters#

service_typetype

The type of the fragment service to retrieve. Must be a type that inherits from Resource or FragmentService.

idstr, optional

The identifier of the fragment service. If empty, retrieves by service type only. For Resources, this would typically be the resource’s name.

Returns#

object or None

The fragment service instance of the requested type, or None if not found. If the service wraps a Resource and a Resource type is requested, the unwrapped Resource instance is returned.

Raises#

RuntimeError

If the component has no associated fragment or if the fragment’s service method cannot be accessed.

Notes#

This is a convenience method that internally calls the fragment’s service() method. For services that wrap Resources, the method will automatically unwrap and return the Resource if a Resource type is requested.

setup(spec)[source]

Default implementation of setup method.

property spec

The operator spec (holoscan.core.OperatorSpec) associated with the operator.

start()

Default implementation of start

stop()

Default implementation of stop

stop_execution(self: holoscan.core._core.OperatorBase) None

Stop the execution of the operator.

This method is used to stop the execution of the operator by setting the internal async condition to EVENT_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operator will not be scheduled for execution (the compute() method will not be called).

Note that executing this method does not trigger the operator’s stop() method. The stop() method is called only when the scheduler deactivates all operators together.

transmitter(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Transmitter]

Get the transmitter used by an output port.

Parameters#

port_namestr

The name of the output port.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

class monai.deploy.operators.DICOMSeriesToVolumeOperator(fragment, *args, affine_lps_to_ras=True, **kwargs)[source]

Bases: Operator

This operator converts an instance of DICOMSeries into an Image object.

The loaded Image Object can be used for further processing via other operators. The data array will be a 3D image NumPy array with index order of DHW. Channel is limited to 1 as of now, and C is absent in the NumPy array.

Named Input:

study_selected_series_list: List of StudySelectedSeries.

Named Output:

image: Image object.

Create an instance for a containing application object.

This operator converts instances of DICOMSeries into an Image object. The loaded Image Object can be used for further processing via other operators. The data array will be a 3D image NumPy array with index order of DHW. Channel is limited to 1 as of now, and C is absent in the NumPy array.

This operator registers nvimgcodec based compressed pixel data decoder plugin with Pydicom at application startup to support and improve the performance of decoding DICOM files with compressed pixel data of in JPEG, JPEG 2000, and HTJ2K, irrespective of if python-gdcm, Python libjpg and openjpeg based decoder plugins are available at runtime.

Registering the decoder plugin is all automatic and does not require any additional change in user’s application except for adding a dependency on the nvimgcodec-cu12 and nvidia-nvjpeg2k-cu12 packages (suffix of cu12 means CUDA 12.0 though cu13 is also supported).

Named Input:

study_selected_series_list: List of StudySelectedSeries.

Named Output:

image: Image object.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • affine_lps_to_ras (bool) – If true, the affine transform in the image metadata is RAS oriented, otherwise it is LPS oriented. Default is True.

class OperatorType(self: holoscan.core._core.OperatorBase.OperatorType, value: int)

Bases: pybind11_object

Enum class for operator types used by the executor.

  • NATIVE: Native operator.

  • GXF: GXF operator.

  • VIRTUAL: Virtual operator. (for internal use, not intended for use by application authors)

Members:

NATIVE

GXF

VIRTUAL

property name
__init__(fragment, *args, affine_lps_to_ras=True, **kwargs)[source]

Create an instance for a containing application object.

This operator converts instances of DICOMSeries into an Image object. The loaded Image Object can be used for further processing via other operators. The data array will be a 3D image NumPy array with index order of DHW. Channel is limited to 1 as of now, and C is absent in the NumPy array.

This operator registers nvimgcodec based compressed pixel data decoder plugin with Pydicom at application startup to support and improve the performance of decoding DICOM files with compressed pixel data of in JPEG, JPEG 2000, and HTJ2K, irrespective of if python-gdcm, Python libjpg and openjpeg based decoder plugins are available at runtime.

Registering the decoder plugin is all automatic and does not require any additional change in user’s application except for adding a dependency on the nvimgcodec-cu12 and nvidia-nvjpeg2k-cu12 packages (suffix of cu12 means CUDA 12.0 though cu13 is also supported).

Named Input:

study_selected_series_list: List of StudySelectedSeries.

Named Output:

image: Image object.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • affine_lps_to_ras (bool) – If true, the affine transform in the image metadata is RAS oriented, otherwise it is LPS oriented. Default is True.

add_arg(*args, **kwargs)

Overloaded function.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.Arg) -> None

Add an argument to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ArgList) -> None

Add a list of arguments to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, **kwargs) -> None

Add arguments to the component via Python kwargs.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ConditionBase) -> None

  2. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ResourceBase) -> None

Add a condition or resource to the Operator.

This can be used to add a condition or resource to an operator after it has already been constructed.

Parameters#

argholoscan.core.Condition or holoscan.core.Resource

The condition or resource to add.

add_dynamic_flow(*args, **kwargs)

Overloaded function.

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flow: holoscan.core._core.FlowInfo) -> None

  2. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flows: list[holoscan.core._core.FlowInfo]) -> None

  3. add_dynamic_flow(self: holoscan.core._core.OperatorBase, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

Add a dynamic flow from this operator to another operator.

Parameters#

next_opholoscan.core.Operator

The downstream operator to connect to.

next_input_port_namestr, optional

The name of the input port on the downstream operator to connect to. If not specified, the first available input port will be used.

Notes#

This method has several overloads to support different ways of creating dynamic flows:

  1. add_dynamic_flow(next_op: Operator, next_input_port_name: str = ‘’) - Basic connection using default output port. This is the simplest form for connecting

    two operators when you only need to specify the destination.

  2. add_dynamic_flow(curr_output_port_name: str, next_op: Operator, next_input_port_name: str = ‘’) - Connection with explicit output port specification. Use this when the source operator has

    multiple output ports and you need to specify which one to use.

  3. add_dynamic_flow(flow: FlowInfo) - Connection using a FlowInfo object, which encapsulates all connection details including:

    • Source operator and its output port specification

    • Destination operator and its input port specification

    • Port names and associated IOSpecs

    • This is useful for complex connections or when reusing connection patterns.

  4. add_dynamic_flow(flows: List[FlowInfo]) - Batch connection using multiple FlowInfo objects. Use this to set up multiple

    connections in a single call, which is more efficient than making multiple individual connections.

The FlowInfo class provides a complete description of a flow connection between operators, including all port specifications and naming. It’s particularly useful when you need to:

  • Store and reuse connection patterns

  • Create complex routing configurations

  • Handle dynamic port specifications

  • Manage multiple connections systematically

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, curr_output_port_name: str, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

property args

The list of arguments associated with the component.

Returns#

arglist : holoscan.core.ArgList

property async_condition

The internal asynchronous condition for the operator.

This property provides access to the internal asynchronous condition for the operator, which controls the scheduling of the operator’s compute method.

Returns#

conditionholoscan.conditions.AsynchronousCondition

An instance of holoscan.conditions.AsynchronousCondition that is the internal asynchronous condition for the operator.

Notes#

This object is only accessible after the executor has called Operator.initialize() via run() or run_async(). If accessed during Application.compose(), it will return None.

compute(op_input, op_output, context)[source]

Performs computation for this operator and handles I/O.

compute_affine_transform(s_1, s_n, n, series)[source]

Computes the affine transform for this series. It does it in both DICOM Patient oriented coordinate system as well as the pne preferred by NIFTI standard. Accordingly, the two attributes dicom_affine_transform and nifti_affine_transform are stored in the series instance.

The Image Orientation Patient contains two triplets, [rx ry rz cx cy cz], which encode direction cosines of the row and column of an image slice. The Image Position Patient of the first slice in a volume, [x1 y1 z1], is the x, y, z coordinates of the upper-left corner voxel of the slice. These two parameters define the location of the slice in PCS. To determine the location of a volume, the Image Position Patient of another slice is normally needed. In practice, we tend to use the position of the last slice in a volume, [xn yn zn]. The voxel size within the slice plane, [vr vc], is stored in object Pixel Spacing.

Parameters:
  • s_1 – A first slice in the series.

  • s_n – A last slice in the series.

  • n – A number of slices in the series.

  • series – An instance of DICOMSeries.

property conditions

Conditions associated with the operator.

convert_to_image(study_selected_series_list)[source]

Extracts the pixel data from a DICOM Series and other attributes to create an Image object

Return type:

Optional[Image]

create_metadata(series)[source]

Collects all relevant metadata from the DICOM Series and creates a dictionary.

Parameters:

series – An instance of DICOMSeries.

Return type:

Dict

Returns:

An instance of a dictionary containing metadata for the volumetric image.

create_volumetric_image(vox_data, metadata)[source]

Creates an instance of 3D image.

Parameters:
  • vox_data – A numpy array representing the volumetric data.

  • metadata – DICOM attributes in a dictionary.

Returns:

An instance of Image object.

property description

YAML formatted string describing the operator.

enable_metadata(self: holoscan.core._core.OperatorBase, enable: bool) None

Configure whether or not the metadata feature is enabled for this operator. If it is not set, the default value will be determined by the enable_metadata setting from the Fragment that this operator belongs to.

property execution_context

The execution context for the operator.

This property provides access to the execution context of the operator, which contains information about the current execution environment including scheduling details.

Returns#

holoscan.core.ExecutionContext

The execution context object for this operator.

find_all_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) list[holoscan.core._core.FlowInfo]

Find all flow info objects in the operator’s next flows that match a given condition.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

list[holoscan.core.FlowInfo]

List of matching FlowInfo objects.

find_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) holoscan.core._core.FlowInfo

Find a flow info in the operator’s next flows based on a given predicate.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

holoscan.core.FlowInfo or None

The first matching FlowInfo object, or None if not found.

property fragment

The fragment (holoscan.core.Fragment) that the operator belongs to.

generate_voxel_data(series)[source]

Applies rescale slope and rescale intercept to the pixels.

Supports monochrome image only for now. Photometric Interpretation attribute, tag (0028,0004), is considered. Both MONOCHROME2 (IDENTITY) and MONOCHROME1 (INVERSE) result in an output image where The minimum sample value is intended to be displayed as black.

Parameters:

series – DICOM Series for which the pixel data needs to be extracted.

Returns:

A 3D numpy tensor representing the volumetric data.

property id

The identifier of the component.

The identifier is initially set to -1, and will become a valid value when the component is initialized.

With the default executor (holoscan.gxf.GXFExecutor), the identifier is set to the GXF component ID.

Returns#

id : int

initialize()

Default implementation of initialize

property is_metadata_enabled

Boolean indicating whether the fragment this operator belongs to has metadata transmission enabled.

property metadata

The metadata dictionary (holoscan.core.MetadataDictionary) associated with the operator.

property metadata_policy

The metadata policy (holoscan.core.MetadataPolicy) associated with the operator.

The supported policies are:

  • MetadataPolicy.REJECT: Reject the new value if the key already exists

  • MetadataPolicy.UPDATE: Replace existing value with the new one if the key already exists

  • MetadataPolicy.INPLACE_UPDATE: Update the value stored within an existing MetadataObject in-place if the key already exists (in contrast to UPDATE which always replaces the existing MetadataObject with a new one).

  • MetadataPolicy.RAISE: Raise an exception if the key already exists

property name

The name of the operator.

property next_flows

Get the list of flow information for connections to downstream operators.

Returns#

list[holoscan.core.FlowInfo]

List of flow information objects describing connections to downstream operators.

property operator_type

The operator type.

holoscan.core.Operator.OperatorType enum representing the type of the operator. The two types currently implemented are native and GXF.

prepare_series(series)[source]

Computes the slice normal for each slice and then projects the first voxel of each slice on that slice normal.

It computes the distance of that point from the origin of the patient coordinate system along the slice normal. It orders the slices in the series according to that distance.

Parameters:

series – An instance of DICOMSeries.

queue_policy(self: holoscan.core._core.OperatorBase, port_name: str, port_type: holoscan.core._core.IOSpec.IOType = <IOType.INPUT: 0>, policy: holoscan.core._core.IOSpec.QueuePolicy = <QueuePolicy.FAULT: 2>) None

Set the queue policy to be used by an input (or output) port’s receiver (or transmitter).

Parameters#

port_namestr

The name of the port.

port_typeIOSpec.IOType, optional

Enum indicating whether port_name corresponds to an input port or output port.

policyIOSpec.QueuePolicy, optional

The queue policy to set. Valid values are:

  • QueuePolicy.POP : If the queue is full, pop the oldest item, then add the new one.

  • QueuePolicy.REJECT : If the queue is full, reject (discard) the new item.

  • QueuePolicy.FAULT : If the queue is full, log a warning and reject the new item.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

receiver(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Receiver]

Get the receiver used by an input port.

Parameters#

port_namestr

The name of the input port.

Returns#

receiverholoscan.resources.Receiver

The receiver used by this input port. Will be None if the port does not exist.

resource(self: holoscan.core._core.OperatorBase, name: str) object | None

Resources associated with the operator.

Parameters#

namestr

The name of the resource to retrieve

Returns#

holoscan.core.Resource or None

The resource with the given name. If no resource with the given name is found, None is returned.

property resources

Resources associated with the operator.

service(self: object, service_type: type, id: str = '') object

Retrieve a registered fragment service through the component’s fragment.

This method delegates to the fragment’s service() method to retrieve a previously registered fragment service by its type and optional identifier. Returns None if no fragment service is found with the specified type and identifier.

Parameters#

service_typetype

The type of the fragment service to retrieve. Must be a type that inherits from Resource or FragmentService.

idstr, optional

The identifier of the fragment service. If empty, retrieves by service type only. For Resources, this would typically be the resource’s name.

Returns#

object or None

The fragment service instance of the requested type, or None if not found. If the service wraps a Resource and a Resource type is requested, the unwrapped Resource instance is returned.

Raises#

RuntimeError

If the component has no associated fragment or if the fragment’s service method cannot be accessed.

Notes#

This is a convenience method that internally calls the fragment’s service() method. For services that wrap Resources, the method will automatically unwrap and return the Resource if a Resource type is requested.

setup(spec)[source]

Default implementation of setup method.

property spec

The operator spec (holoscan.core.OperatorSpec) associated with the operator.

start()

Default implementation of start

stop()

Default implementation of stop

stop_execution(self: holoscan.core._core.OperatorBase) None

Stop the execution of the operator.

This method is used to stop the execution of the operator by setting the internal async condition to EVENT_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operator will not be scheduled for execution (the compute() method will not be called).

Note that executing this method does not trigger the operator’s stop() method. The stop() method is called only when the scheduler deactivates all operators together.

transmitter(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Transmitter]

Get the transmitter used by an output port.

Parameters#

port_namestr

The name of the output port.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

class monai.deploy.operators.DICOMTextSRWriterOperator(fragment, *args, output_folder, model_info, copy_tags=True, equipment_info=None, custom_tags=None, **kwargs)[source]

Bases: Operator

Class to write DICOM Text SR Instance with provided text input.

Named inputs:

text: text content to be encapsulated in a DICOM instance file. study_selected_series_list: Optional, DICOM series for copying metadata from.

Named output:

None

File output:

Generated DICOM instance file in the provided output folder.

Class to write DICOM SR SOP Instance for AI textual result in memory or in a file.

Parameters:
  • output_folder (str or Path) – The folder for saving the generated DICOM instance file.

  • copy_tags (bool) – True, default, for copying DICOM attributes from a provided DICOMSeries. If True and no DICOMSeries obj provided, runtime exception is thrown.

  • model_info (ModelInfo) – Object encapsulating model creator, name, version and UID.

  • equipment_info (EquipmentInfo, optional) – Object encapsulating info for DICOM Equipment Module. Defaults to None.

  • custom_tags (Dict[str, str], optional) – Dictionary for setting custom DICOM tags using Keywords and str values only. Defaults to None.

Raises:

ValueError – If copy_tags is true and no DICOMSeries object provided, or if result cannot be found either in memory or from file.

class OperatorType(self: holoscan.core._core.OperatorBase.OperatorType, value: int)

Bases: pybind11_object

Enum class for operator types used by the executor.

  • NATIVE: Native operator.

  • GXF: GXF operator.

  • VIRTUAL: Virtual operator. (for internal use, not intended for use by application authors)

Members:

NATIVE

GXF

VIRTUAL

property name
__init__(fragment, *args, output_folder, model_info, copy_tags=True, equipment_info=None, custom_tags=None, **kwargs)[source]

Class to write DICOM SR SOP Instance for AI textual result in memory or in a file.

Parameters:
  • output_folder (str or Path) – The folder for saving the generated DICOM instance file.

  • copy_tags (bool) – True, default, for copying DICOM attributes from a provided DICOMSeries. If True and no DICOMSeries obj provided, runtime exception is thrown.

  • model_info (ModelInfo) – Object encapsulating model creator, name, version and UID.

  • equipment_info (EquipmentInfo, optional) – Object encapsulating info for DICOM Equipment Module. Defaults to None.

  • custom_tags (Dict[str, str], optional) – Dictionary for setting custom DICOM tags using Keywords and str values only. Defaults to None.

Raises:

ValueError – If copy_tags is true and no DICOMSeries object provided, or if result cannot be found either in memory or from file.

add_arg(*args, **kwargs)

Overloaded function.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.Arg) -> None

Add an argument to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ArgList) -> None

Add a list of arguments to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, **kwargs) -> None

Add arguments to the component via Python kwargs.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ConditionBase) -> None

  2. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ResourceBase) -> None

Add a condition or resource to the Operator.

This can be used to add a condition or resource to an operator after it has already been constructed.

Parameters#

argholoscan.core.Condition or holoscan.core.Resource

The condition or resource to add.

add_dynamic_flow(*args, **kwargs)

Overloaded function.

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flow: holoscan.core._core.FlowInfo) -> None

  2. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flows: list[holoscan.core._core.FlowInfo]) -> None

  3. add_dynamic_flow(self: holoscan.core._core.OperatorBase, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

Add a dynamic flow from this operator to another operator.

Parameters#

next_opholoscan.core.Operator

The downstream operator to connect to.

next_input_port_namestr, optional

The name of the input port on the downstream operator to connect to. If not specified, the first available input port will be used.

Notes#

This method has several overloads to support different ways of creating dynamic flows:

  1. add_dynamic_flow(next_op: Operator, next_input_port_name: str = ‘’) - Basic connection using default output port. This is the simplest form for connecting

    two operators when you only need to specify the destination.

  2. add_dynamic_flow(curr_output_port_name: str, next_op: Operator, next_input_port_name: str = ‘’) - Connection with explicit output port specification. Use this when the source operator has

    multiple output ports and you need to specify which one to use.

  3. add_dynamic_flow(flow: FlowInfo) - Connection using a FlowInfo object, which encapsulates all connection details including:

    • Source operator and its output port specification

    • Destination operator and its input port specification

    • Port names and associated IOSpecs

    • This is useful for complex connections or when reusing connection patterns.

  4. add_dynamic_flow(flows: List[FlowInfo]) - Batch connection using multiple FlowInfo objects. Use this to set up multiple

    connections in a single call, which is more efficient than making multiple individual connections.

The FlowInfo class provides a complete description of a flow connection between operators, including all port specifications and naming. It’s particularly useful when you need to:

  • Store and reuse connection patterns

  • Create complex routing configurations

  • Handle dynamic port specifications

  • Manage multiple connections systematically

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, curr_output_port_name: str, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

property args

The list of arguments associated with the component.

Returns#

arglist : holoscan.core.ArgList

property async_condition

The internal asynchronous condition for the operator.

This property provides access to the internal asynchronous condition for the operator, which controls the scheduling of the operator’s compute method.

Returns#

conditionholoscan.conditions.AsynchronousCondition

An instance of holoscan.conditions.AsynchronousCondition that is the internal asynchronous condition for the operator.

Notes#

This object is only accessible after the executor has called Operator.initialize() via run() or run_async(). If accessed during Application.compose(), it will return None.

compute(op_input, op_output, context)[source]

Performs computation for this operator and handles I/O.

For now, only a single result content is supported, which could be in memory or an accessible file. The DICOM series used during inference is optional, but is required if the copy_tags is true indicating the generated DICOM object needs to copy study level metadata.

When there are multiple selected series in the input, the first series’ containing study will be used for retrieving DICOM Study module attributes, e.g. StudyInstanceUID.

Raises:
  • FileNotFoundError – When result object not in the input, and result file not found either.

  • ValueError – Content object and file path not in the inputs, or no DICOM series when required.

  • IOError – If the input content is blank.

property conditions

Conditions associated with the operator.

property description

YAML formatted string describing the operator.

enable_metadata(self: holoscan.core._core.OperatorBase, enable: bool) None

Configure whether or not the metadata feature is enabled for this operator. If it is not set, the default value will be determined by the enable_metadata setting from the Fragment that this operator belongs to.

property execution_context

The execution context for the operator.

This property provides access to the execution context of the operator, which contains information about the current execution environment including scheduling details.

Returns#

holoscan.core.ExecutionContext

The execution context object for this operator.

find_all_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) list[holoscan.core._core.FlowInfo]

Find all flow info objects in the operator’s next flows that match a given condition.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

list[holoscan.core.FlowInfo]

List of matching FlowInfo objects.

find_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) holoscan.core._core.FlowInfo

Find a flow info in the operator’s next flows based on a given predicate.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

holoscan.core.FlowInfo or None

The first matching FlowInfo object, or None if not found.

property fragment

The fragment (holoscan.core.Fragment) that the operator belongs to.

property id

The identifier of the component.

The identifier is initially set to -1, and will become a valid value when the component is initialized.

With the default executor (holoscan.gxf.GXFExecutor), the identifier is set to the GXF component ID.

Returns#

id : int

initialize()

Default implementation of initialize

property is_metadata_enabled

Boolean indicating whether the fragment this operator belongs to has metadata transmission enabled.

property metadata

The metadata dictionary (holoscan.core.MetadataDictionary) associated with the operator.

property metadata_policy

The metadata policy (holoscan.core.MetadataPolicy) associated with the operator.

The supported policies are:

  • MetadataPolicy.REJECT: Reject the new value if the key already exists

  • MetadataPolicy.UPDATE: Replace existing value with the new one if the key already exists

  • MetadataPolicy.INPLACE_UPDATE: Update the value stored within an existing MetadataObject in-place if the key already exists (in contrast to UPDATE which always replaces the existing MetadataObject with a new one).

  • MetadataPolicy.RAISE: Raise an exception if the key already exists

property name

The name of the operator.

property next_flows

Get the list of flow information for connections to downstream operators.

Returns#

list[holoscan.core.FlowInfo]

List of flow information objects describing connections to downstream operators.

property operator_type

The operator type.

holoscan.core.Operator.OperatorType enum representing the type of the operator. The two types currently implemented are native and GXF.

queue_policy(self: holoscan.core._core.OperatorBase, port_name: str, port_type: holoscan.core._core.IOSpec.IOType = <IOType.INPUT: 0>, policy: holoscan.core._core.IOSpec.QueuePolicy = <QueuePolicy.FAULT: 2>) None

Set the queue policy to be used by an input (or output) port’s receiver (or transmitter).

Parameters#

port_namestr

The name of the port.

port_typeIOSpec.IOType, optional

Enum indicating whether port_name corresponds to an input port or output port.

policyIOSpec.QueuePolicy, optional

The queue policy to set. Valid values are:

  • QueuePolicy.POP : If the queue is full, pop the oldest item, then add the new one.

  • QueuePolicy.REJECT : If the queue is full, reject (discard) the new item.

  • QueuePolicy.FAULT : If the queue is full, log a warning and reject the new item.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

receiver(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Receiver]

Get the receiver used by an input port.

Parameters#

port_namestr

The name of the input port.

Returns#

receiverholoscan.resources.Receiver

The receiver used by this input port. Will be None if the port does not exist.

resource(self: holoscan.core._core.OperatorBase, name: str) object | None

Resources associated with the operator.

Parameters#

namestr

The name of the resource to retrieve

Returns#

holoscan.core.Resource or None

The resource with the given name. If no resource with the given name is found, None is returned.

property resources

Resources associated with the operator.

service(self: object, service_type: type, id: str = '') object

Retrieve a registered fragment service through the component’s fragment.

This method delegates to the fragment’s service() method to retrieve a previously registered fragment service by its type and optional identifier. Returns None if no fragment service is found with the specified type and identifier.

Parameters#

service_typetype

The type of the fragment service to retrieve. Must be a type that inherits from Resource or FragmentService.

idstr, optional

The identifier of the fragment service. If empty, retrieves by service type only. For Resources, this would typically be the resource’s name.

Returns#

object or None

The fragment service instance of the requested type, or None if not found. If the service wraps a Resource and a Resource type is requested, the unwrapped Resource instance is returned.

Raises#

RuntimeError

If the component has no associated fragment or if the fragment’s service method cannot be accessed.

Notes#

This is a convenience method that internally calls the fragment’s service() method. For services that wrap Resources, the method will automatically unwrap and return the Resource if a Resource type is requested.

setup(spec)[source]

Set up the named input(s), and output(s) if applicable.

This operator does not have an output for the next operator, rather file output only.

Parameters:

spec (OperatorSpec) – The Operator specification for inputs and outputs etc.

property spec

The operator spec (holoscan.core.OperatorSpec) associated with the operator.

start()

Default implementation of start

stop()

Default implementation of stop

stop_execution(self: holoscan.core._core.OperatorBase) None

Stop the execution of the operator.

This method is used to stop the execution of the operator by setting the internal async condition to EVENT_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operator will not be scheduled for execution (the compute() method will not be called).

Note that executing this method does not trigger the operator’s stop() method. The stop() method is called only when the scheduler deactivates all operators together.

transmitter(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Transmitter]

Get the transmitter used by an output port.

Parameters#

port_namestr

The name of the output port.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

write(content_text, dicom_series, output_dir)[source]

Writes DICOM object

Parameters:
  • content_file (str) – file containing the contents

  • dicom_series (DicomSeries) – DicomSeries object encapsulating the original series.

  • model_info (MoelInfo) – Object encapsulating model creator, name, version and UID.

Returns:

PyDicom Dataset

class monai.deploy.operators.EquipmentInfo(manufacturer='MONAI Deploy', manufacturer_model='MONAI Deploy App SDK', series_number='0000', software_version_number='')[source]

Bases: object

Class encapsulating attributes required for DICOM Equipment Module.

class monai.deploy.operators.IOMapping(label, data_type, storage_type)[source]

Bases: object

This object holds an I/O definition for an operator.

Creates an object holding an operator I/O definitions.

Limitations apply with the combination of data_type and storage_type, which will be validated at runtime.

Parameters:
  • label (str) – Label for the operator input or output.

  • data_type (Type) – Datatype of the I/O data content.

  • storage_type (IOType) – The storage type expected, i.e. IN_MEMORY or DISK.

__init__(label, data_type, storage_type)[source]

Creates an object holding an operator I/O definitions.

Limitations apply with the combination of data_type and storage_type, which will be validated at runtime.

Parameters:
  • label (str) – Label for the operator input or output.

  • data_type (Type) – Datatype of the I/O data content.

  • storage_type (IOType) – The storage type expected, i.e. IN_MEMORY or DISK.

class monai.deploy.operators.InferenceOperator(fragment, *args, **kwargs)[source]

Bases: Operator

The base operator for operators that perform AI inference.

This operator performs pre-transforms on a input image, inference with a given model, post-transforms, and final results generation.

Constructor of the operator.

class OperatorType(self: holoscan.core._core.OperatorBase.OperatorType, value: int)

Bases: pybind11_object

Enum class for operator types used by the executor.

  • NATIVE: Native operator.

  • GXF: GXF operator.

  • VIRTUAL: Virtual operator. (for internal use, not intended for use by application authors)

Members:

NATIVE

GXF

VIRTUAL

property name
__init__(fragment, *args, **kwargs)[source]

Constructor of the operator.

add_arg(*args, **kwargs)

Overloaded function.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.Arg) -> None

Add an argument to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ArgList) -> None

Add a list of arguments to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, **kwargs) -> None

Add arguments to the component via Python kwargs.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ConditionBase) -> None

  2. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ResourceBase) -> None

Add a condition or resource to the Operator.

This can be used to add a condition or resource to an operator after it has already been constructed.

Parameters#

argholoscan.core.Condition or holoscan.core.Resource

The condition or resource to add.

add_dynamic_flow(*args, **kwargs)

Overloaded function.

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flow: holoscan.core._core.FlowInfo) -> None

  2. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flows: list[holoscan.core._core.FlowInfo]) -> None

  3. add_dynamic_flow(self: holoscan.core._core.OperatorBase, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

Add a dynamic flow from this operator to another operator.

Parameters#

next_opholoscan.core.Operator

The downstream operator to connect to.

next_input_port_namestr, optional

The name of the input port on the downstream operator to connect to. If not specified, the first available input port will be used.

Notes#

This method has several overloads to support different ways of creating dynamic flows:

  1. add_dynamic_flow(next_op: Operator, next_input_port_name: str = ‘’) - Basic connection using default output port. This is the simplest form for connecting

    two operators when you only need to specify the destination.

  2. add_dynamic_flow(curr_output_port_name: str, next_op: Operator, next_input_port_name: str = ‘’) - Connection with explicit output port specification. Use this when the source operator has

    multiple output ports and you need to specify which one to use.

  3. add_dynamic_flow(flow: FlowInfo) - Connection using a FlowInfo object, which encapsulates all connection details including:

    • Source operator and its output port specification

    • Destination operator and its input port specification

    • Port names and associated IOSpecs

    • This is useful for complex connections or when reusing connection patterns.

  4. add_dynamic_flow(flows: List[FlowInfo]) - Batch connection using multiple FlowInfo objects. Use this to set up multiple

    connections in a single call, which is more efficient than making multiple individual connections.

The FlowInfo class provides a complete description of a flow connection between operators, including all port specifications and naming. It’s particularly useful when you need to:

  • Store and reuse connection patterns

  • Create complex routing configurations

  • Handle dynamic port specifications

  • Manage multiple connections systematically

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, curr_output_port_name: str, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

property args

The list of arguments associated with the component.

Returns#

arglist : holoscan.core.ArgList

property async_condition

The internal asynchronous condition for the operator.

This property provides access to the internal asynchronous condition for the operator, which controls the scheduling of the operator’s compute method.

Returns#

conditionholoscan.conditions.AsynchronousCondition

An instance of holoscan.conditions.AsynchronousCondition that is the internal asynchronous condition for the operator.

Notes#

This object is only accessible after the executor has called Operator.initialize() via run() or run_async(). If accessed during Application.compose(), it will return None.

compute(op_input, op_output, context)[source]

An abstract method that needs to be implemented by the user.

Parameters:
  • op_input (InputContext) – An input context for the operator.

  • op_output (OutputContext) – An output context for the operator.

  • context (ExecutionContext) – An execution context for the operator.

property conditions

Conditions associated with the operator.

property description

YAML formatted string describing the operator.

enable_metadata(self: holoscan.core._core.OperatorBase, enable: bool) None

Configure whether or not the metadata feature is enabled for this operator. If it is not set, the default value will be determined by the enable_metadata setting from the Fragment that this operator belongs to.

property execution_context

The execution context for the operator.

This property provides access to the execution context of the operator, which contains information about the current execution environment including scheduling details.

Returns#

holoscan.core.ExecutionContext

The execution context object for this operator.

find_all_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) list[holoscan.core._core.FlowInfo]

Find all flow info objects in the operator’s next flows that match a given condition.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

list[holoscan.core.FlowInfo]

List of matching FlowInfo objects.

find_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) holoscan.core._core.FlowInfo

Find a flow info in the operator’s next flows based on a given predicate.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

holoscan.core.FlowInfo or None

The first matching FlowInfo object, or None if not found.

property fragment

The fragment (holoscan.core.Fragment) that the operator belongs to.

property id

The identifier of the component.

The identifier is initially set to -1, and will become a valid value when the component is initialized.

With the default executor (holoscan.gxf.GXFExecutor), the identifier is set to the GXF component ID.

Returns#

id : int

initialize()

Default implementation of initialize

property is_metadata_enabled

Boolean indicating whether the fragment this operator belongs to has metadata transmission enabled.

property metadata

The metadata dictionary (holoscan.core.MetadataDictionary) associated with the operator.

property metadata_policy

The metadata policy (holoscan.core.MetadataPolicy) associated with the operator.

The supported policies are:

  • MetadataPolicy.REJECT: Reject the new value if the key already exists

  • MetadataPolicy.UPDATE: Replace existing value with the new one if the key already exists

  • MetadataPolicy.INPLACE_UPDATE: Update the value stored within an existing MetadataObject in-place if the key already exists (in contrast to UPDATE which always replaces the existing MetadataObject with a new one).

  • MetadataPolicy.RAISE: Raise an exception if the key already exists

property name

The name of the operator.

property next_flows

Get the list of flow information for connections to downstream operators.

Returns#

list[holoscan.core.FlowInfo]

List of flow information objects describing connections to downstream operators.

property operator_type

The operator type.

holoscan.core.Operator.OperatorType enum representing the type of the operator. The two types currently implemented are native and GXF.

post_process(data, *args, **kwargs)[source]

Transform the prediction results from the model(s).

This method must be overridden by a derived class.

Raises:

NotImplementedError – When the subclass does not override this method.

Return type:

Union[Image, Any, Tuple[Any, ...], Dict[Any, Any]]

pre_process(data, *args, **kwargs)[source]

Transforms input before being used for predicting on a model.

This method must be overridden by a derived class.

Raises:

NotImplementedError – When the subclass does not override this method.

Return type:

Union[Image, Any, Tuple[Any, ...], Dict[Any, Any]]

predict(data, *args, **kwargs)[source]

Predicts results using the models(s) with input tensors.

This method must be overridden by a derived class.

Raises:

NotImplementedError – When the subclass does not override this method.

Return type:

Union[Image, Any, Tuple[Any, ...], Dict[Any, Any]]

queue_policy(self: holoscan.core._core.OperatorBase, port_name: str, port_type: holoscan.core._core.IOSpec.IOType = <IOType.INPUT: 0>, policy: holoscan.core._core.IOSpec.QueuePolicy = <QueuePolicy.FAULT: 2>) None

Set the queue policy to be used by an input (or output) port’s receiver (or transmitter).

Parameters#

port_namestr

The name of the port.

port_typeIOSpec.IOType, optional

Enum indicating whether port_name corresponds to an input port or output port.

policyIOSpec.QueuePolicy, optional

The queue policy to set. Valid values are:

  • QueuePolicy.POP : If the queue is full, pop the oldest item, then add the new one.

  • QueuePolicy.REJECT : If the queue is full, reject (discard) the new item.

  • QueuePolicy.FAULT : If the queue is full, log a warning and reject the new item.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

receiver(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Receiver]

Get the receiver used by an input port.

Parameters#

port_namestr

The name of the input port.

Returns#

receiverholoscan.resources.Receiver

The receiver used by this input port. Will be None if the port does not exist.

resource(self: holoscan.core._core.OperatorBase, name: str) object | None

Resources associated with the operator.

Parameters#

namestr

The name of the resource to retrieve

Returns#

holoscan.core.Resource or None

The resource with the given name. If no resource with the given name is found, None is returned.

property resources

Resources associated with the operator.

service(self: object, service_type: type, id: str = '') object

Retrieve a registered fragment service through the component’s fragment.

This method delegates to the fragment’s service() method to retrieve a previously registered fragment service by its type and optional identifier. Returns None if no fragment service is found with the specified type and identifier.

Parameters#

service_typetype

The type of the fragment service to retrieve. Must be a type that inherits from Resource or FragmentService.

idstr, optional

The identifier of the fragment service. If empty, retrieves by service type only. For Resources, this would typically be the resource’s name.

Returns#

object or None

The fragment service instance of the requested type, or None if not found. If the service wraps a Resource and a Resource type is requested, the unwrapped Resource instance is returned.

Raises#

RuntimeError

If the component has no associated fragment or if the fragment’s service method cannot be accessed.

Notes#

This is a convenience method that internally calls the fragment’s service() method. For services that wrap Resources, the method will automatically unwrap and return the Resource if a Resource type is requested.

setup(spec)

Default implementation of setup method.

property spec

The operator spec (holoscan.core.OperatorSpec) associated with the operator.

start()

Default implementation of start

stop()

Default implementation of stop

stop_execution(self: holoscan.core._core.OperatorBase) None

Stop the execution of the operator.

This method is used to stop the execution of the operator by setting the internal async condition to EVENT_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operator will not be scheduled for execution (the compute() method will not be called).

Note that executing this method does not trigger the operator’s stop() method. The stop() method is called only when the scheduler deactivates all operators together.

transmitter(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Transmitter]

Get the transmitter used by an output port.

Parameters#

port_namestr

The name of the output port.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

class monai.deploy.operators.ModelInfo(creator='', name='', version='', uid='')[source]

Bases: object

Class encapsulating AI model information, according to IHE AI Results (AIR) Rev 1.1.

The attributes of the class will be used to populate the Contributing Equipment Sequence in the DICOM IOD per IHE AIR Rev 1.1, Section 6.5.3.1 General Result Encoding Requirements, as the following,

The Creator shall describe each algorithm that was used to generate the results in the Contributing Equipment Sequence (0018,A001). Multiple items may be included. The Creator shall encode the following details in the Contributing Equipment Sequence,

  • Purpose of Reference Code Sequence (0040,A170) shall be (Newcode1, 99IHE, 1630 “Processing Algorithm”)

  • Manufacturer (0008,0070)

  • Manufacturer’s Model Name (0008,1090)

  • Software Versions (0018,1020)

  • Device UID (0018,1002)

Each time an AI Model is modified, for example by training, it would be appropriate to update the Device UID.

class monai.deploy.operators.MonaiBundleInferenceOperator(fragment, *args, app_context, input_mapping, output_mapping, model_name='', bundle_path=None, bundle_config_names=<monai.deploy.operators.monai_bundle_inference_operator.BundleConfigNames object>, **kwargs)[source]

Bases: InferenceOperator

This inference operator automates the inference operation for a given MONAI Bundle.

This inference operator configures itself based on the parsed data from a MONAI bundle file. This file is included with a MAP as a Torchscript file with added bundle metadata or a zipped bundle with weights. The class will configure how to do pre- and post-processing, inference, which device to use, state its inputs, outputs, and dependencies. Its compute method is meant to be general purpose to most any bundle such that it will handle any input specified in the bundle and produce output as specified, using the inference object the bundle defines. A number of methods are provided which define parts of functionality relating to this behavior, users may wish to overwrite these to change behavior is needed for specific bundles.

The input(s) and output(s) for this operator need to be provided when an instance is created, and their labels need to correspond to the bundle network input and output names, which are also used as the keys in the pre and post processing.

For image input and output, the type is the Image class. For output of probabilities, the type is Dict.

This operator is expected to be linked with both source and destination operators, e.g. receiving an Image object from the DICOMSeriesToVolumeOperator, and passing a segmentation Image to the DICOMSegmentationWriterOperator. In such cases, the I/O storage type can only be IN_MEMORY due to the restrictions imposed by the application executor.

For the time being, the input and output to this operator are limited to in_memory object.

Create an instance of this class, associated with an Application/Fragment.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • app_context (AppContext) – Object holding the I/O and model paths, and potentially loaded models.

  • input_mapping (List[IOMapping]) – Define the inputs’ name, type, and storage type.

  • output_mapping (List[IOMapping]) – Defines the outputs’ name, type, and storage type.

  • model_name (Optional[str], optional) – Name of the model/bundle, needed in multi-model case. Defaults to “”.

  • bundle_path (Optional[str], optional) – Known path to the bundle file. Defaults to None.

  • bundle_config_names (BundleConfigNames, optional) – Relevant config item names in a the bundle. Defaults to DEFAULT_BundleConfigNames.

class OperatorType(self: holoscan.core._core.OperatorBase.OperatorType, value: int)

Bases: pybind11_object

Enum class for operator types used by the executor.

  • NATIVE: Native operator.

  • GXF: GXF operator.

  • VIRTUAL: Virtual operator. (for internal use, not intended for use by application authors)

Members:

NATIVE

GXF

VIRTUAL

property name
__init__(fragment, *args, app_context, input_mapping, output_mapping, model_name='', bundle_path=None, bundle_config_names=<monai.deploy.operators.monai_bundle_inference_operator.BundleConfigNames object>, **kwargs)[source]

Create an instance of this class, associated with an Application/Fragment.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • app_context (AppContext) – Object holding the I/O and model paths, and potentially loaded models.

  • input_mapping (List[IOMapping]) – Define the inputs’ name, type, and storage type.

  • output_mapping (List[IOMapping]) – Defines the outputs’ name, type, and storage type.

  • model_name (Optional[str], optional) – Name of the model/bundle, needed in multi-model case. Defaults to “”.

  • bundle_path (Optional[str], optional) – Known path to the bundle file. Defaults to None.

  • bundle_config_names (BundleConfigNames, optional) – Relevant config item names in a the bundle. Defaults to DEFAULT_BundleConfigNames.

add_arg(*args, **kwargs)

Overloaded function.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.Arg) -> None

Add an argument to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ArgList) -> None

Add a list of arguments to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, **kwargs) -> None

Add arguments to the component via Python kwargs.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ConditionBase) -> None

  2. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ResourceBase) -> None

Add a condition or resource to the Operator.

This can be used to add a condition or resource to an operator after it has already been constructed.

Parameters#

argholoscan.core.Condition or holoscan.core.Resource

The condition or resource to add.

add_dynamic_flow(*args, **kwargs)

Overloaded function.

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flow: holoscan.core._core.FlowInfo) -> None

  2. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flows: list[holoscan.core._core.FlowInfo]) -> None

  3. add_dynamic_flow(self: holoscan.core._core.OperatorBase, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

Add a dynamic flow from this operator to another operator.

Parameters#

next_opholoscan.core.Operator

The downstream operator to connect to.

next_input_port_namestr, optional

The name of the input port on the downstream operator to connect to. If not specified, the first available input port will be used.

Notes#

This method has several overloads to support different ways of creating dynamic flows:

  1. add_dynamic_flow(next_op: Operator, next_input_port_name: str = ‘’) - Basic connection using default output port. This is the simplest form for connecting

    two operators when you only need to specify the destination.

  2. add_dynamic_flow(curr_output_port_name: str, next_op: Operator, next_input_port_name: str = ‘’) - Connection with explicit output port specification. Use this when the source operator has

    multiple output ports and you need to specify which one to use.

  3. add_dynamic_flow(flow: FlowInfo) - Connection using a FlowInfo object, which encapsulates all connection details including:

    • Source operator and its output port specification

    • Destination operator and its input port specification

    • Port names and associated IOSpecs

    • This is useful for complex connections or when reusing connection patterns.

  4. add_dynamic_flow(flows: List[FlowInfo]) - Batch connection using multiple FlowInfo objects. Use this to set up multiple

    connections in a single call, which is more efficient than making multiple individual connections.

The FlowInfo class provides a complete description of a flow connection between operators, including all port specifications and naming. It’s particularly useful when you need to:

  • Store and reuse connection patterns

  • Create complex routing configurations

  • Handle dynamic port specifications

  • Manage multiple connections systematically

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, curr_output_port_name: str, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

property args

The list of arguments associated with the component.

Returns#

arglist : holoscan.core.ArgList

property async_condition

The internal asynchronous condition for the operator.

This property provides access to the internal asynchronous condition for the operator, which controls the scheduling of the operator’s compute method.

Returns#

conditionholoscan.conditions.AsynchronousCondition

An instance of holoscan.conditions.AsynchronousCondition that is the internal asynchronous condition for the operator.

Notes#

This object is only accessible after the executor has called Operator.initialize() via run() or run_async(). If accessed during Application.compose(), it will return None.

property bundle_path: Path | None

The path of the MONAI Bundle model.

compute(op_input, op_output, context)[source]

Infers with the input(s) and saves the prediction result(s) to output

Parameters:
  • op_input (InputContext) – An input context for the operator.

  • op_output (OutputContext) – An output context for the operator.

  • context (ExecutionContext) – An execution context for the operator.

property conditions

Conditions associated with the operator.

property description

YAML formatted string describing the operator.

enable_metadata(self: holoscan.core._core.OperatorBase, enable: bool) None

Configure whether or not the metadata feature is enabled for this operator. If it is not set, the default value will be determined by the enable_metadata setting from the Fragment that this operator belongs to.

property execution_context

The execution context for the operator.

This property provides access to the execution context of the operator, which contains information about the current execution environment including scheduling details.

Returns#

holoscan.core.ExecutionContext

The execution context object for this operator.

find_all_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) list[holoscan.core._core.FlowInfo]

Find all flow info objects in the operator’s next flows that match a given condition.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

list[holoscan.core.FlowInfo]

List of matching FlowInfo objects.

find_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) holoscan.core._core.FlowInfo

Find a flow info in the operator’s next flows based on a given predicate.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

holoscan.core.FlowInfo or None

The first matching FlowInfo object, or None if not found.

property fragment

The fragment (holoscan.core.Fragment) that the operator belongs to.

property id

The identifier of the component.

The identifier is initially set to -1, and will become a valid value when the component is initialized.

With the default executor (holoscan.gxf.GXFExecutor), the identifier is set to the GXF component ID.

Returns#

id : int

initialize()

Default implementation of initialize

property is_metadata_enabled

Boolean indicating whether the fragment this operator belongs to has metadata transmission enabled.

property metadata

The metadata dictionary (holoscan.core.MetadataDictionary) associated with the operator.

property metadata_policy

The metadata policy (holoscan.core.MetadataPolicy) associated with the operator.

The supported policies are:

  • MetadataPolicy.REJECT: Reject the new value if the key already exists

  • MetadataPolicy.UPDATE: Replace existing value with the new one if the key already exists

  • MetadataPolicy.INPLACE_UPDATE: Update the value stored within an existing MetadataObject in-place if the key already exists (in contrast to UPDATE which always replaces the existing MetadataObject with a new one).

  • MetadataPolicy.RAISE: Raise an exception if the key already exists

property name

The name of the operator.

property next_flows

Get the list of flow information for connections to downstream operators.

Returns#

list[holoscan.core.FlowInfo]

List of flow information objects describing connections to downstream operators.

property operator_type

The operator type.

holoscan.core.Operator.OperatorType enum representing the type of the operator. The two types currently implemented are native and GXF.

property parser: ConfigParser | None

The ConfigParser object.

post_process(data, *args, **kwargs)[source]

Processes the output list/dictionary with the stored transform sequence self._postproc.

The “processed_inputs”, in fact the metadata in it, need to be passed in so that the invertible transforms in the post processing can work properly.

Return type:

Union[Image, Any, Tuple[Any, ...], Dict[Any, Any]]

pre_process(data, *args, **kwargs)[source]

Processes the input dictionary with the stored transform sequence self._preproc.

Return type:

Union[Image, Any, Tuple[Any, ...], Dict[Any, Any]]

predict(data, *args, **kwargs)[source]

Predicts output using the inferer.

Return type:

Union[Image, Any, Tuple[Any, ...], Dict[Any, Any]]

queue_policy(self: holoscan.core._core.OperatorBase, port_name: str, port_type: holoscan.core._core.IOSpec.IOType = <IOType.INPUT: 0>, policy: holoscan.core._core.IOSpec.QueuePolicy = <QueuePolicy.FAULT: 2>) None

Set the queue policy to be used by an input (or output) port’s receiver (or transmitter).

Parameters#

port_namestr

The name of the port.

port_typeIOSpec.IOType, optional

Enum indicating whether port_name corresponds to an input port or output port.

policyIOSpec.QueuePolicy, optional

The queue policy to set. Valid values are:

  • QueuePolicy.POP : If the queue is full, pop the oldest item, then add the new one.

  • QueuePolicy.REJECT : If the queue is full, reject (discard) the new item.

  • QueuePolicy.FAULT : If the queue is full, log a warning and reject the new item.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

receiver(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Receiver]

Get the receiver used by an input port.

Parameters#

port_namestr

The name of the input port.

Returns#

receiverholoscan.resources.Receiver

The receiver used by this input port. Will be None if the port does not exist.

resource(self: holoscan.core._core.OperatorBase, name: str) object | None

Resources associated with the operator.

Parameters#

namestr

The name of the resource to retrieve

Returns#

holoscan.core.Resource or None

The resource with the given name. If no resource with the given name is found, None is returned.

property resources

Resources associated with the operator.

service(self: object, service_type: type, id: str = '') object

Retrieve a registered fragment service through the component’s fragment.

This method delegates to the fragment’s service() method to retrieve a previously registered fragment service by its type and optional identifier. Returns None if no fragment service is found with the specified type and identifier.

Parameters#

service_typetype

The type of the fragment service to retrieve. Must be a type that inherits from Resource or FragmentService.

idstr, optional

The identifier of the fragment service. If empty, retrieves by service type only. For Resources, this would typically be the resource’s name.

Returns#

object or None

The fragment service instance of the requested type, or None if not found. If the service wraps a Resource and a Resource type is requested, the unwrapped Resource instance is returned.

Raises#

RuntimeError

If the component has no associated fragment or if the fragment’s service method cannot be accessed.

Notes#

This is a convenience method that internally calls the fragment’s service() method. For services that wrap Resources, the method will automatically unwrap and return the Resource if a Resource type is requested.

setup(spec)[source]

Default implementation of setup method.

property spec

The operator spec (holoscan.core.OperatorSpec) associated with the operator.

start()

Default implementation of start

stop()

Default implementation of stop

stop_execution(self: holoscan.core._core.OperatorBase) None

Stop the execution of the operator.

This method is used to stop the execution of the operator by setting the internal async condition to EVENT_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operator will not be scheduled for execution (the compute() method will not be called).

Note that executing this method does not trigger the operator’s stop() method. The stop() method is called only when the scheduler deactivates all operators together.

transmitter(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Transmitter]

Get the transmitter used by an output port.

Parameters#

port_namestr

The name of the output port.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

class monai.deploy.operators.MonaiSegInferenceOperator(fragment, *args, roi_size, pre_transforms, post_transforms, app_context, model_name='', overlap=0.25, sw_batch_size=4, inferer=sliding_window, model_path=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/monai-deploy-app-sdk/checkouts/stable/docs/source/model/model.ts'), **kwargs)[source]

Bases: InferenceOperator

This segmentation operator uses MONAI transforms and performs Simple or Sliding Window Inference.

This operator performs pre-transforms on a input image, inference using a given model, and post-transforms. The segmentation image is saved as a named Image object in memory.

If specified in the post transforms, results may also be saved to disk.

This operator uses the MONAI inference utils functions for sliding window and simple inference, and thus input parameters need to be as expected by these functions.

Any additional sliding window arguments not explicitly defined in this operator can be passed via **kwargs for forwarding to ‘sliding_window_inference’.

Named Input:

image: Image object of the input image.

Named Output:

seg_image: Image object of the segmentation image. Not requiring a ready receiver.

Creates a instance of this class.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • roi_size (Sequence[int], int, optional) – The window size to execute “SLIDING_WINDOW” evaluation. Applicable for “SLIDING_WINDOW” only.

  • pre_transforms (Compose) – MONAI Compose object used for pre-transforms.

  • post_transforms (Compose) – MONAI Compose object used for post-transforms.

  • app_context (AppContext) – Object holding the I/O and model paths, and potentially loaded models.

  • model_name (str, optional) – Name of the model. Default to “” for single model app.

  • overlap (Sequence[float], float) – The amount of overlap between scans along each spatial dimension. Defaults to 0.25. Applicable for “SLIDING_WINDOW” only.

  • sw_batch_size (int) – The batch size to run window slices. Defaults to 4. Applicable for “SLIDING_WINDOW” only.

  • inferer (InfererType, str) – The type of inferer to use, “SIMPLE” or “SLIDING_WINDOW”. Defaults to “SLIDING_WINDOW”.

  • model_path (Path) – Path to the model file. Defaults to model/models.ts of current working dir.

  • **kwargs – any other sliding window parameters to forward (e.g. mode, cval, etc.).

class OperatorType(self: holoscan.core._core.OperatorBase.OperatorType, value: int)

Bases: pybind11_object

Enum class for operator types used by the executor.

  • NATIVE: Native operator.

  • GXF: GXF operator.

  • VIRTUAL: Virtual operator. (for internal use, not intended for use by application authors)

Members:

NATIVE

GXF

VIRTUAL

property name
__init__(fragment, *args, roi_size, pre_transforms, post_transforms, app_context, model_name='', overlap=0.25, sw_batch_size=4, inferer=sliding_window, model_path=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/monai-deploy-app-sdk/checkouts/stable/docs/source/model/model.ts'), **kwargs)[source]

Creates a instance of this class.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • roi_size (Sequence[int], int, optional) – The window size to execute “SLIDING_WINDOW” evaluation. Applicable for “SLIDING_WINDOW” only.

  • pre_transforms (Compose) – MONAI Compose object used for pre-transforms.

  • post_transforms (Compose) – MONAI Compose object used for post-transforms.

  • app_context (AppContext) – Object holding the I/O and model paths, and potentially loaded models.

  • model_name (str, optional) – Name of the model. Default to “” for single model app.

  • overlap (Sequence[float], float) – The amount of overlap between scans along each spatial dimension. Defaults to 0.25. Applicable for “SLIDING_WINDOW” only.

  • sw_batch_size (int) – The batch size to run window slices. Defaults to 4. Applicable for “SLIDING_WINDOW” only.

  • inferer (InfererType, str) – The type of inferer to use, “SIMPLE” or “SLIDING_WINDOW”. Defaults to “SLIDING_WINDOW”.

  • model_path (Path) – Path to the model file. Defaults to model/models.ts of current working dir.

  • **kwargs – any other sliding window parameters to forward (e.g. mode, cval, etc.).

add_arg(*args, **kwargs)

Overloaded function.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.Arg) -> None

Add an argument to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ArgList) -> None

Add a list of arguments to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, **kwargs) -> None

Add arguments to the component via Python kwargs.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ConditionBase) -> None

  2. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ResourceBase) -> None

Add a condition or resource to the Operator.

This can be used to add a condition or resource to an operator after it has already been constructed.

Parameters#

argholoscan.core.Condition or holoscan.core.Resource

The condition or resource to add.

add_dynamic_flow(*args, **kwargs)

Overloaded function.

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flow: holoscan.core._core.FlowInfo) -> None

  2. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flows: list[holoscan.core._core.FlowInfo]) -> None

  3. add_dynamic_flow(self: holoscan.core._core.OperatorBase, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

Add a dynamic flow from this operator to another operator.

Parameters#

next_opholoscan.core.Operator

The downstream operator to connect to.

next_input_port_namestr, optional

The name of the input port on the downstream operator to connect to. If not specified, the first available input port will be used.

Notes#

This method has several overloads to support different ways of creating dynamic flows:

  1. add_dynamic_flow(next_op: Operator, next_input_port_name: str = ‘’) - Basic connection using default output port. This is the simplest form for connecting

    two operators when you only need to specify the destination.

  2. add_dynamic_flow(curr_output_port_name: str, next_op: Operator, next_input_port_name: str = ‘’) - Connection with explicit output port specification. Use this when the source operator has

    multiple output ports and you need to specify which one to use.

  3. add_dynamic_flow(flow: FlowInfo) - Connection using a FlowInfo object, which encapsulates all connection details including:

    • Source operator and its output port specification

    • Destination operator and its input port specification

    • Port names and associated IOSpecs

    • This is useful for complex connections or when reusing connection patterns.

  4. add_dynamic_flow(flows: List[FlowInfo]) - Batch connection using multiple FlowInfo objects. Use this to set up multiple

    connections in a single call, which is more efficient than making multiple individual connections.

The FlowInfo class provides a complete description of a flow connection between operators, including all port specifications and naming. It’s particularly useful when you need to:

  • Store and reuse connection patterns

  • Create complex routing configurations

  • Handle dynamic port specifications

  • Manage multiple connections systematically

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, curr_output_port_name: str, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

property args

The list of arguments associated with the component.

Returns#

arglist : holoscan.core.ArgList

property async_condition

The internal asynchronous condition for the operator.

This property provides access to the internal asynchronous condition for the operator, which controls the scheduling of the operator’s compute method.

Returns#

conditionholoscan.conditions.AsynchronousCondition

An instance of holoscan.conditions.AsynchronousCondition that is the internal asynchronous condition for the operator.

Notes#

This object is only accessible after the executor has called Operator.initialize() via run() or run_async(). If accessed during Application.compose(), it will return None.

compute(op_input, op_output, context)[source]

Infers with the input image and save the predicted image to output

Parameters:
  • op_input (InputContext) – An input context for the operator.

  • op_output (OutputContext) – An output context for the operator.

  • context (ExecutionContext) – An execution context for the operator.

property conditions

Conditions associated with the operator.

property description

YAML formatted string describing the operator.

enable_metadata(self: holoscan.core._core.OperatorBase, enable: bool) None

Configure whether or not the metadata feature is enabled for this operator. If it is not set, the default value will be determined by the enable_metadata setting from the Fragment that this operator belongs to.

property execution_context

The execution context for the operator.

This property provides access to the execution context of the operator, which contains information about the current execution environment including scheduling details.

Returns#

holoscan.core.ExecutionContext

The execution context object for this operator.

static filter_sw_kwargs(**kwargs)[source]

Filters the keyword arguments into a tuple of two dictionaries:

  1. A dictionary of named parameters to pass to the sliding_window_inference function that:
    • Are not explicitly defined in the __init__ of this class

    • Are not explicitly used when calling sliding_window_inference

  2. A dictionary of named parameters to pass to the base class __init__ of this class that:
    • Are not used when calling sliding_window_inference

    • Can be successfully converted from Python –> Holoscan’s C++ layer

Parameters:

**kwargs – extra arguments passed into __init__ beyond the explicitly defined args.

Returns:

A filtered dictionary of arguments to be passed to sliding_window_inference. filtered_base_init_params: A filtered dictionary of arguments to be passed to the base class __init__.

Return type:

filtered_swi_params

find_all_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) list[holoscan.core._core.FlowInfo]

Find all flow info objects in the operator’s next flows that match a given condition.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

list[holoscan.core.FlowInfo]

List of matching FlowInfo objects.

find_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) holoscan.core._core.FlowInfo

Find a flow info in the operator’s next flows based on a given predicate.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

holoscan.core.FlowInfo or None

The first matching FlowInfo object, or None if not found.

property fragment

The fragment (holoscan.core.Fragment) that the operator belongs to.

property id

The identifier of the component.

The identifier is initially set to -1, and will become a valid value when the component is initialized.

With the default executor (holoscan.gxf.GXFExecutor), the identifier is set to the GXF component ID.

Returns#

id : int

property inferer: InfererType | str

The type of inferer to use

initialize()

Default implementation of initialize

property input_dataset_key

This is the input image key name used in dictionary based MONAI pre-transforms.

property is_metadata_enabled

Boolean indicating whether the fragment this operator belongs to has metadata transmission enabled.

property metadata

The metadata dictionary (holoscan.core.MetadataDictionary) associated with the operator.

property metadata_policy

The metadata policy (holoscan.core.MetadataPolicy) associated with the operator.

The supported policies are:

  • MetadataPolicy.REJECT: Reject the new value if the key already exists

  • MetadataPolicy.UPDATE: Replace existing value with the new one if the key already exists

  • MetadataPolicy.INPLACE_UPDATE: Update the value stored within an existing MetadataObject in-place if the key already exists (in contrast to UPDATE which always replaces the existing MetadataObject with a new one).

  • MetadataPolicy.RAISE: Raise an exception if the key already exists

property name

The name of the operator.

property next_flows

Get the list of flow information for connections to downstream operators.

Returns#

list[holoscan.core.FlowInfo]

List of flow information objects describing connections to downstream operators.

property operator_type

The operator type.

holoscan.core.Operator.OperatorType enum representing the type of the operator. The two types currently implemented are native and GXF.

property overlap

This is the overlap used during sliding window inference

post_process(data, *args, **kwargs)[source]

Transforms the prediction results from the model(s).

This method must be overridden by a derived class. Expected return is monai.transforms.Compose.

Parameters:

data (monai.transforms.Compose) – The pre-processing transforms in a Compose object.

Return type:

Union[Any, Image, Tuple[Any, ...], Dict[Any, Any]]

Returns:

monai.transforms.Compose encapsulating post-processing transforms.

Raises:

NotImplementedError – When the subclass does not override this method.

pre_process(data, *args, **kwargs)[source]

Transforms input before being used for predicting on a model.

This method must be overridden by a derived class. Expected return is monai.transforms.Compose.

Parameters:

data (monai.data.ImageReader) – Reader used in LoadImage to load monai.deploy.core.Image as the input.

Return type:

Union[Any, Image, Tuple[Any, ...], Dict[Any, Any]]

Returns:

monai.transforms.Compose encapsulating pre transforms

Raises:

NotImplementedError – When the subclass does not override this method.

property pred_dataset_key

This is the prediction key name used in dictionary based MONAI post-transforms.

predict(data, *args, **kwargs)[source]

Predicts results using the models(s) with input tensors.

This method is currently not used in this class, instead monai.inferers.sliding_window_inference is used.

Raises:

NotImplementedError – When the subclass does not override this method.

Return type:

Union[Image, Any, Tuple[Any, ...], Dict[Any, Any]]

queue_policy(self: holoscan.core._core.OperatorBase, port_name: str, port_type: holoscan.core._core.IOSpec.IOType = <IOType.INPUT: 0>, policy: holoscan.core._core.IOSpec.QueuePolicy = <QueuePolicy.FAULT: 2>) None

Set the queue policy to be used by an input (or output) port’s receiver (or transmitter).

Parameters#

port_namestr

The name of the port.

port_typeIOSpec.IOType, optional

Enum indicating whether port_name corresponds to an input port or output port.

policyIOSpec.QueuePolicy, optional

The queue policy to set. Valid values are:

  • QueuePolicy.POP : If the queue is full, pop the oldest item, then add the new one.

  • QueuePolicy.REJECT : If the queue is full, reject (discard) the new item.

  • QueuePolicy.FAULT : If the queue is full, log a warning and reject the new item.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

receiver(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Receiver]

Get the receiver used by an input port.

Parameters#

port_namestr

The name of the input port.

Returns#

receiverholoscan.resources.Receiver

The receiver used by this input port. Will be None if the port does not exist.

resource(self: holoscan.core._core.OperatorBase, name: str) object | None

Resources associated with the operator.

Parameters#

namestr

The name of the resource to retrieve

Returns#

holoscan.core.Resource or None

The resource with the given name. If no resource with the given name is found, None is returned.

property resources

Resources associated with the operator.

property roi_size

The ROI size of tensors used in prediction.

service(self: object, service_type: type, id: str = '') object

Retrieve a registered fragment service through the component’s fragment.

This method delegates to the fragment’s service() method to retrieve a previously registered fragment service by its type and optional identifier. Returns None if no fragment service is found with the specified type and identifier.

Parameters#

service_typetype

The type of the fragment service to retrieve. Must be a type that inherits from Resource or FragmentService.

idstr, optional

The identifier of the fragment service. If empty, retrieves by service type only. For Resources, this would typically be the resource’s name.

Returns#

object or None

The fragment service instance of the requested type, or None if not found. If the service wraps a Resource and a Resource type is requested, the unwrapped Resource instance is returned.

Raises#

RuntimeError

If the component has no associated fragment or if the fragment’s service method cannot be accessed.

Notes#

This is a convenience method that internally calls the fragment’s service() method. For services that wrap Resources, the method will automatically unwrap and return the Resource if a Resource type is requested.

setup(spec)[source]

Default implementation of setup method.

property spec

The operator spec (holoscan.core.OperatorSpec) associated with the operator.

start()

Default implementation of start

stop()

Default implementation of stop

stop_execution(self: holoscan.core._core.OperatorBase) None

Stop the execution of the operator.

This method is used to stop the execution of the operator by setting the internal async condition to EVENT_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operator will not be scheduled for execution (the compute() method will not be called).

Note that executing this method does not trigger the operator’s stop() method. The stop() method is called only when the scheduler deactivates all operators together.

property sw_batch_size

The batch size to run window slices

transmitter(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Transmitter]

Get the transmitter used by an output port.

Parameters#

port_namestr

The name of the output port.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

class monai.deploy.operators.NiftiDataLoader(fragment, *args, input_path, **kwargs)[source]

Bases: Operator

This operator reads a nifti image, extracts the numpy array and forwards it to the next operator

Named input:

image_path: Path to the image file, optional. Use it to override the input path set on the object.

Named output:

image: A Numpy array object. Downstream receiver optional.

Creates an instance with the file path to load image from.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • input_path (Path) – The file Path to read from, overridden by valid named input on compute.

class OperatorType(self: holoscan.core._core.OperatorBase.OperatorType, value: int)

Bases: pybind11_object

Enum class for operator types used by the executor.

  • NATIVE: Native operator.

  • GXF: GXF operator.

  • VIRTUAL: Virtual operator. (for internal use, not intended for use by application authors)

Members:

NATIVE

GXF

VIRTUAL

property name
__init__(fragment, *args, input_path, **kwargs)[source]

Creates an instance with the file path to load image from.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • input_path (Path) – The file Path to read from, overridden by valid named input on compute.

add_arg(*args, **kwargs)

Overloaded function.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.Arg) -> None

Add an argument to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ArgList) -> None

Add a list of arguments to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, **kwargs) -> None

Add arguments to the component via Python kwargs.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ConditionBase) -> None

  2. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ResourceBase) -> None

Add a condition or resource to the Operator.

This can be used to add a condition or resource to an operator after it has already been constructed.

Parameters#

argholoscan.core.Condition or holoscan.core.Resource

The condition or resource to add.

add_dynamic_flow(*args, **kwargs)

Overloaded function.

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flow: holoscan.core._core.FlowInfo) -> None

  2. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flows: list[holoscan.core._core.FlowInfo]) -> None

  3. add_dynamic_flow(self: holoscan.core._core.OperatorBase, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

Add a dynamic flow from this operator to another operator.

Parameters#

next_opholoscan.core.Operator

The downstream operator to connect to.

next_input_port_namestr, optional

The name of the input port on the downstream operator to connect to. If not specified, the first available input port will be used.

Notes#

This method has several overloads to support different ways of creating dynamic flows:

  1. add_dynamic_flow(next_op: Operator, next_input_port_name: str = ‘’) - Basic connection using default output port. This is the simplest form for connecting

    two operators when you only need to specify the destination.

  2. add_dynamic_flow(curr_output_port_name: str, next_op: Operator, next_input_port_name: str = ‘’) - Connection with explicit output port specification. Use this when the source operator has

    multiple output ports and you need to specify which one to use.

  3. add_dynamic_flow(flow: FlowInfo) - Connection using a FlowInfo object, which encapsulates all connection details including:

    • Source operator and its output port specification

    • Destination operator and its input port specification

    • Port names and associated IOSpecs

    • This is useful for complex connections or when reusing connection patterns.

  4. add_dynamic_flow(flows: List[FlowInfo]) - Batch connection using multiple FlowInfo objects. Use this to set up multiple

    connections in a single call, which is more efficient than making multiple individual connections.

The FlowInfo class provides a complete description of a flow connection between operators, including all port specifications and naming. It’s particularly useful when you need to:

  • Store and reuse connection patterns

  • Create complex routing configurations

  • Handle dynamic port specifications

  • Manage multiple connections systematically

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, curr_output_port_name: str, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

property args

The list of arguments associated with the component.

Returns#

arglist : holoscan.core.ArgList

property async_condition

The internal asynchronous condition for the operator.

This property provides access to the internal asynchronous condition for the operator, which controls the scheduling of the operator’s compute method.

Returns#

conditionholoscan.conditions.AsynchronousCondition

An instance of holoscan.conditions.AsynchronousCondition that is the internal asynchronous condition for the operator.

Notes#

This object is only accessible after the executor has called Operator.initialize() via run() or run_async(). If accessed during Application.compose(), it will return None.

compute(op_input, op_output, context)[source]

Performs computation with the provided context.

property conditions

Conditions associated with the operator.

convert_and_save(nii_path)[source]

reads the nifti image and returns a numpy image array

property description

YAML formatted string describing the operator.

enable_metadata(self: holoscan.core._core.OperatorBase, enable: bool) None

Configure whether or not the metadata feature is enabled for this operator. If it is not set, the default value will be determined by the enable_metadata setting from the Fragment that this operator belongs to.

property execution_context

The execution context for the operator.

This property provides access to the execution context of the operator, which contains information about the current execution environment including scheduling details.

Returns#

holoscan.core.ExecutionContext

The execution context object for this operator.

find_all_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) list[holoscan.core._core.FlowInfo]

Find all flow info objects in the operator’s next flows that match a given condition.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

list[holoscan.core.FlowInfo]

List of matching FlowInfo objects.

find_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) holoscan.core._core.FlowInfo

Find a flow info in the operator’s next flows based on a given predicate.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

holoscan.core.FlowInfo or None

The first matching FlowInfo object, or None if not found.

property fragment

The fragment (holoscan.core.Fragment) that the operator belongs to.

property id

The identifier of the component.

The identifier is initially set to -1, and will become a valid value when the component is initialized.

With the default executor (holoscan.gxf.GXFExecutor), the identifier is set to the GXF component ID.

Returns#

id : int

initialize()

Default implementation of initialize

property is_metadata_enabled

Boolean indicating whether the fragment this operator belongs to has metadata transmission enabled.

property metadata

The metadata dictionary (holoscan.core.MetadataDictionary) associated with the operator.

property metadata_policy

The metadata policy (holoscan.core.MetadataPolicy) associated with the operator.

The supported policies are:

  • MetadataPolicy.REJECT: Reject the new value if the key already exists

  • MetadataPolicy.UPDATE: Replace existing value with the new one if the key already exists

  • MetadataPolicy.INPLACE_UPDATE: Update the value stored within an existing MetadataObject in-place if the key already exists (in contrast to UPDATE which always replaces the existing MetadataObject with a new one).

  • MetadataPolicy.RAISE: Raise an exception if the key already exists

property name

The name of the operator.

property next_flows

Get the list of flow information for connections to downstream operators.

Returns#

list[holoscan.core.FlowInfo]

List of flow information objects describing connections to downstream operators.

property operator_type

The operator type.

holoscan.core.Operator.OperatorType enum representing the type of the operator. The two types currently implemented are native and GXF.

queue_policy(self: holoscan.core._core.OperatorBase, port_name: str, port_type: holoscan.core._core.IOSpec.IOType = <IOType.INPUT: 0>, policy: holoscan.core._core.IOSpec.QueuePolicy = <QueuePolicy.FAULT: 2>) None

Set the queue policy to be used by an input (or output) port’s receiver (or transmitter).

Parameters#

port_namestr

The name of the port.

port_typeIOSpec.IOType, optional

Enum indicating whether port_name corresponds to an input port or output port.

policyIOSpec.QueuePolicy, optional

The queue policy to set. Valid values are:

  • QueuePolicy.POP : If the queue is full, pop the oldest item, then add the new one.

  • QueuePolicy.REJECT : If the queue is full, reject (discard) the new item.

  • QueuePolicy.FAULT : If the queue is full, log a warning and reject the new item.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

receiver(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Receiver]

Get the receiver used by an input port.

Parameters#

port_namestr

The name of the input port.

Returns#

receiverholoscan.resources.Receiver

The receiver used by this input port. Will be None if the port does not exist.

resource(self: holoscan.core._core.OperatorBase, name: str) object | None

Resources associated with the operator.

Parameters#

namestr

The name of the resource to retrieve

Returns#

holoscan.core.Resource or None

The resource with the given name. If no resource with the given name is found, None is returned.

property resources

Resources associated with the operator.

service(self: object, service_type: type, id: str = '') object

Retrieve a registered fragment service through the component’s fragment.

This method delegates to the fragment’s service() method to retrieve a previously registered fragment service by its type and optional identifier. Returns None if no fragment service is found with the specified type and identifier.

Parameters#

service_typetype

The type of the fragment service to retrieve. Must be a type that inherits from Resource or FragmentService.

idstr, optional

The identifier of the fragment service. If empty, retrieves by service type only. For Resources, this would typically be the resource’s name.

Returns#

object or None

The fragment service instance of the requested type, or None if not found. If the service wraps a Resource and a Resource type is requested, the unwrapped Resource instance is returned.

Raises#

RuntimeError

If the component has no associated fragment or if the fragment’s service method cannot be accessed.

Notes#

This is a convenience method that internally calls the fragment’s service() method. For services that wrap Resources, the method will automatically unwrap and return the Resource if a Resource type is requested.

setup(spec)[source]

Default implementation of setup method.

property spec

The operator spec (holoscan.core.OperatorSpec) associated with the operator.

start()

Default implementation of start

stop()

Default implementation of stop

stop_execution(self: holoscan.core._core.OperatorBase) None

Stop the execution of the operator.

This method is used to stop the execution of the operator by setting the internal async condition to EVENT_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operator will not be scheduled for execution (the compute() method will not be called).

Note that executing this method does not trigger the operator’s stop() method. The stop() method is called only when the scheduler deactivates all operators together.

transmitter(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Transmitter]

Get the transmitter used by an output port.

Parameters#

port_namestr

The name of the output port.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

class monai.deploy.operators.PNGConverterOperator(fragment, *args, output_folder, **kwargs)[source]

Bases: Operator

This operator writes out a 3D Volumetric Image to to a file folder in a slice by slice manner.

Named input:

image: Image object or numpy ndarray

Named output:

None

File output:

Generated PNG image file(s) saved in the provided output folder.

Class to write out a 3D Volumetric Image to a file folder in a slice by slice manner.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • output_folder (str or Path) – The folder for saving the generated DICOM instance file.

class OperatorType(self: holoscan.core._core.OperatorBase.OperatorType, value: int)

Bases: pybind11_object

Enum class for operator types used by the executor.

  • NATIVE: Native operator.

  • GXF: GXF operator.

  • VIRTUAL: Virtual operator. (for internal use, not intended for use by application authors)

Members:

NATIVE

GXF

VIRTUAL

property name
__init__(fragment, *args, output_folder, **kwargs)[source]

Class to write out a 3D Volumetric Image to a file folder in a slice by slice manner.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • output_folder (str or Path) – The folder for saving the generated DICOM instance file.

add_arg(*args, **kwargs)

Overloaded function.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.Arg) -> None

Add an argument to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ArgList) -> None

Add a list of arguments to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, **kwargs) -> None

Add arguments to the component via Python kwargs.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ConditionBase) -> None

  2. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ResourceBase) -> None

Add a condition or resource to the Operator.

This can be used to add a condition or resource to an operator after it has already been constructed.

Parameters#

argholoscan.core.Condition or holoscan.core.Resource

The condition or resource to add.

add_dynamic_flow(*args, **kwargs)

Overloaded function.

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flow: holoscan.core._core.FlowInfo) -> None

  2. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flows: list[holoscan.core._core.FlowInfo]) -> None

  3. add_dynamic_flow(self: holoscan.core._core.OperatorBase, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

Add a dynamic flow from this operator to another operator.

Parameters#

next_opholoscan.core.Operator

The downstream operator to connect to.

next_input_port_namestr, optional

The name of the input port on the downstream operator to connect to. If not specified, the first available input port will be used.

Notes#

This method has several overloads to support different ways of creating dynamic flows:

  1. add_dynamic_flow(next_op: Operator, next_input_port_name: str = ‘’) - Basic connection using default output port. This is the simplest form for connecting

    two operators when you only need to specify the destination.

  2. add_dynamic_flow(curr_output_port_name: str, next_op: Operator, next_input_port_name: str = ‘’) - Connection with explicit output port specification. Use this when the source operator has

    multiple output ports and you need to specify which one to use.

  3. add_dynamic_flow(flow: FlowInfo) - Connection using a FlowInfo object, which encapsulates all connection details including:

    • Source operator and its output port specification

    • Destination operator and its input port specification

    • Port names and associated IOSpecs

    • This is useful for complex connections or when reusing connection patterns.

  4. add_dynamic_flow(flows: List[FlowInfo]) - Batch connection using multiple FlowInfo objects. Use this to set up multiple

    connections in a single call, which is more efficient than making multiple individual connections.

The FlowInfo class provides a complete description of a flow connection between operators, including all port specifications and naming. It’s particularly useful when you need to:

  • Store and reuse connection patterns

  • Create complex routing configurations

  • Handle dynamic port specifications

  • Manage multiple connections systematically

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, curr_output_port_name: str, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

property args

The list of arguments associated with the component.

Returns#

arglist : holoscan.core.ArgList

property async_condition

The internal asynchronous condition for the operator.

This property provides access to the internal asynchronous condition for the operator, which controls the scheduling of the operator’s compute method.

Returns#

conditionholoscan.conditions.AsynchronousCondition

An instance of holoscan.conditions.AsynchronousCondition that is the internal asynchronous condition for the operator.

Notes#

This object is only accessible after the executor has called Operator.initialize() via run() or run_async(). If accessed during Application.compose(), it will return None.

compute(op_input, op_output, context)[source]

Default implementation of compute

property conditions

Conditions associated with the operator.

convert_and_save(image, path)[source]

extracts the slices in originally acquired direction (often axial) and saves them in PNG format slice by slice in the specified directory

property description

YAML formatted string describing the operator.

enable_metadata(self: holoscan.core._core.OperatorBase, enable: bool) None

Configure whether or not the metadata feature is enabled for this operator. If it is not set, the default value will be determined by the enable_metadata setting from the Fragment that this operator belongs to.

property execution_context

The execution context for the operator.

This property provides access to the execution context of the operator, which contains information about the current execution environment including scheduling details.

Returns#

holoscan.core.ExecutionContext

The execution context object for this operator.

find_all_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) list[holoscan.core._core.FlowInfo]

Find all flow info objects in the operator’s next flows that match a given condition.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

list[holoscan.core.FlowInfo]

List of matching FlowInfo objects.

find_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) holoscan.core._core.FlowInfo

Find a flow info in the operator’s next flows based on a given predicate.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

holoscan.core.FlowInfo or None

The first matching FlowInfo object, or None if not found.

property fragment

The fragment (holoscan.core.Fragment) that the operator belongs to.

property id

The identifier of the component.

The identifier is initially set to -1, and will become a valid value when the component is initialized.

With the default executor (holoscan.gxf.GXFExecutor), the identifier is set to the GXF component ID.

Returns#

id : int

initialize()

Default implementation of initialize

property is_metadata_enabled

Boolean indicating whether the fragment this operator belongs to has metadata transmission enabled.

property metadata

The metadata dictionary (holoscan.core.MetadataDictionary) associated with the operator.

property metadata_policy

The metadata policy (holoscan.core.MetadataPolicy) associated with the operator.

The supported policies are:

  • MetadataPolicy.REJECT: Reject the new value if the key already exists

  • MetadataPolicy.UPDATE: Replace existing value with the new one if the key already exists

  • MetadataPolicy.INPLACE_UPDATE: Update the value stored within an existing MetadataObject in-place if the key already exists (in contrast to UPDATE which always replaces the existing MetadataObject with a new one).

  • MetadataPolicy.RAISE: Raise an exception if the key already exists

property name

The name of the operator.

property next_flows

Get the list of flow information for connections to downstream operators.

Returns#

list[holoscan.core.FlowInfo]

List of flow information objects describing connections to downstream operators.

property operator_type

The operator type.

holoscan.core.Operator.OperatorType enum representing the type of the operator. The two types currently implemented are native and GXF.

queue_policy(self: holoscan.core._core.OperatorBase, port_name: str, port_type: holoscan.core._core.IOSpec.IOType = <IOType.INPUT: 0>, policy: holoscan.core._core.IOSpec.QueuePolicy = <QueuePolicy.FAULT: 2>) None

Set the queue policy to be used by an input (or output) port’s receiver (or transmitter).

Parameters#

port_namestr

The name of the port.

port_typeIOSpec.IOType, optional

Enum indicating whether port_name corresponds to an input port or output port.

policyIOSpec.QueuePolicy, optional

The queue policy to set. Valid values are:

  • QueuePolicy.POP : If the queue is full, pop the oldest item, then add the new one.

  • QueuePolicy.REJECT : If the queue is full, reject (discard) the new item.

  • QueuePolicy.FAULT : If the queue is full, log a warning and reject the new item.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

receiver(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Receiver]

Get the receiver used by an input port.

Parameters#

port_namestr

The name of the input port.

Returns#

receiverholoscan.resources.Receiver

The receiver used by this input port. Will be None if the port does not exist.

resource(self: holoscan.core._core.OperatorBase, name: str) object | None

Resources associated with the operator.

Parameters#

namestr

The name of the resource to retrieve

Returns#

holoscan.core.Resource or None

The resource with the given name. If no resource with the given name is found, None is returned.

property resources

Resources associated with the operator.

service(self: object, service_type: type, id: str = '') object

Retrieve a registered fragment service through the component’s fragment.

This method delegates to the fragment’s service() method to retrieve a previously registered fragment service by its type and optional identifier. Returns None if no fragment service is found with the specified type and identifier.

Parameters#

service_typetype

The type of the fragment service to retrieve. Must be a type that inherits from Resource or FragmentService.

idstr, optional

The identifier of the fragment service. If empty, retrieves by service type only. For Resources, this would typically be the resource’s name.

Returns#

object or None

The fragment service instance of the requested type, or None if not found. If the service wraps a Resource and a Resource type is requested, the unwrapped Resource instance is returned.

Raises#

RuntimeError

If the component has no associated fragment or if the fragment’s service method cannot be accessed.

Notes#

This is a convenience method that internally calls the fragment’s service() method. For services that wrap Resources, the method will automatically unwrap and return the Resource if a Resource type is requested.

setup(spec)[source]

Default implementation of setup method.

property spec

The operator spec (holoscan.core.OperatorSpec) associated with the operator.

start()

Default implementation of start

stop()

Default implementation of stop

stop_execution(self: holoscan.core._core.OperatorBase) None

Stop the execution of the operator.

This method is used to stop the execution of the operator by setting the internal async condition to EVENT_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operator will not be scheduled for execution (the compute() method will not be called).

Note that executing this method does not trigger the operator’s stop() method. The stop() method is called only when the scheduler deactivates all operators together.

transmitter(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Transmitter]

Get the transmitter used by an output port.

Parameters#

port_namestr

The name of the output port.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

class monai.deploy.operators.PublisherOperator(*args, input_folder, output_folder, **kwargs)[source]

Bases: Operator

This Operator publishes the input and segment mask images for the 3rd party Render Server.

It takes as input the folder path to the input and mask images, in nii, nii.gz, or mhd, generates the render config file and the meta data file, then save all in the publish folder of the app.

Class to write DICOM Encapsulated PDF Instance with PDF bytes in memory or in a file.

Parameters:
  • input_folder (str or Path) – The folder to read the input and segment mask files.

  • output_folder (str or Path) – The folder to save the published files.

class OperatorType(self: holoscan.core._core.OperatorBase.OperatorType, value: int)

Bases: pybind11_object

Enum class for operator types used by the executor.

  • NATIVE: Native operator.

  • GXF: GXF operator.

  • VIRTUAL: Virtual operator. (for internal use, not intended for use by application authors)

Members:

NATIVE

GXF

VIRTUAL

property name
__init__(*args, input_folder, output_folder, **kwargs)[source]

Class to write DICOM Encapsulated PDF Instance with PDF bytes in memory or in a file.

Parameters:
  • input_folder (str or Path) – The folder to read the input and segment mask files.

  • output_folder (str or Path) – The folder to save the published files.

add_arg(*args, **kwargs)

Overloaded function.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.Arg) -> None

Add an argument to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ArgList) -> None

Add a list of arguments to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, **kwargs) -> None

Add arguments to the component via Python kwargs.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ConditionBase) -> None

  2. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ResourceBase) -> None

Add a condition or resource to the Operator.

This can be used to add a condition or resource to an operator after it has already been constructed.

Parameters#

argholoscan.core.Condition or holoscan.core.Resource

The condition or resource to add.

add_dynamic_flow(*args, **kwargs)

Overloaded function.

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flow: holoscan.core._core.FlowInfo) -> None

  2. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flows: list[holoscan.core._core.FlowInfo]) -> None

  3. add_dynamic_flow(self: holoscan.core._core.OperatorBase, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

Add a dynamic flow from this operator to another operator.

Parameters#

next_opholoscan.core.Operator

The downstream operator to connect to.

next_input_port_namestr, optional

The name of the input port on the downstream operator to connect to. If not specified, the first available input port will be used.

Notes#

This method has several overloads to support different ways of creating dynamic flows:

  1. add_dynamic_flow(next_op: Operator, next_input_port_name: str = ‘’) - Basic connection using default output port. This is the simplest form for connecting

    two operators when you only need to specify the destination.

  2. add_dynamic_flow(curr_output_port_name: str, next_op: Operator, next_input_port_name: str = ‘’) - Connection with explicit output port specification. Use this when the source operator has

    multiple output ports and you need to specify which one to use.

  3. add_dynamic_flow(flow: FlowInfo) - Connection using a FlowInfo object, which encapsulates all connection details including:

    • Source operator and its output port specification

    • Destination operator and its input port specification

    • Port names and associated IOSpecs

    • This is useful for complex connections or when reusing connection patterns.

  4. add_dynamic_flow(flows: List[FlowInfo]) - Batch connection using multiple FlowInfo objects. Use this to set up multiple

    connections in a single call, which is more efficient than making multiple individual connections.

The FlowInfo class provides a complete description of a flow connection between operators, including all port specifications and naming. It’s particularly useful when you need to:

  • Store and reuse connection patterns

  • Create complex routing configurations

  • Handle dynamic port specifications

  • Manage multiple connections systematically

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, curr_output_port_name: str, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

property args

The list of arguments associated with the component.

Returns#

arglist : holoscan.core.ArgList

property async_condition

The internal asynchronous condition for the operator.

This property provides access to the internal asynchronous condition for the operator, which controls the scheduling of the operator’s compute method.

Returns#

conditionholoscan.conditions.AsynchronousCondition

An instance of holoscan.conditions.AsynchronousCondition that is the internal asynchronous condition for the operator.

Notes#

This object is only accessible after the executor has called Operator.initialize() via run() or run_async(). If accessed during Application.compose(), it will return None.

compute(op_input, op_output, context)[source]

Default implementation of compute

property conditions

Conditions associated with the operator.

property description

YAML formatted string describing the operator.

enable_metadata(self: holoscan.core._core.OperatorBase, enable: bool) None

Configure whether or not the metadata feature is enabled for this operator. If it is not set, the default value will be determined by the enable_metadata setting from the Fragment that this operator belongs to.

property execution_context

The execution context for the operator.

This property provides access to the execution context of the operator, which contains information about the current execution environment including scheduling details.

Returns#

holoscan.core.ExecutionContext

The execution context object for this operator.

find_all_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) list[holoscan.core._core.FlowInfo]

Find all flow info objects in the operator’s next flows that match a given condition.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

list[holoscan.core.FlowInfo]

List of matching FlowInfo objects.

find_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) holoscan.core._core.FlowInfo

Find a flow info in the operator’s next flows based on a given predicate.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

holoscan.core.FlowInfo or None

The first matching FlowInfo object, or None if not found.

property fragment

The fragment (holoscan.core.Fragment) that the operator belongs to.

property id

The identifier of the component.

The identifier is initially set to -1, and will become a valid value when the component is initialized.

With the default executor (holoscan.gxf.GXFExecutor), the identifier is set to the GXF component ID.

Returns#

id : int

initialize()

Default implementation of initialize

property is_metadata_enabled

Boolean indicating whether the fragment this operator belongs to has metadata transmission enabled.

property metadata

The metadata dictionary (holoscan.core.MetadataDictionary) associated with the operator.

property metadata_policy

The metadata policy (holoscan.core.MetadataPolicy) associated with the operator.

The supported policies are:

  • MetadataPolicy.REJECT: Reject the new value if the key already exists

  • MetadataPolicy.UPDATE: Replace existing value with the new one if the key already exists

  • MetadataPolicy.INPLACE_UPDATE: Update the value stored within an existing MetadataObject in-place if the key already exists (in contrast to UPDATE which always replaces the existing MetadataObject with a new one).

  • MetadataPolicy.RAISE: Raise an exception if the key already exists

property name

The name of the operator.

property next_flows

Get the list of flow information for connections to downstream operators.

Returns#

list[holoscan.core.FlowInfo]

List of flow information objects describing connections to downstream operators.

property operator_type

The operator type.

holoscan.core.Operator.OperatorType enum representing the type of the operator. The two types currently implemented are native and GXF.

queue_policy(self: holoscan.core._core.OperatorBase, port_name: str, port_type: holoscan.core._core.IOSpec.IOType = <IOType.INPUT: 0>, policy: holoscan.core._core.IOSpec.QueuePolicy = <QueuePolicy.FAULT: 2>) None

Set the queue policy to be used by an input (or output) port’s receiver (or transmitter).

Parameters#

port_namestr

The name of the port.

port_typeIOSpec.IOType, optional

Enum indicating whether port_name corresponds to an input port or output port.

policyIOSpec.QueuePolicy, optional

The queue policy to set. Valid values are:

  • QueuePolicy.POP : If the queue is full, pop the oldest item, then add the new one.

  • QueuePolicy.REJECT : If the queue is full, reject (discard) the new item.

  • QueuePolicy.FAULT : If the queue is full, log a warning and reject the new item.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

receiver(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Receiver]

Get the receiver used by an input port.

Parameters#

port_namestr

The name of the input port.

Returns#

receiverholoscan.resources.Receiver

The receiver used by this input port. Will be None if the port does not exist.

resource(self: holoscan.core._core.OperatorBase, name: str) object | None

Resources associated with the operator.

Parameters#

namestr

The name of the resource to retrieve

Returns#

holoscan.core.Resource or None

The resource with the given name. If no resource with the given name is found, None is returned.

property resources

Resources associated with the operator.

service(self: object, service_type: type, id: str = '') object

Retrieve a registered fragment service through the component’s fragment.

This method delegates to the fragment’s service() method to retrieve a previously registered fragment service by its type and optional identifier. Returns None if no fragment service is found with the specified type and identifier.

Parameters#

service_typetype

The type of the fragment service to retrieve. Must be a type that inherits from Resource or FragmentService.

idstr, optional

The identifier of the fragment service. If empty, retrieves by service type only. For Resources, this would typically be the resource’s name.

Returns#

object or None

The fragment service instance of the requested type, or None if not found. If the service wraps a Resource and a Resource type is requested, the unwrapped Resource instance is returned.

Raises#

RuntimeError

If the component has no associated fragment or if the fragment’s service method cannot be accessed.

Notes#

This is a convenience method that internally calls the fragment’s service() method. For services that wrap Resources, the method will automatically unwrap and return the Resource if a Resource type is requested.

setup(spec)

Default implementation of setup method.

property spec

The operator spec (holoscan.core.OperatorSpec) associated with the operator.

start()

Default implementation of start

stop()

Default implementation of stop

stop_execution(self: holoscan.core._core.OperatorBase) None

Stop the execution of the operator.

This method is used to stop the execution of the operator by setting the internal async condition to EVENT_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operator will not be scheduled for execution (the compute() method will not be called).

Note that executing this method does not trigger the operator’s stop() method. The stop() method is called only when the scheduler deactivates all operators together.

transmitter(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Transmitter]

Get the transmitter used by an output port.

Parameters#

port_namestr

The name of the output port.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

class monai.deploy.operators.STLConversionOperator(fragment, *args, output_file, class_id=None, is_smooth=True, keep_largest_connected_component=True, **kwargs)[source]

Bases: Operator

Converts volumetric image to surface mesh in STL format.

If a file path is provided, the STL binary will be saved in the said output folder. This operator also save the STL file as bytes in memory, identified by the named output. Being optional, this output does not require any downstream receiver.

Named inputs:

image: Image object for which to generate surface mesh. output_file: Optional, the path of the file to save the mesh in STL format.

If provided, this will overrider the output file path set on the object.

Named output:

stl_bytes: Bytes of the surface mesh STL file. Optional, not requiring a downstram receiver.

Creates an object to generate a surface mesh and saves it as an STL file if the path is provided.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • output_file ([Path,str], optional) – output STL file path. None for no file output.

  • class_id (array, optional) – Class label ids. Defaults to None.

  • is_smooth (bool, optional) – smoothing or not. Defaults to True.

  • keep_largest_connected_component (bool, optional) – Defaults to True.

class OperatorType(self: holoscan.core._core.OperatorBase.OperatorType, value: int)

Bases: pybind11_object

Enum class for operator types used by the executor.

  • NATIVE: Native operator.

  • GXF: GXF operator.

  • VIRTUAL: Virtual operator. (for internal use, not intended for use by application authors)

Members:

NATIVE

GXF

VIRTUAL

property name
__init__(fragment, *args, output_file, class_id=None, is_smooth=True, keep_largest_connected_component=True, **kwargs)[source]

Creates an object to generate a surface mesh and saves it as an STL file if the path is provided.

Parameters:
  • fragment (Fragment) – An instance of the Application class which is derived from Fragment.

  • output_file ([Path,str], optional) – output STL file path. None for no file output.

  • class_id (array, optional) – Class label ids. Defaults to None.

  • is_smooth (bool, optional) – smoothing or not. Defaults to True.

  • keep_largest_connected_component (bool, optional) – Defaults to True.

add_arg(*args, **kwargs)

Overloaded function.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.Arg) -> None

Add an argument to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ArgList) -> None

Add a list of arguments to the component.

  1. add_arg(self: holoscan.core._core.OperatorBase, **kwargs) -> None

Add arguments to the component via Python kwargs.

  1. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ConditionBase) -> None

  2. add_arg(self: holoscan.core._core.OperatorBase, arg: holoscan.core._core.ResourceBase) -> None

Add a condition or resource to the Operator.

This can be used to add a condition or resource to an operator after it has already been constructed.

Parameters#

argholoscan.core.Condition or holoscan.core.Resource

The condition or resource to add.

add_dynamic_flow(*args, **kwargs)

Overloaded function.

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flow: holoscan.core._core.FlowInfo) -> None

  2. add_dynamic_flow(self: holoscan.core._core.OperatorBase, flows: list[holoscan.core._core.FlowInfo]) -> None

  3. add_dynamic_flow(self: holoscan.core._core.OperatorBase, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

Add a dynamic flow from this operator to another operator.

Parameters#

next_opholoscan.core.Operator

The downstream operator to connect to.

next_input_port_namestr, optional

The name of the input port on the downstream operator to connect to. If not specified, the first available input port will be used.

Notes#

This method has several overloads to support different ways of creating dynamic flows:

  1. add_dynamic_flow(next_op: Operator, next_input_port_name: str = ‘’) - Basic connection using default output port. This is the simplest form for connecting

    two operators when you only need to specify the destination.

  2. add_dynamic_flow(curr_output_port_name: str, next_op: Operator, next_input_port_name: str = ‘’) - Connection with explicit output port specification. Use this when the source operator has

    multiple output ports and you need to specify which one to use.

  3. add_dynamic_flow(flow: FlowInfo) - Connection using a FlowInfo object, which encapsulates all connection details including:

    • Source operator and its output port specification

    • Destination operator and its input port specification

    • Port names and associated IOSpecs

    • This is useful for complex connections or when reusing connection patterns.

  4. add_dynamic_flow(flows: List[FlowInfo]) - Batch connection using multiple FlowInfo objects. Use this to set up multiple

    connections in a single call, which is more efficient than making multiple individual connections.

The FlowInfo class provides a complete description of a flow connection between operators, including all port specifications and naming. It’s particularly useful when you need to:

  • Store and reuse connection patterns

  • Create complex routing configurations

  • Handle dynamic port specifications

  • Manage multiple connections systematically

  1. add_dynamic_flow(self: holoscan.core._core.OperatorBase, curr_output_port_name: str, next_op: holoscan.core._core.OperatorBase, next_input_port_name: str = ‘’) -> None

property args

The list of arguments associated with the component.

Returns#

arglist : holoscan.core.ArgList

property async_condition

The internal asynchronous condition for the operator.

This property provides access to the internal asynchronous condition for the operator, which controls the scheduling of the operator’s compute method.

Returns#

conditionholoscan.conditions.AsynchronousCondition

An instance of holoscan.conditions.AsynchronousCondition that is the internal asynchronous condition for the operator.

Notes#

This object is only accessible after the executor has called Operator.initialize() via run() or run_async(). If accessed during Application.compose(), it will return None.

compute(op_input, op_output, context)[source]

Gets the input (image), processes it and sets results in the output.

This function sets the mesh in STL bytes in its named output, which require no receivers. If provided, the mesh will be saved to the file in STL format.

Parameters:
  • op_input (InputContext) – An input context for the operator.

  • op_output (OutputContext) – An output context for the operator.

  • context (ExecutionContext) – An execution context for the operator.

property conditions

Conditions associated with the operator.

property description

YAML formatted string describing the operator.

enable_metadata(self: holoscan.core._core.OperatorBase, enable: bool) None

Configure whether or not the metadata feature is enabled for this operator. If it is not set, the default value will be determined by the enable_metadata setting from the Fragment that this operator belongs to.

property execution_context

The execution context for the operator.

This property provides access to the execution context of the operator, which contains information about the current execution environment including scheduling details.

Returns#

holoscan.core.ExecutionContext

The execution context object for this operator.

find_all_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) list[holoscan.core._core.FlowInfo]

Find all flow info objects in the operator’s next flows that match a given condition.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

list[holoscan.core.FlowInfo]

List of matching FlowInfo objects.

find_flow_info(self: holoscan.core._core.OperatorBase, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) holoscan.core._core.FlowInfo

Find a flow info in the operator’s next flows based on a given predicate.

Parameters#

predicatecallable

A function that takes a FlowInfo object and returns a boolean.

Returns#

holoscan.core.FlowInfo or None

The first matching FlowInfo object, or None if not found.

property fragment

The fragment (holoscan.core.Fragment) that the operator belongs to.

property id

The identifier of the component.

The identifier is initially set to -1, and will become a valid value when the component is initialized.

With the default executor (holoscan.gxf.GXFExecutor), the identifier is set to the GXF component ID.

Returns#

id : int

initialize()

Default implementation of initialize

property is_metadata_enabled

Boolean indicating whether the fragment this operator belongs to has metadata transmission enabled.

property metadata

The metadata dictionary (holoscan.core.MetadataDictionary) associated with the operator.

property metadata_policy

The metadata policy (holoscan.core.MetadataPolicy) associated with the operator.

The supported policies are:

  • MetadataPolicy.REJECT: Reject the new value if the key already exists

  • MetadataPolicy.UPDATE: Replace existing value with the new one if the key already exists

  • MetadataPolicy.INPLACE_UPDATE: Update the value stored within an existing MetadataObject in-place if the key already exists (in contrast to UPDATE which always replaces the existing MetadataObject with a new one).

  • MetadataPolicy.RAISE: Raise an exception if the key already exists

property name

The name of the operator.

property next_flows

Get the list of flow information for connections to downstream operators.

Returns#

list[holoscan.core.FlowInfo]

List of flow information objects describing connections to downstream operators.

property operator_type

The operator type.

holoscan.core.Operator.OperatorType enum representing the type of the operator. The two types currently implemented are native and GXF.

queue_policy(self: holoscan.core._core.OperatorBase, port_name: str, port_type: holoscan.core._core.IOSpec.IOType = <IOType.INPUT: 0>, policy: holoscan.core._core.IOSpec.QueuePolicy = <QueuePolicy.FAULT: 2>) None

Set the queue policy to be used by an input (or output) port’s receiver (or transmitter).

Parameters#

port_namestr

The name of the port.

port_typeIOSpec.IOType, optional

Enum indicating whether port_name corresponds to an input port or output port.

policyIOSpec.QueuePolicy, optional

The queue policy to set. Valid values are:

  • QueuePolicy.POP : If the queue is full, pop the oldest item, then add the new one.

  • QueuePolicy.REJECT : If the queue is full, reject (discard) the new item.

  • QueuePolicy.FAULT : If the queue is full, log a warning and reject the new item.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

receiver(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Receiver]

Get the receiver used by an input port.

Parameters#

port_namestr

The name of the input port.

Returns#

receiverholoscan.resources.Receiver

The receiver used by this input port. Will be None if the port does not exist.

resource(self: holoscan.core._core.OperatorBase, name: str) object | None

Resources associated with the operator.

Parameters#

namestr

The name of the resource to retrieve

Returns#

holoscan.core.Resource or None

The resource with the given name. If no resource with the given name is found, None is returned.

property resources

Resources associated with the operator.

service(self: object, service_type: type, id: str = '') object

Retrieve a registered fragment service through the component’s fragment.

This method delegates to the fragment’s service() method to retrieve a previously registered fragment service by its type and optional identifier. Returns None if no fragment service is found with the specified type and identifier.

Parameters#

service_typetype

The type of the fragment service to retrieve. Must be a type that inherits from Resource or FragmentService.

idstr, optional

The identifier of the fragment service. If empty, retrieves by service type only. For Resources, this would typically be the resource’s name.

Returns#

object or None

The fragment service instance of the requested type, or None if not found. If the service wraps a Resource and a Resource type is requested, the unwrapped Resource instance is returned.

Raises#

RuntimeError

If the component has no associated fragment or if the fragment’s service method cannot be accessed.

Notes#

This is a convenience method that internally calls the fragment’s service() method. For services that wrap Resources, the method will automatically unwrap and return the Resource if a Resource type is requested.

setup(spec)[source]

Default implementation of setup method.

property spec

The operator spec (holoscan.core.OperatorSpec) associated with the operator.

start()

Default implementation of start

stop()

Default implementation of stop

stop_execution(self: holoscan.core._core.OperatorBase) None

Stop the execution of the operator.

This method is used to stop the execution of the operator by setting the internal async condition to EVENT_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operator will not be scheduled for execution (the compute() method will not be called).

Note that executing this method does not trigger the operator’s stop() method. The stop() method is called only when the scheduler deactivates all operators together.

transmitter(self: holoscan.core._core.OperatorBase, port_name: str) Optional[holoscan::Transmitter]

Get the transmitter used by an output port.

Parameters#

port_namestr

The name of the output port.

Returns#

transmitterholoscan.resources.Transmitter or None

The transmitter used by this output port. Will be None if the port does not exist.

class monai.deploy.operators.STLConverter(*args, **kwargs)[source]

Bases: object

Converts volumetric image to surface mesh in STL

Creates an instance to generate a surface mesh in STL with an Image object.

class SpatialImage(image, dtype=<class 'numpy.float32'>)[source]

Bases: object

Object encapsulating a spatial volume image instance of Image.

Channel is not supported in this version.

Creates an instance.

Parameters:
  • image (Image) – An instance of Image.

  • dtype (Numpy type, optional) – Defaults to np.float32.

__init__(image, dtype=<class 'numpy.float32'>)[source]

Creates an instance.

Parameters:
  • image (Image) – An instance of Image.

  • dtype (Numpy type, optional) – Defaults to np.float32.

property affine

Affine of the re-oriented image data, or None

get_data()[source]

Returns the image array in ndarray

get_property(key, default=None)[source]

Gets value of the specified property

Parameters:
  • key (str) – key of the property

  • default – default value if the property does not exist.

Returns:

the value of the property, or the default value if property does not exist.

property image_array

Image data in Numpy array, or None

property itk_image

ITK image object created from the encapsulated image object, or None

property original_affine

Original affine of the image, or None

set_property(key, value)[source]

Sets an image property

Parameters:
  • key (str) – key of the property

  • value – value of the property

property shape

Shape of image array, or None

property spacing

Pixel spacing of original image, aka resolution, or None

__init__(*args, **kwargs)[source]

Creates an instance to generate a surface mesh in STL with an Image object.

convert(image, output_file=None, class_ids=None, is_smooth=True, keep_largest_connected_component=True)[source]
Parameters:
  • image (Image) – object with the image (ndarray of DHW index order) and its metadata dictionary.

  • output_file (str) – output STL file path. Default to None for not saving output file.

  • class_id (array, optional) – Class label id. Defaults to None.

  • is_smooth (bool, optional) – smoothing or not. Defaults to True.

  • keep_largest_connected_component (bool, optional) – Defaults to True.

Returns:

Bytes of the binary STL file.

monai.deploy.operators.random_with_n_digits(n)[source]

Random number generator to generate n digit int, where 1 <= n <= 32.

monai.deploy.operators.save_dcm_file(data_set, file_path, validate_readable=True)[source]

Save a DICOM data set, in pydicom Dataset, to the provided file path.

monai.deploy.operators.write_common_modules(dicom_series, copy_tags, modality_type, sop_class_uid, model_info=None, equipment_info=None)[source]

Writes DICOM object common modules with or without a reference DCIOM Series

Common modules include Study, Patient, Equipment, Series, and SOP common.

Parameters:
  • dicom_series (DicomSeries) – DicomSeries object encapsulating the original series.

  • copy_tags (bool) – If true, dicom_series must be provided for copying tags.

  • modality_type (str) – DICOM Modality Type, e.g. SR.

  • sop_class_uid (str) – Media Storage SOP Class UID, e.g. “1.2.840.10008.5.1.4.1.1.88.34” for Comprehensive 3D SR IOD.

  • model_info (MoelInfo) – Object encapsulating model creator, name, version and UID.

  • equipment_info (EquipmentInfo) – Object encapsulating attributes for DICOM Equipment Module

Return type:

Dataset

Returns:

pydicom Dataset

Raises:

ValueError – When dicom_series is not a DICOMSeries object, and new_study is not True.