monai.deploy.operators.DICOMSeriesToVolumeOperator¶
- class monai.deploy.operators.DICOMSeriesToVolumeOperator(*args, **kwargs)[source]¶
Bases:
monai.deploy.core.operator.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.
Constructor of the base operator.
It creates an instance of Data Store which holds on to all inputs and outputs relavant for this operator.
- Parameters
args – Arguments.
kwargs – Keyword arguments.
Methods
__init__
(*args, **kwargs)Constructor of the base operator.
add_input
(label, data_type, storage_type)add_output
(label, data_type, storage_type)compute
(op_input, op_output, context)Performs computation for this operator and handles I/O.
compute_affine_transform
(s_1, s_n, n, series)Computes the affine transform for this series.
convert_to_image
(study_selected_series_list)Extracts the pixel data from a DICOM Series and other attributes to create an Image object
create_metadata
(series)Collects all relevant metadata from the DICOM Series and creates a dictionary.
create_volumetric_image
(vox_data, metadata)Creates an instance of 3D image.
Ensures that the operator is valid.
generate_voxel_data
(series)Applies rescale slope and rescale intercept to the pixels.
This method gets executed after “compute()” of an operator is called.
This method gets executed before compute() of an operator is called.
prepare_series
(series)Computes the slice normal for each slice and then projects the first voxel of each slice on that slice normal.
Attributes
Gives access to the environment.
Returns the name of this operator.
Retrieves the operator info.
Gives access to the UID of the operator.
- __init__(*args, **kwargs)¶
Constructor of the base operator.
It creates an instance of Data Store which holds on to all inputs and outputs relavant for this operator.
- Parameters
args – Arguments.
kwargs – Keyword arguments.
- 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.
- 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.
- 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.
- 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 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.
- 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.
- property uid: uuid.UUID¶
Gives access to the UID of the operator.
- Return type
UUID
- Returns
UID of the operator.