To use VTK from a script in Slicer’s Python environment:
Instead of these steps, you can load the nifti mask directly as a segmentation node. See example.
If you want to run some additional Segment Editor effects, you can load the mask as a scalar volume and use it as master volume and then follow these examples.
You can use Extract Centerline module logic class from your own scripts or copy paste any parts of the modules into your scripts.
If the aneurysms are not just slightly dilated vessels but ballooning out then instead of centerline analysis you may consider segmenting the aneurysm sack and get shape properties using Segment Statistics module (there are many optional shape metrics that you can enable).