How can I use vmtk using python without 3D slicer GUI?

Hello everyone,
I’ve just started using vmtk package in python. (windows OS).
I’m not willing to use the GUI provided by 3D slicer now, I’ll be building the complete project with python code, is it possible? and if yes, may someone help me load dicom images?

Here’s the error message:

vmtkimagereader -ifile “patient\IMG0001.dcm” --pipe vmtkimagereader
^
SyntaxError: invalid syntax

Thank you

I would recommend to get started with the Slicer GUI (if a GUI exists for the function you need). When you know exactly what you want to do and how then you can automate things using pure Python scripting. I’m not sure exactly what is the state of VMTK’s Python wrapping and availability in PyPI and conda, it may be available, and you may be able to make the VTK classes or even the PypeS interface work, but that is just way more difficult than installing VMTK with a few clicks in Slicer, segment the input image using Segment Editor, then extract centerline and compute metrics with another few clicks.

What is the end goal of the project? What is the specify task that you would like address first?

Hello,
We actually used 3D slicer before & also Pyepad and they were very efficient, but using a pure python code for the job is a requirement for our thesis but we faced some difficulties so I was willing to find anyone here who used this before. The aim is to obtain the hessian analysis & the eigenvectors and eigenvalues at each point of the image. I tried multiple approaches like downloading the vmtk as a package and activated an anaconda virtual environment and tried to access it in visual studio code where ‘import vmtk’ worked but it couldn’t read the modules like vmtkimagereader

If all the features that you need work in Slicer then the simplest is to run VMTK in Slicer’s Python environment. You can either use the Slicer modules without GUI (just calling methods of module logic classes - see a complete example here) or just use Python-wrapped VTK classes. PypeS interface may work, too, I have never tried those (they add a layer between you and VMTK classes, so it is harder to see what is actually happening), just used those as examples.

First, I want to thank you so much for your replies, I really appreciate it :pray:.
Can you please elaborate what are Python-wrapped VTK classes?

All VMTK classes are Python-wrapped and readily available in the Python environment that Slicer provides. See an example here.

Hello Amira,
Have you tried using pypes?
vmtk-pypes
Even though it is not ‘pure python functions’, but ‘pypes wrapped functions’.