Hi there, I am trying to write a python script that uses Totalsegmentator in 3dSlicer, but so far I am not able to make good progress. The aim of using it in 3dslicer instead of standalone is to be able to exctract SUV values from pet data later using the same script. So far the import seems to work, but I wasn`t able to figure out how to call totalsegmentator. Also, since the DICOM includes ct and pet files, the script should figure out which of the files (=CT) to use as input (?)
So far my script is as follows, can someone help me out how to continue from here?
import os
import sys
import TotalSegmentator
from DICOMLib import DICOMUtils
dicomDataDir = “C:/Users/user1/sample/dicom” # input folder with DICOM files
Check if the folder exists
if not os.path.exists(dicomDataDir):
sys.exit(“Aborting the script. Folder is required.”)
loadedNodeIDs =
with DICOMUtils.TemporaryDICOMDatabase() as db:
DICOMUtils.importDicom(dicomDataDir, db)
patientUIDs = db.patients()
for patientUID in patientUIDs:
loadedNodeIDs.extend(DICOMUtils.loadPatientByUID(patientUID))
slicer.util.selectModule(“TotalSegmentator”)