Skip to main content

MeasureOperations

Operations

Provides tools for statistical analysis and measurement operations on volume, mask, surface, and mesh objects. Supports histogram generation, volume/mask/surface/mesh statistics, similarity metrics, mask comparison, mesh quality analysis, primitive fitting, and measurement between primitives.

Import

import ScriptingApi as api

# Access via Application
app = api.Application()
ops = app.get_measure_operations()

Methods

Creation

generate_histogram

Generates a histogram for the specified volume object.

Signature:

generate_histogram(volumeName: str, params: HistogramParams) -> HistogramResult

Parameters:

ParameterTypeDescription
volumeNameanyName of the volume object to analyze.
paramsanyHistogram generation parameters. Use api.HistogramParams().

Returns: HistogramResult — Histogram result containing bin values and frequencies.


generate_histogram_with_mask

Generates a histogram for a volume filtered by a mask.

Signature:

generate_histogram_with_mask(volumeName: str, maskName: str, params: HistogramParams) -> HistogramResult

Parameters:

ParameterTypeDescription
volumeNameanyName of the volume object to analyze.
maskNameanyName of the mask object to filter the volume.
paramsanyHistogram generation parameters. Use api.HistogramParams().

Returns: HistogramResult — Histogram result containing bin values and frequencies.


File System

export_histogram_to_disk

Exports histogram data to a formatted text file.

Signature:

export_histogram_to_disk(histogramResult: HistogramResult, fileName: str) -> bool

Parameters:

ParameterTypeDescription
histogramResultanyThe histogram result to export.
fileNameanyFull path to the output text file (.txt extension recommended).

Returns: bool — True if export was successful, False otherwise.


export_volume_statistics_to_disk

Exports volume statistics to a formatted text file.

Signature:

export_volume_statistics_to_disk(statisticsResult: VolumeStatisticsResult, fileName: str) -> bool

Parameters:

ParameterTypeDescription
statisticsResultanyThe volume statistics result to export.
fileNameanyFull path to the output text file (.txt extension recommended).

Returns: bool — True if export was successful.


export_volume_similarity_to_disk

Exports volume similarity statistics to a formatted text file.

Signature:

export_volume_similarity_to_disk(similarityResult: VolumeSimilarityResult, fileName: str) -> bool

Parameters:

ParameterTypeDescription
similarityResultanyThe volume similarity result to export.
fileNameanyFull path to the output text file (.txt extension recommended).

Returns: bool — True if export was successful, False otherwise.


export_mask_statistics_to_disk

Exports mask statistics to a formatted text file.

Signature:

export_mask_statistics_to_disk(statisticsResult: MaskStatisticsResult, fileName: str) -> bool

Parameters:

ParameterTypeDescription
statisticsResultanyThe mask statistics result to export.
fileNameanyFull path to the output text file (.txt extension recommended).

Returns: bool — True if export was successful, False otherwise.


export_mask_comparison_to_disk

Exports mask comparison statistics to a formatted text file.

Signature:

export_mask_comparison_to_disk(comparisonResult: MaskComparisonResult, fileName: str) -> bool

Parameters:

ParameterTypeDescription
comparisonResultanyThe mask comparison result to export.
fileNameanyFull path to the output text file (.txt extension recommended).

Returns: bool — True if export was successful.


export_surface_mesh_statistics_to_disk

Exports surface mesh statistics to a formatted text file.

Signature:

export_surface_mesh_statistics_to_disk(statisticsResult: SurfaceMeshStatisticsResult, fileName: str) -> bool

Parameters:

ParameterTypeDescription
statisticsResultanyThe surface mesh statistics result to export.
fileNameanyFull path to the output text file (.txt extension recommended).

Returns: bool — True if export was successful.


export_volume_mesh_statistics_to_disk

Exports volume mesh statistics to a formatted text file.

Signature:

export_volume_mesh_statistics_to_disk(statisticsResult: VolumeMeshStatisticsResult, fileName: str) -> bool

Parameters:

ParameterTypeDescription
statisticsResultanyThe volume mesh statistics result to export.
fileNameanyFull path to the output text file (.txt extension recommended).

Returns: bool — True if export was successful.


export_surface_mesh_quality_to_disk

Exports surface mesh quality analysis to a formatted text file.

Signature:

export_surface_mesh_quality_to_disk(qualityResult: SurfaceMeshQualityResult, fileName: str) -> bool

Parameters:

ParameterTypeDescription
qualityResultanyThe surface mesh quality result to export.
fileNameanyFull path to the output text file (.txt extension recommended).

Returns: bool — True if export was successful.


export_volume_mesh_quality_to_disk

Exports volume mesh quality analysis to a formatted text file.

Signature:

export_volume_mesh_quality_to_disk(qualityResult: VolumeMeshQualityResult, fileName: str) -> bool

Parameters:

ParameterTypeDescription
qualityResultanyThe volume mesh quality result to export.
fileNameanyFull path to the output text file (.txt extension recommended).

Returns: bool — True if export was successful.


Analysis

compute_volume_statistics

Computes grayscale statistics for the specified volume object.

Signature:

compute_volume_statistics(volumeName: str, params: VolumeStatisticsParams) -> VolumeStatisticsResult

Parameters:

ParameterTypeDescription
volumeNameanyName of the volume object to analyze.
paramsanyVolume statistics parameters. Use api.VolumeStatisticsParams().

Returns: VolumeStatisticsResult — Volume statistics result containing all computed metrics.


compute_volume_statistics_with_mask

Computes grayscale statistics for a volume filtered by a mask.

Signature:

compute_volume_statistics_with_mask(volumeName: str, maskName: str, params: VolumeStatisticsParams) -> VolumeStatisticsResult

Parameters:

ParameterTypeDescription
volumeNameanyName of the volume object to analyze.
maskNameanyName of the mask object to filter the volume.
paramsanyVolume statistics parameters. Use api.VolumeStatisticsParams().

Returns: VolumeStatisticsResult — Volume statistics result containing all computed metrics.


compute_volume_statistics_all_visible_masks

Computes grayscale statistics for a volume using all visible masks.

Signature:

compute_volume_statistics_all_visible_masks(volumeName: str, params: VolumeStatisticsParams) -> list

Parameters:

ParameterTypeDescription
volumeNameanyName of the volume object to analyze.
paramsanyVolume statistics parameters. Use api.VolumeStatisticsParams().

Returns: list — List of volume statistics results, one for each visible mask.


compute_volume_similarity

Computes similarity statistics between two volume objects.

Signature:

compute_volume_similarity(sourceVolumeName: str, targetVolumeName: str) -> VolumeSimilarityResult

Parameters:

ParameterTypeDescription
sourceVolumeNameanyName of the source volume object.
targetVolumeNameanyName of the target volume object.

Returns: VolumeSimilarityResult — Volume similarity result containing all similarity metrics.


compute_whole_mask_statistics

Computes shape statistics for the entire mask (whole mask statistics).

Signature:

compute_whole_mask_statistics(maskName: str, volumeName: str = "", requestedStats: list = []) -> MaskStatisticsResult

Parameters:

ParameterTypeDescription
maskNameanyName of the mask object to analyze.
volumeNameanyOptional volume name for intensity-based statistics (empty string if not needed).
requestedStatsanyOptional list of label statistics to compute. When empty, all statistics are computed. Python example: [api.LabelStatisticType.VoxelCount, api.LabelStatisticType.Volume, api.LabelStatisticType.MeanIntensity]

Returns: MaskStatisticsResult — Mask statistics result containing shape and intensity metrics.


compute_per_region_mask_statistics

Computes statistics for each connected region in a mask (per-region mask statistics).

Signature:

compute_per_region_mask_statistics(maskName: str, volumeName: str = "", requestedStats: list = []) -> MaskStatisticsResult

Parameters:

ParameterTypeDescription
maskNameanyName of the mask object to analyze.
volumeNameanyOptional volume name for intensity-based statistics (empty string if not needed).
requestedStatsanyOptional list of label statistics to compute. When empty, all statistics are computed. Python example: [api.LabelStatisticType.VoxelCount, api.LabelStatisticType.Volume, api.LabelStatisticType.Compactness]

Returns: MaskStatisticsResult — Mask statistics result containing per-region shape and intensity metrics.


compute_per_label_mask_statistics

Computes statistics for each label in a multi-label mask (per-label mask statistics).

Signature:

compute_per_label_mask_statistics(maskName: str, volumeName: str = "", requestedStats: list = []) -> MaskStatisticsResult

Parameters:

ParameterTypeDescription
maskNameanyName of the multi-label mask object to analyze.
volumeNameanyOptional volume name for intensity-based statistics (empty string if not needed).
requestedStatsanyOptional list of label statistics to compute. When empty, all statistics are computed. Python example: [api.LabelStatisticType.VoxelCount, api.LabelStatisticType.Volume, api.LabelStatisticType.Elongation]

Returns: MaskStatisticsResult — Mask statistics result containing per-label shape and intensity metrics.


compute_per_region_mask_3d_preview_statistics

Computes mesh statistics for each connected region of a mask's 3D preview.

Signature:

compute_per_region_mask_3d_preview_statistics(maskName: str, requestedStats: list = []) -> SurfaceMeshStatisticsResult

Parameters:

ParameterTypeDescription
maskNameanyName of the mask object whose 3D preview will be analyzed.
requestedStatsanyOptional list of mesh statistics to compute. When empty, all statistics are computed. Python example: [api.SurfaceMeshStatisticType.NumVertices, api.SurfaceMeshStatisticType.SurfaceArea, api.SurfaceMeshStatisticType.Volume]

Returns: SurfaceMeshStatisticsResult — Surface mesh statistics result containing per-region mesh metrics.


compute_per_label_mask_3d_preview_statistics

Computes mesh statistics for each label in a multi-label mask's 3D preview.

Signature:

compute_per_label_mask_3d_preview_statistics(maskName: str, requestedStats: list = []) -> SurfaceMeshStatisticsResult

Parameters:

ParameterTypeDescription
maskNameanyName of the multi-label mask object whose 3D preview will be analyzed.
requestedStatsanyOptional list of mesh statistics to compute. When empty, all statistics are computed. Python example: [api.SurfaceMeshStatisticType.NumVertices, api.SurfaceMeshStatisticType.SurfaceArea]

Returns: SurfaceMeshStatisticsResult — Surface mesh statistics result containing per-label mesh metrics.


compute_whole_surface_mesh_statistics

Computes statistics for a surface mesh object (whole surface mesh statistics).

Signature:

compute_whole_surface_mesh_statistics(surfaceName: str, requestedStats: list = []) -> SurfaceMeshStatisticsResult

Parameters:

ParameterTypeDescription
surfaceNameanyName of the surface object to analyze.
requestedStatsanyOptional list of mesh statistics to compute. When empty, all statistics are computed. Python example: [api.SurfaceMeshStatisticType.NumTriangles, api.SurfaceMeshStatisticType.SurfaceArea, api.SurfaceMeshStatisticType.Volume]

Returns: SurfaceMeshStatisticsResult — Surface mesh statistics result containing geometry and topology metrics.


compute_all_visible_surface_mesh_statistics

Computes statistics for all visible surface mesh objects.

Signature:

compute_all_visible_surface_mesh_statistics(requestedStats: list = []) -> list

Parameters:

ParameterTypeDescription
requestedStatsanyOptional list of mesh statistics to compute. When empty, all statistics are computed. Python example: [api.SurfaceMeshStatisticType.NumVertices, api.SurfaceMeshStatisticType.SurfaceArea]

Returns: list — List of surface mesh statistics results, one for each visible surface.


compute_per_region_surface_mesh_statistics

Computes statistics for each connected region of a surface mesh.

Signature:

compute_per_region_surface_mesh_statistics(surfaceName: str, requestedStats: list = []) -> SurfaceMeshStatisticsResult

Parameters:

ParameterTypeDescription
surfaceNameanyName of the surface object to analyze.
requestedStatsanyOptional list of mesh statistics to compute. When empty, all statistics are computed. Python example: [api.SurfaceMeshStatisticType.SurfaceArea, api.SurfaceMeshStatisticType.Sphericity]

Returns: SurfaceMeshStatisticsResult — Surface mesh statistics result containing per-region metrics.


compute_volume_mesh_statistics

Computes statistics for a volume mesh object.

Signature:

compute_volume_mesh_statistics(volumeMeshName: str, requestedStats: list = []) -> VolumeMeshStatisticsResult

Parameters:

ParameterTypeDescription
volumeMeshNameanyName of the volume mesh object to analyze.
requestedStatsanyOptional list of mesh statistics to compute. When empty, all statistics are computed. Python example: [api.VolumeMeshStatisticType.NumVertices, api.VolumeMeshStatisticType.TotalVolume, api.VolumeMeshStatisticType.NumTetrahedra]

Returns: VolumeMeshStatisticsResult — Volume mesh statistics result containing geometry metrics.


compute_all_visible_volume_mesh_statistics

Computes statistics for all visible volume mesh objects.

Signature:

compute_all_visible_volume_mesh_statistics(requestedStats: list = []) -> list

Parameters:

ParameterTypeDescription
requestedStatsanyOptional list of mesh statistics to compute. When empty, all statistics are computed. Python example: [api.VolumeMeshStatisticType.TotalVolume, api.VolumeMeshStatisticType.NumTetrahedra]

Returns: list — List of volume mesh statistics results, one for each visible volume mesh.


analyze_surface_mesh_quality

Analyzes mesh quality for a surface object using the specified quality metric.

Signature:

analyze_surface_mesh_quality(surfaceName: str, metricType: SurfaceMeshQualityMetric) -> SurfaceMeshQualityResult

Parameters:

ParameterTypeDescription
surfaceNameanyName of the surface object to analyze.
metricTypeanyQuality metric type. Use api.SurfaceMeshQualityMetric.AspectRatio

Returns: SurfaceMeshQualityResult — Surface mesh quality result containing quality statistics.


analyze_mask_3d_preview_mesh_quality

Analyzes mesh quality for a mask's 3D preview using the specified quality metric.

Signature:

analyze_mask_3d_preview_mesh_quality(maskName: str, metricType: SurfaceMeshQualityMetric) -> SurfaceMeshQualityResult

Parameters:

ParameterTypeDescription
maskNameanyName of the mask object whose 3D preview will be analyzed.
metricTypeanyQuality metric type. Use api.SurfaceMeshQualityMetric.AspectRatio

Returns: SurfaceMeshQualityResult — Surface mesh quality result containing quality statistics.


analyze_volume_mesh_quality

Analyzes mesh quality for a volume mesh object using the specified quality metric.

Signature:

analyze_volume_mesh_quality(volumeMeshName: str, metricType: VolumeMeshQualityMetric) -> VolumeMeshQualityResult

Parameters:

ParameterTypeDescription
volumeMeshNameanyName of the volume mesh object to analyze.
metricTypeanyQuality metric type. Use api.VolumeMeshQualityMetric.TetAspectRatio

Returns: VolumeMeshQualityResult — Volume mesh quality result containing quality statistics.


measure_between_primitives

Measures the distance between two primitive objects.

Signature:

measure_between_primitives(primitive1Name: str, primitive2Name: str, createMeasurement: bool = True) -> PrimitiveMeasurementResult

Parameters:

ParameterTypeDescription
primitive1NameanyName of the first primitive object.
primitive2NameanyName of the second primitive object.
createMeasurementanyIf true, creates a distance measurement object in the project.

Returns: PrimitiveMeasurementResult — Primitive measurement result containing distance and closest points.


General

compare_masks

Computes overlap statistics between two mask objects.

Signature:

compare_masks(sourceMaskName: str, targetMaskName: str) -> MaskComparisonResult

Parameters:

ParameterTypeDescription
sourceMaskNameanyName of the source mask object.
targetMaskNameanyName of the target mask object.

Returns: MaskComparisonResult — Mask comparison result containing Dice coefficient, false positive/negative rates, and volume similarity.


fit_primitive_to_surface

Fits a geometric primitive to a surface object.

Signature:

fit_primitive_to_surface(surfaceName: str, params: PrimitiveFittingParams) -> PrimitiveFittingResult

Parameters:

ParameterTypeDescription
surfaceNameanyName of the surface object to fit.
paramsanyPrimitive fitting parameters. Use api.PrimitiveFittingParams().

Returns: PrimitiveFittingResult — Primitive fitting result containing the fitted primitive information.


fit_primitive_to_mask_3d_preview

Fits a geometric primitive to a mask's 3D preview.

Signature:

fit_primitive_to_mask_3d_preview(maskName: str, params: PrimitiveFittingParams) -> PrimitiveFittingResult

Parameters:

ParameterTypeDescription
maskNameanyName of the mask object whose 3D preview will be used for fitting.
paramsanyPrimitive fitting parameters. Use api.PrimitiveFittingParams().

Returns: PrimitiveFittingResult — Primitive fitting result containing the fitted primitive information.


See Also