Page 1 of 1

Obtaining volumetric values from 3d model

Posted: Thu Jan 09, 2025 9:06 pm
by william2203
Is there a function or way to find the volume of the vessel from the specific 3D model within SimVascular? If not what are some other options?

Re: Obtaining volumetric values from 3d model

Posted: Fri Jan 10, 2025 11:32 am
by davep
Hello,

SV does not compute vessel volumes, will need to do this manually.

You will need to first write out the lofted surface for a vessel to a VTK VTP file from the Segmentations Tool.
Screenshot 2025-01-10 at 9.40.47 AM.png
Screenshot 2025-01-10 at 9.40.47 AM.png (278.91 KiB) Viewed 737 times
You can then write a Python script using the vtk package to compute the volume, something like

Code: Select all

import vtk

if __name__ == '__main__':
    file_name = sys.argv[1]
    reader = vtk.vtkXMLPolyDataReader()
    reader.SetFileName(file_name)
    reader.Update()
    lofted_model = reader.GetOutput()

    fill_hole_filter = vtk.vtkFillHolesFilter()
    fill_hole_filter.SetInputData(lofted_model)
    fill_hole_filter.SetHoleSize(float(1e10))
    fill_hole_filter.Update()
    volume_model = fill_hole_filter.GetOutput()
    
    mass_props = vtk.vtkMassProperties()
    mass_props.SetInputData(volume_model)
    mass_props.Update()

    surf_area = mass_props.GetSurfaceArea()
    print("Model surface area: {0:f}".format(surf_area))

    volume = mass_props.GetVolume()
    print("Model volume: {0:f}".format(volume))
Be sure to check to make sure you are getting the correct volume, you never know with VTK.

Cheers,
Dave

Re: Obtaining volumetric values from 3d model

Posted: Tue Jan 21, 2025 2:54 pm
by william2203
Hi Dave,

Thank you so much for the information. Would you be able to share the python script with me?

Here is my email: wlim1704@gmail.com

Best,
William Lim

Re: Obtaining volumetric values from 3d model

Posted: Tue Feb 04, 2025 11:40 am
by davep
Hi William,

Just copy the script that I posted.

Cheers,
Dave