Hello! I want to run a python script for Slicer from PyCharm. I’m using the SegmentEditor module and PyRadiomics, and would like to automate the process for batch processing.
I’m able to write a script that runs on Slicer’s python console but I can’t figure out how to run it from PyCharm. I’m aware slicer has a debugger on pycharm and I tried setting slicer’s python.exe as the interpreter in pycharm. It hasn’t worked for me. Would anyone be able to advise?
The python interpreter of slicer can’t run on its own, you need the slicer environment if you use the modules and/or the slicer API.
You can run a python script in the slicer environment using this command : Slicer.exe --python-script "/full/path/to/myscript.py" --no-splash --no-main-window
I haven’t tried but you can probably configure pycharm to execute this command for you if you want to stay in pycharm.
I ran into a problem with my code. Below is a snippet. When I want to export the features table, the csv is empty; it just has the headers. I think this is because the feature extractor is not done working and the table is already exported as csv, because when I wait for the extracted to be done then save as table, it works fine. However, this won’t be good if I have to do this for every time I extract the features. Can you by any chance advise how to go about this?