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 = HistogramParams()) -> HistogramResult

Parameters:

ParameterTypeDescription
volumeNamestrName of the volume object to analyze.
paramsHistogramParamsHistogram generation parameters. Create using api.HistogramParams(). params.numberOfBins, params.target, and params.sliceMode control how the histogram is computed. If params.imageFilePath is not empty, a histogram chart image is also saved to disk using the standard application histogram styling.

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


generate_histogram_with_mask​

Generates a histogram for a volume restricted to the region covered by a mask.

Signature:

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

Parameters:

ParameterTypeDescription
volumeNamestrName of the volume object to analyze.
maskNamestrName of the mask object used to restrict the analyzed region.
paramsHistogramParamsHistogram generation parameters. Create using api.HistogramParams(). params.numberOfBins and params.sliceMode control how the histogram is computed within the mask region. If params.imageFilePath is not empty, a histogram chart image is also saved to disk using the standard application histogram styling.

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


File System​

export_histogram_to_disk​

Exports histogram data to a formatted text file. Each row names the value range a bin covers and the number of voxels counted within it, so that a count is never read as the number of voxels at one exact value.

Signature:

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

Parameters:

ParameterTypeDescription
histogramResultHistogramResultThe histogram result as api.HistogramResult to export.
fileNamestrFull 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
statisticsResultVolumeStatisticsResultThe volume statistics result as api.VolumeStatisticsResult to export.
fileNamestrFull 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
similarityResultVolumeSimilarityResultThe volume similarity result as api.VolumeSimilarityResult to export.
fileNamestrFull 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
statisticsResultMaskStatisticsResultThe mask statistics result as api.MaskStatisticsResult to export.
fileNamestrFull 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
comparisonResultMaskComparisonResultThe mask comparison result as api.MaskComparisonResult to export.
fileNamestrFull 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
statisticsResultSurfaceMeshStatisticsResultThe surface mesh statistics result as api.SurfaceMeshStatisticsResult to export.
fileNamestrFull 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
statisticsResultVolumeMeshStatisticsResultThe volume mesh statistics result as api.VolumeMeshStatisticsResult to export.
fileNamestrFull 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
qualityResultSurfaceMeshQualityResultThe surface mesh quality result as api.SurfaceMeshQualityResult to export.
fileNamestrFull 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
qualityResultVolumeMeshQualityResultThe volume mesh quality result as api.VolumeMeshQualityResult to export.
fileNamestrFull 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 = VolumeStatisticsParams()) -> VolumeStatisticsResult

Parameters:

ParameterTypeDescription
volumeNamestrName of the volume object to analyze.
paramsVolumeStatisticsParamsVolume statistics parameters. Create using api.VolumeStatisticsParams().

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


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 = VolumeStatisticsParams()) -> VolumeStatisticsResult

Parameters:

ParameterTypeDescription
volumeNamestrName of the volume object to analyze.
maskNamestrName of the mask object to filter the volume.
paramsVolumeStatisticsParamsVolume statistics parameters. Create using api.VolumeStatisticsParams().

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


compute_volume_similarity​

Computes similarity statistics between two volume objects.

Signature:

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

Parameters:

ParameterTypeDescription
sourceVolumeNamestrName of the source volume object.
targetVolumeNamestrName of the target volume object.

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


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
maskNamestrName of the mask object to analyze.
volumeNamestrOptional volume name for intensity-based statistics (empty string if not needed).
requestedStatslistOptional 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 as api.MaskStatisticsResult.


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
maskNamestrName of the mask object to analyze.
volumeNamestrOptional volume name for intensity-based statistics (empty string if not needed).
requestedStatslistOptional 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 as api.MaskStatisticsResult.


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
maskNamestrName of the multi-label mask object to analyze.
volumeNamestrOptional volume name for intensity-based statistics (empty string if not needed).
requestedStatslistOptional 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 as api.MaskStatisticsResult.


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
maskNamestrName of the mask object whose 3D preview will be analyzed.
requestedStatslistOptional 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 as api.SurfaceMeshStatisticsResult.


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
maskNamestrName of the multi-label mask object whose 3D preview will be analyzed.
requestedStatslistOptional 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 as api.SurfaceMeshStatisticsResult.


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
surfaceNamestrName of the surface object to analyze.
requestedStatslistOptional 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 as api.SurfaceMeshStatisticsResult.


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
requestedStatslistOptional 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 as api.SurfaceMeshStatisticsResult.


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
surfaceNamestrName of the surface object to analyze.
requestedStatslistOptional 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 as api.SurfaceMeshStatisticsResult.


compute_volume_mesh_statistics​

Computes statistics for a volume mesh object.

Signature:

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

Parameters:

ParameterTypeDescription
volumeMeshNamestrName of the volume mesh object to analyze.
requestedStatslistOptional 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 as api.VolumeMeshStatisticsResult.


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
requestedStatslistOptional 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 as api.VolumeMeshStatisticsResult.


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
surfaceNamestrName of the surface object to analyze.
metricTypeSurfaceMeshQualityMetricQuality metric type. Use api.SurfaceMeshQualityMetric.AspectRatio

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


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
maskNamestrName of the mask object whose 3D preview will be analyzed.
metricTypeSurfaceMeshQualityMetricQuality metric type. Use api.SurfaceMeshQualityMetric.AspectRatio

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


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
volumeMeshNamestrName of the volume mesh object to analyze.
metricTypeVolumeMeshQualityMetricQuality metric type. Use api.VolumeMeshQualityMetric.TetAspectRatio

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


measure_between_primitives​

Measures the distance between two primitive objects.

Signature:

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

Parameters:

ParameterTypeDescription
primitive1NamestrName of the first primitive object.
primitive2NamestrName of the second primitive object.
createMeasurementboolIf True (default), creates a distance measurement object in the project between the two closest points. The measurement is only created when the computed distance is non-negative.

Returns: PrimitiveMeasurementResult — Primitive measurement result containing the shortest geometric distance and closest points as api.PrimitiveMeasurementResult. The measurementName field contains the created measurement object name only when a measurement object was created.


General​

compare_masks​

Computes overlap statistics between two mask objects.

Signature:

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

Parameters:

ParameterTypeDescription
sourceMaskNamestrName of the source mask object.
targetMaskNamestrName of the target mask object.

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


fit_primitive_to_surface​

Fits a geometric primitive to a surface object. On success a new primitive markup object is created in the project. Cone fitting is not supported.

Signature:

fit_primitive_to_surface(surfaceName: str, primitiveType: PrimitiveFittingType) -> PrimitiveFittingResult

Parameters:

ParameterTypeDescription
surfaceNamestrName of the surface object to fit.
primitiveTypePrimitiveFittingTypeThe type of primitive to fit. Use api.PrimitiveFittingType.Sphere.

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


fit_primitive_to_mask_3d_preview​

Fits a geometric primitive to a mask's 3D preview. Requires that a 3D preview of the mask has already been generated. On success a new primitive markup object is created in the project. Cone fitting is not supported.

Signature:

fit_primitive_to_mask_3d_preview(maskName: str, primitiveType: PrimitiveFittingType) -> PrimitiveFittingResult

Parameters:

ParameterTypeDescription
maskNamestrName of the mask object whose 3D preview will be used for fitting.
primitiveTypePrimitiveFittingTypeThe type of primitive to fit. Use api.PrimitiveFittingType.Sphere.

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


See Also​