I have a question regarding creating temporary database, I got the script from ‘ScriptRepository’ of creating temporary database and loading DICOMs to slicer " How to load DICOM files into the scene from a folder" . My issue is that when I populates the database using “importDicom” function, the database is still empty. I’m working on c++ loadable module in which I want to load DICOM files into temporary database and as loader is python based module, I have to process python script in c++. Here is what this code looks like:
PythonQtObjectPtr context = PythonQt::self()->getMainModule();
“from pathlib import Path\n”
“from DICOMLib import DICOMUtils\n”
“with DICOMUtils.TemporaryDICOMDatabase(directory) as db:\n”
" DICOMUtils.importDicom(dicomDataDir, db)\n"
" patientUIDs = db.patients()\n"
" for patientUID in patientUIDs:\n"
The above code is called on click of button and “folderName” variable has all the dicom files. When this evalScript is done, in separate function in c++, I’m opening the database using following code but it shows empty output for patientsUIDs:
ctkDICOMDatabase *data; data->openDatabase("/tmp/SlicerCAT-user/TEMP/ctkDICOM.sql"); //This is where temporary database is QStringList patients = data->patients(); qDebug() << "Patients UIDs" << patients; qDebug() << "StudyList" << data->studiesForPatient(patients);
My question is that does the temporary database is cleared automatically when “evalScript” is run and finishes. During evalScript, I printed the studyList of loaded Dicoms and it shows correct output.