Export coordinate points of markups to the predefined folder

I’m pretty sure that this is a very simple, but can’t find an answer in the Support category.
I need to export the RAS of the markups table to the predefined folder just with one click of the “Export” button to avoid the “highlight”, “copy” and “paste” generated by the Slicer table option.
Is such a solution already exist?
Thank you in advance!

You can write a few-line Python script to do this and assign it to a keyboard shortcut. For example, export to table node by calling slicer.modules.markups.logic().ExportControlPointsToTable(...) and then save the table node to file. See examples in the script repository.

What is the end goal of your project?

If you want to make the same measurements on many data sets then you may find this short tutorial useful:

If you want to use this for real-time communication with an external software then you can use OpenIGTLink to stream markup positions to any other application. For example, you can receive the point positions in real-time in any Python environment using pyigtl package.

Thanks a lot for your prompt reply!
The goal is to get in real-time a needle position inserted in phantom with the tracking system and send coordinates of the penetration point with the needle’s spatial information to the fem simulation. Compare results of obtained simulation with the pre-simulated computation and adjust the intensity of the media distributed through the needle or, change/adjust the needle position and send again to the fem computation.
I’m trying to follow up with example on GitHub - lassoan/pyigtl: Python implementation of OpenIGTLink. However, there is an error when executing pyigtl commands in cmd (screenshot attached).
Also, could you please tell how to check version of installed OpenIGTLink?
Thank you in advance for the help and suggestions.

What FEM simulation package do you use? If it has a Python interpreter then you can run pyigtl directly in there. If the simulator has any other real-time interface then you should be able to send messages from Slicer’s Python environment using that interface.

It’s a great suggestion, because we’re using COMSOL; will investigate the Python interpreter in it.
Thanks!!

I stuck with the real-time markups stream using pyigtl, which was successfully (i hope) installed by cmd “pip install pyigtl”, according to pyigtl/pyigtl at master · lassoan/pyigtl · GitHub
Executing a simple ‘import pyigtl’ in Slicer, generates ModuleNotFoundError: No module named ‘pyigtl’
Should i build the module and install it by using Slicer Extension Manager?
Could you please provide a short description of how to implement and use pyigtl in Slicer?


No_module_pyigtl
Thank you!

Slicer has OpenIGTLink support via the SlicerOpenIGTLink extension. It automatically sends out messages if designated nodes change and it automatically updates data in the scene from incoming OpenIGTLink messages.

pyigtl is to be used in external software (such as comsol), so that you can send data to or receive data from Slicer in real-time.

I didn’t realize that the data can be updated completely automatically!
I want to try pyigtl within other than comsol environment, since native comsol doesn’t have a python api. Would be possible to upload an example/video/screenshot of your pyigtl test?
Thank you!

You can run pyigtl in any Python environment.

I would recommend to use a Python IDE, such as Visual Studio Code. There should be lots of tutorials online.