monai.deploy.operators.STLConversionOperator

class monai.deploy.operators.STLConversionOperator(output_file=None, class_id=None, is_smooth=True, keep_largest_connected_component=True, *args, **kwargs)[source]

Bases: monai.deploy.core.operator.Operator

Converts volumetric image to surface mesh in STL format, file output only.

Only when used as a non-leaf operator is the output of STL binary stored in memory idenfied by the output label. If a file path is provided, the STL binary will be saved in the the application’s output folder of the current run.

Creates an object to generate a surface mesh and saves it as an STL file if the path is provided.

Parameters
  • output_file (str, optional) – output STL file relative path. Default to 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.

Methods

__init__([output_file, class_id, is_smooth, …])

Creates an object to generate a surface mesh and saves it as an STL file if the path is provided.

add_input(label, data_type, storage_type)

add_output(label, data_type, storage_type)

compute(op_input, op_output, context)

Gets the input (image), processes it and sets results in the output.

ensure_valid()

Ensures that the operator is valid.

post_compute()

This method gets executed after “compute()” of an operator is called.

pre_compute()

This method gets executed before compute() of an operator is called.

Attributes

env

Gives access to the environment.

name

Returns the name of this operator.

op_info

Retrieves the operator info.

uid

Gives access to the UID of the operator.

__init__(output_file=None, class_id=None, is_smooth=True, keep_largest_connected_component=True, *args, **kwargs)[source]

Creates an object to generate a surface mesh and saves it as an STL file if the path is provided.

Parameters
  • output_file (str, optional) – output STL file relative path. Default to 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.

compute(op_input, op_output, context)[source]

Gets the input (image), processes it and sets results in the output.

When used in a leaf operator, this function cannot set its output as in-memory object due to current limitation. If a file path is provided, the STL binary will be saved in the the application’s output folder of the current run.

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.

ensure_valid()

Ensures that the operator is valid.

This method needs to be executed by add_operator() and add_flow() methods in the compose() method of the application. This sets default values for the operator in the graph if necessary. (e.g., set default value for the operator’s input port, set default value for the operator’s output port, etc.)

property env: monai.deploy.core.operator.OperatorEnv

Gives access to the environment.

This sets a default value for the operator’s environment if not set.

Return type

OperatorEnv

Returns

An instance of OperatorEnv.

property name: str

Returns the name of this operator.

Return type

str

property op_info: monai.deploy.core.operator_info.OperatorInfo

Retrieves the operator info.

Args:

Return type

OperatorInfo

Returns

An instance of OperatorInfo.

post_compute()

This method gets executed after “compute()” of an operator is called.

This is a post-execution step before the operator is done doing its main action. This needs to be overridden by a base class for any meaningful action.

pre_compute()

This method gets executed before compute() of an operator is called.

This is a preperatory step before the operator executes its main job. This needs to be overridden by a base class for any meaningful action.

property uid: uuid.UUID

Gives access to the UID of the operator.

Return type

UUID

Returns

UID of the operator.