VolumeOperations
Provides tools for creating, editing, and analyzing 3D volume images. Supports import/export, filtering, transformation, segmentation, and conversion between volume and mask data.
Import
import ScriptingApi as api
# Access via Application
app = api.Application()
ops = app.get_volume_operations()
Methods
Properties
get_render_properties_operations
Returns an api.VolumeRenderPropertiesOperations object.
Signature:
get_render_properties_operations() -> VolumeRenderPropertiesOperations
Returns: VolumeRenderPropertiesOperations — The api.VolumeRenderPropertiesOperations object.
get_voxel_data_type
Retrieves the voxel data (scalar) type of a specified volume.
Signature:
get_voxel_data_type(volumeName: str) -> VoxelDataType
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to retrieve the voxel data type for. |
Returns: VoxelDataType — The voxel data type of the volume as api.VoxelDataType.Unsigned8Bit, api.VoxelDataType.Signed16Bit, api.VoxelDataType.Unsigned16Bit, or api.VoxelDataType.Float32Bit.
get_volume_uint8
Retrieves the volume data as an 8-bit unsigned integer structure.
Signature:
get_volume_uint8(volumeName: str) -> VolumeUint8
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to retrieve. |
Returns: VolumeUint8 — The api.VolumeUint8 volume data as an 8-bit unsigned integer structure.
get_volume_int_16
Retrieves the volume data as a 16-bit signed integer structure.
Signature:
get_volume_int_16(volumeName: str) -> VolumeInt16
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to retrieve. |
Returns: VolumeInt16 — The api.VolumeInt16 volume data as a 16-bit signed integer structure.
get_volume_uint_16
Retrieves the volume data as a 16-bit unsigned integer structure.
Signature:
get_volume_uint_16(volumeName: str) -> VolumeUint16
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to retrieve. |
Returns: VolumeUint16 — The api.VolumeUint16 volume data as a 16-bit unsigned integer structure.
get_volume_float_32
Retrieves the volume data as a 32-bit floating-point structure.
Signature:
get_volume_float_32(volumeName: str) -> VolumeFloat32
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to retrieve. |
Returns: VolumeFloat32 — The api.VolumeFloat32 volume data as a 32-bit floating-point structure.
set_volume_uint8
Sets the volume data as an 8-bit unsigned integer structure. This method checks for dimension, spacing, and origin compatibility before setting the data. If the new data matches the existing data exactly, the update is skipped.
Signature:
set_volume_uint8(volumeName: str, volumeData: VolumeUint8) -> bool
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to set. |
volumeData | VolumeUint8 | The volume data to set. Create using api.VolumeUint8(). |
Returns: bool — True if the volume data was set successfully; False otherwise.
set_volume_int_16
Sets the volume data as a 16-bit signed integer structure. This method checks for dimension, spacing, and origin compatibility before setting the data. If the new data matches the existing data exactly, the update is skipped.
Signature:
set_volume_int_16(volumeName: str, volumeData: VolumeInt16) -> bool
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to set. |
volumeData | VolumeInt16 | The volume data to set. Create using api.VolumeInt16(). |
Returns: bool — True if the volume data was set successfully; False otherwise.
set_volume_uint_16
Sets the volume data as a 16-bit unsigned integer structure. This method checks for dimension, spacing, and origin compatibility before setting the data. If the new data matches the existing data exactly, the update is skipped.
Signature:
set_volume_uint_16(volumeName: str, volumeData: VolumeUint16) -> bool
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to set. |
volumeData | VolumeUint16 | The volume data to set. Create using api.VolumeUint16(). |
Returns: bool — True if the volume data was set successfully; False otherwise.
set_volume_float_32
Sets the volume data as a 32-bit floating-point structure. This method checks for dimension, spacing, and origin compatibility before setting the data. If the new data matches the existing data exactly, the update is skipped.
Signature:
set_volume_float_32(volumeName: str, volumeData: VolumeFloat32) -> bool
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to set. |
volumeData | VolumeFloat32 | The volume data to set. Create using api.VolumeFloat32(). |
Returns: bool — True if the volume data was set successfully; False otherwise.
get_dimensions
Retrieves the dimensions of a specified volume.
Signature:
get_dimensions(volumeName: str) -> list
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to retrieve dimensions for. |
Returns: list — The dimensions of the volume as [width, height, depth] in pixels.
get_spacing
Retrieves the spacing of a specified volume.
Signature:
get_spacing(volumeName: str) -> list
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to retrieve spacing for. |
Returns: list — The spacing of the volume as [x, y, z] in millimeters.
get_origin
Retrieves the physical origin of a specified volume.
Signature:
get_origin(volumeName: str) -> list
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to retrieve origin for. |
Returns: list — The origin of the volume as [x, y, z] in millimeters.
get_scalar_range
Retrieves the scalar value range of a specified volume.
Signature:
get_scalar_range(volumeName: str) -> list
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to retrieve scalar range for. |
Returns: list — The scalar range of the volume as [min, max].
get_bounds
Retrieves the physical bounds of a specified volume.
Signature:
get_bounds(volumeName: str) -> list
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to inspect. |
Returns: list — The bounds of the volume as [xMin, xMax, yMin, yMax, zMin, zMax] in millimeters.
get_physical_center
Retrieves the physical center of a specified volume.
Signature:
get_physical_center(volumeName: str) -> list
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to inspect. |
Returns: list — The center of the volume as [x, y, z] in millimeters.
get_memory_size_in_m_bytes
Retrieves the current memory usage of a specified volume.
Signature:
get_memory_size_in_m_bytes(volumeName: str) -> float
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to inspect. |
Returns: float — Approximate memory size in megabytes.
get_current_slice_depth
Retrieves the stored slice indices for a specified volume.
Signature:
get_current_slice_depth(volumeName: str) -> list
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to inspect. |
Returns: list — The current slice indices as [x, y, z].
set_active_frame_index
Activates a stored frame on a multi-frame volume. The requested index is clamped to the available frame range. The selected frame becomes the current image and metadata state of the volume. Throws a runtime exception if the volume has no stored frames.
Signature:
set_active_frame_index(volumeName: str, frameIndex: int) -> None
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the multi-frame volume. |
frameIndex | int | The requested frame index. |
get_active_frame_index
Retrieves the active stored frame index for a volume.
Signature:
get_active_frame_index(volumeName: str) -> int
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to inspect. |
Returns: int — The active frame index. Volumes without stored frames return 0.
get_number_of_frames
Retrieves the number of stored frames attached to a volume.
Signature:
get_number_of_frames(volumeName: str) -> int
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to inspect. |
Returns: int — The number of stored frames. Standard 3D volumes return 0.
is_meta_data_dictionary_empty
Checks whether the metadata dictionary of a volume is empty.
Signature:
is_meta_data_dictionary_empty(volumeName: str) -> bool
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to inspect. |
Returns: bool — True if the metadata dictionary is empty; otherwise, False.
get_meta_data_keys
Lists all metadata keys stored on a volume.
Signature:
get_meta_data_keys(volumeName: str) -> list
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to inspect. |
Returns: list — A list of metadata keys.
has_meta_data_key
Checks whether a metadata key exists on a volume.
Signature:
has_meta_data_key(volumeName: str, key: str) -> bool
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to inspect. |
key | str | The metadata key to look up. |
Returns: bool — True if the key exists; otherwise, False.
get_meta_data
Retrieves a metadata entry by key.
Signature:
get_meta_data(volumeName: str, key: str) -> DicomTag
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to inspect. |
key | str | The metadata key to look up. |
Returns: DicomTag — The stored metadata details as api.DicomTag. If the key is missing, empty fields are returned.
set_meta_data
Stores or replaces a metadata entry.
Signature:
set_meta_data(volumeName: str, key: str, value: DicomTag) -> None
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to update. |
key | str | The metadata key to store. |
value | DicomTag | The metadata details to store. Create using api.DicomTag(). |
set_meta_data_dictionary
Replaces the full metadata list stored on a volume.
Signature:
set_meta_data_dictionary(volumeName: str, dictionary: list) -> None
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to update. |
dictionary | list | Metadata entries to store. Create using api.MetaDataEntry(). |
get_meta_data_dictionary
Retrieves all metadata stored on a volume.
Signature:
get_meta_data_dictionary(volumeName: str) -> list
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume to inspect. |
Returns: list — A list of metadata entries as api.MetaDataEntry. Each entry includes the lookup key and the stored details.
get_gray_value_at_voxel
Retrieves the gray value(s) at a specific voxel index within a volume. This function accesses the intensity value(s) stored at the given voxel index in the specified volume. For scalar volumes, a single gray value is returned; for multi-channel volumes, multiple values may be returned.
Signature:
get_gray_value_at_voxel(volumeName: str, voxelIndex: list) -> list
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume from which to retrieve gray values. |
voxelIndex | list | The [i, j, k] index of the voxel (in pixel coordinates) to query. |
Returns: list — A list containing the gray value(s) at the specified voxel index. Returns one value for scalar volumes, or multiple values for multi-channel volumes.
get_gray_value_at_world_coordinates
Retrieves the gray value(s) at specified world coordinates within a volume. This function computes the gray value(s) at the provided world coordinates by mapping them to the corresponding voxel location in the specified volume. For scalar volumes, a single gray value is returned; for multi-channel volumes, multiple values may be returned.
Signature:
get_gray_value_at_world_coordinates(volumeName: str, worldCoordinates: list) -> list
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeName | str | The name of the volume from which to retrieve gray values. |
worldCoordinates | list | The [x, y, z] position in world (physical) coordinates to query. |
Returns: list — A list containing the gray value(s) at the specified world coordinates. Returns one value for scalar volumes, or multiple values for multi-channel volumes.
curvature_anisotropic_diffusion_filter
Applies curvature anisotropic diffusion filtering to the specified volumes. Smooths images while preserving edges using anisotropic diffusion based on image curvature. Useful for edge-preserving denoising of medical images.
Signature:
curvature_anisotropic_diffusion_filter(volumeNames: list, iterations: int = 1, timeStep: float = 0.1, conductance: float = 3.0) -> None
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeNames | list | Names of the volumes to process. |
iterations | int | Number of diffusion iterations to perform. |
timeStep | float | Time step for the diffusion equation (controls smoothing rate). |
conductance | float | Conductance parameter controlling edge sensitivity. |
discrete_gaussian_filter
Applies discrete Gaussian smoothing to the specified volumes. Performs Gaussian smoothing using a discrete Gaussian kernel. Sigma values can be specified in pixel or physical coordinates.
Signature:
discrete_gaussian_filter(volumeNames: list, sigma: list = [1.0, 1.0, 1.0], useImageSpacing: bool = False) -> None
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeNames | list | Names of the volumes to process. |
sigma | list | Standard deviation of the Gaussian kernel in X, Y, Z directions. |
useImageSpacing | bool | If true, sigma is in physical coordinates (millimeters); if False, sigma is in pixel units. |
gradient_anisotropic_diffusion_filter
Applies gradient anisotropic diffusion filtering to the specified volumes. Smooths images while preserving edges using anisotropic diffusion based on image gradients. Useful for edge-preserving denoising.
Signature:
gradient_anisotropic_diffusion_filter(volumeNames: list, iterations: int = 1, timeStep: float = 0.1, conductance: float = 3.0) -> None
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeNames | list | Names of the volumes to process. |
iterations | int | Number of diffusion iterations to perform. |
timeStep | float | Time step for the diffusion equation (controls smoothing rate). |
conductance | float | Conductance parameter controlling edge sensitivity. |
patch_based_denoising_filter
Applies patch-based denoising filtering to the specified volumes. Denoises images using non-local means based on patch similarity. Effective for removing noise while preserving fine details.
Signature:
patch_based_denoising_filter(volumeNames: list, patchRadius: float = 2.0, noiseModel: str = "Gaussian", iterations: int = 1, fidelityWeight: float = 0.1) -> None
Parameters:
| Parameter | Type | Description |
|---|---|---|
volumeNames | list | Names of the volumes to process. |
patchRadius | float | Radius of patches used for similarity comparison. |
noiseModel | str | Type of noise model (e.g., "Gaussian", "Rician", "Poisson"). |
iterations | int | Number of denoising iterations. |
fidelityWeight | float | Weight controlling fidelity to input data vs. denoising strength. |