Unexpected behavior of fiducial node

Ok not really unexpected, but annoying.
I’m using a script to loop over control points in a fiducial node, then delete the ones that do not belong to a given labelmap.

To delete a control point, I only found the method removeNthcontrolpoint. But here is the issue : the list of controlpoints gets reordered after each deletion. So my loop gets broken.

For example if I delete the 4t control point, the next loop iteration will jump to what was the 6th control point, because it is now the 5th.

Not sure if I’m understandable here.

Is there a workaround ? I could workaround it but it would be a dirty hack

Thank you , have a good weekend

When you erase items from a list by index then always start with last item that you want to delete, then the second last, etc. and finally the first one (because deleting an item only invalidates indices of the items after it).

Simple and effective. Thank you for all your work around here

1 Like