Hi everyone,
I’m quite a new entry in the Slicer world. I’m trying to use a python script for batch conversion of structures to .vtk but I face some problems. The first issue I would like to solve is this: I loaded two test patients files and it seems they are correcly imported in the Database, but then when I use slicer.dicomDatabase.patients() I get a list of integers instead of patients IDs and subsequently I get some errors, trying to call the patients in other parts of the code. Here is a simple example:
from DICOMLib import DICOMUtils
input_folder = '/Users/lisaalborghetti/Desktop/Patients/dicom'
DICOMUtils.openTemporaryDatabase()
DICOMUtils.importDicom(input_folder)
all_patients = slicer.dicomDatabase.patients()
print("Patient list: ", all_patients)
patient_names = {}
# Loop through the patient IDs and extract patient names
for patient_id in all_patients:
patient_name = slicer.dicomDatabase.fileValue(patient_id, '0010,0010')
patient_names[patient_id] = patient_name
for patient_id, patient_name in patient_names.items():
print(f"Patient ID: {patient_id}, Patient Name: {patient_name}")
This is what I see in 3Dslicer:
And this the terminal output:
Patient list: (‘1’, ‘2’)
Could not load “1”
DCMTK says: No such file or directory
File 1 could not be initialized.
Could not load “2”
DCMTK says: No such file or directory
File 2 could not be initialized.
Patient ID: 1, Patient Name:
Patient ID: 2, Patient Name:
Am I doing something wrong?
Thank you!
Lisa