MeasureOperations
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:
| Parameter | Type | Description |
|---|---|---|
volumeName | any | Name of the volume object to analyze. |
params | any | Histogram 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:
| Parameter | Type | Description |
|---|---|---|
volumeName | any | Name of the volume object to analyze. |
maskName | any | Name of the mask object used to restrict the analyzed region. |
params | any | Histogram 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.
Signature:
export_histogram_to_disk(histogramResult: HistogramResult, fileName: str) -> bool
Parameters:
| Parameter | Type | Description |
|---|---|---|
histogramResult | any | The histogram result as api.HistogramResult to export. |
fileName | any | Full 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:
| Parameter | Type | Description |
|---|---|---|
statisticsResult | any | The volume statistics result as api.VolumeStatisticsResult to export. |
fileName | any | Full 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:
| Parameter | Type | Description |
|---|---|---|
similarityResult | any | The volume similarity result as api.VolumeSimilarityResult to export. |
fileName | any | Full 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:
| Parameter | Type | Description |
|---|---|---|
statisticsResult | any | The mask statistics result as api.MaskStatisticsResult to export. |
fileName | any | Full 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:
| Parameter | Type | Description |
|---|---|---|
comparisonResult | any | The mask comparison result as api.MaskComparisonResult to export. |
fileName | any | Full 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:
| Parameter | Type | Description |
|---|---|---|
statisticsResult | any | The surface mesh statistics result as api.SurfaceMeshStatisticsResult to export. |
fileName | any | Full 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:
| Parameter | Type | Description |
|---|---|---|
statisticsResult | any | The volume mesh statistics result as api.VolumeMeshStatisticsResult to export. |
fileName | any | Full 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:
| Parameter | Type | Description |
|---|---|---|
qualityResult | any | The surface mesh quality result as api.SurfaceMeshQualityResult to export. |
fileName | any | Full 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:
| Parameter | Type | Description |
|---|---|---|
qualityResult | any | The volume mesh quality result as api.VolumeMeshQualityResult to export. |
fileName | any | Full 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:
| Parameter | Type | Description |
|---|---|---|
volumeName | any | Name of the volume object to analyze. |
params | any | Volume 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:
| Parameter | Type | Description |
|---|---|---|
volumeName | any | Name of the volume object to analyze. |
maskName | any | Name of the mask object to filter the volume. |
params | any | Volume 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:
| Parameter | Type | Description |
|---|---|---|
sourceVolumeName | any | Name of the source volume object. |
targetVolumeName | any | Name 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:
| Parameter | Type | Description |
|---|---|---|
maskName | any | Name of the mask object to analyze. |
volumeName | any | Optional volume name for intensity-based statistics (empty string if not needed). |
requestedStats | any | Optional 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:
| Parameter | Type | Description |
|---|---|---|
maskName | any | Name of the mask object to analyze. |
volumeName | any | Optional volume name for intensity-based statistics (empty string if not needed). |
requestedStats | any | Optional 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:
| Parameter | Type | Description |
|---|---|---|
maskName | any | Name of the multi-label mask object to analyze. |
volumeName | any | Optional volume name for intensity-based statistics (empty string if not needed). |
requestedStats | any | Optional 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:
| Parameter | Type | Description |
|---|---|---|
maskName | any | Name of the mask object whose 3D preview will be analyzed. |
requestedStats | any | Optional 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:
| Parameter | Type | Description |
|---|---|---|
maskName | any | Name of the multi-label mask object whose 3D preview will be analyzed. |
requestedStats | any | Optional 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:
| Parameter | Type | Description |
|---|---|---|
surfaceName | any | Name of the surface object to analyze. |
requestedStats | any | Optional 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:
| Parameter | Type | Description |
|---|---|---|
requestedStats | any | Optional 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:
| Parameter | Type | Description |
|---|---|---|
surfaceName | any | Name of the surface object to analyze. |
requestedStats | any | Optional 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:
| Parameter | Type | Description |
|---|---|---|
volumeMeshName | any | Name of the volume mesh object to analyze. |
requestedStats | any | Optional 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:
| Parameter | Type | Description |
|---|---|---|
requestedStats | any | Optional 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:
| Parameter | Type | Description |
|---|---|---|
surfaceName | any | Name of the surface object to analyze. |
metricType | any | Quality 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:
| Parameter | Type | Description |
|---|---|---|
maskName | any | Name of the mask object whose 3D preview will be analyzed. |
metricType | any | Quality 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:
| Parameter | Type | Description |
|---|---|---|
volumeMeshName | any | Name of the volume mesh object to analyze. |
metricType | any | Quality 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:
| Parameter | Type | Description |
|---|---|---|
primitive1Name | any | Name of the first primitive object. |
primitive2Name | any | Name of the second primitive object. |
createMeasurement | any | If 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:
| Parameter | Type | Description |
|---|---|---|
sourceMaskName | any | Name of the source mask object. |
targetMaskName | any | Name 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:
| Parameter | Type | Description |
|---|---|---|
surfaceName | any | Name of the surface object to fit. |
primitiveType | any | The 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:
| Parameter | Type | Description |
|---|---|---|
maskName | any | Name of the mask object whose 3D preview will be used for fitting. |
primitiveType | any | The type of primitive to fit. Use api.PrimitiveFittingType.Sphere. |
Returns: PrimitiveFittingResult — Primitive fitting result containing the fitted primitive information as api.PrimitiveFittingResult.