# Access to Error Metric during VMTK Level Set Evolution in Python

**URL:** <https://discourse.slicer.org/t/access-to-error-metric-during-vmtk-level-set-evolution-in-python/37306>\
**Category:** VMTK\
**Tags:** python\
**Created:** [July 10, 2024, 2:47pm UTC](https://discourse.slicer.org/t/access-to-error-metric-during-vmtk-level-set-evolution-in-python/37306 "2024-07-10T14:47:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tuingc159](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@tuingc159](https://discourse.slicer.org/u/tuingc159)\
**Post date:** [July 10, 2024, 2:47pm UTC](https://discourse.slicer.org/t/access-to-error-metric-during-vmtk-level-set-evolution-in-python/37306/1 "2024-07-10T14:47:20Z")

</div>

Hi all,

I have implemented the `vmtkLevelSetSegmentation` module in Python for my segmentation tasks using VMTK. During the evolution of level sets, I am interested in accessing the error metric (such as RMS error) to monitor convergence directly within my Python script.

Currently, the segmentation stops based on `self.MaximumRMSError`, which sets the maximum allowable RMS error. (or when self.NumberOfIterations is reached) However, I would like to retrieve this error metric programmatically during the evolution process to monitor convergence more closely.  
I understand that `self.PrintProgress` captures progress as a percentage via a `"ProgressEvent"`. However, this does not provide insight into the specific error between iterations.

Could someone please provide the method to access the error metric (RMS error or similar) during level set evolution in Python? Alternatively, a feature enhancement for this capability would greatly assist in monitoring convergence and optimizing parameters.

So for example:  
levelSets = vmtk.vmtkLevelSetSegmentation()  
levelSets.Execute()  
currentRmsError = levelSets.GetCurrentRMSError()

Thank you.
