Show DICOM browser's folder import dialog

How Can i directly Call(or popup) DICOM Browser -> Import

In recent Slicer Preview releases, you can do this to show folder selector for DICOM import:

slicer.util.selectModule('DICOM')
slicer.modules.DICOMInstance.browserWidget.dicomBrowser.openImportDialog()

Thank you very much. Have a Nice Day :slight_smile:

But i want to call in my qSlicerMainWindow.cxx file.

in other words.

i want to call python script in my c++ code

You can run Python code from C++ using pythonManager->executeString.

If you want to import DICOM files from a folder then you can create ctkDICOMIndexer independent from the one in the DICOM browser as shown in this example.

Thank you. i will do it ^^

I am making the source code but it is very hard to me to call python code in my c++ in slicer
for showing DICOM browser’s folder import dialog

pythonManager->executeString .

slicer.util.selectModule(‘DICOM’)
slicer.modules.DICOMInstance.browserWidget.dicomBrowser.openImportDialog()

i found similar code but not work for me
Show DICOM browser’s folder import dialog

If you have any specific issue with calling Python from C++ then let us know. If you prefer staying in C++ then you can follow the example in CTK that I referred to above.

I will do it at Slicer Preview releases^^

DICOM browser changed recently, so the code to show the it may be slightly different for the stable release.

i saw the source code but i think there’s many changes between stable vs. preview release.

it is now working for me;

similar situation,

i want to show DICOM browser’s folder export dialog
preview release doesn’t support this.

would show me the sample code?

seconde question :slight_smile:
after exporting DICOM Data, i want to delete previous data which is used for exporting. i want python script code example.

image

Everything that the old DICOM browser could do, the new one can do, too. What code did you use previously to show the export dialog?

You can use removePatient/removeStudy/removeSeries to delete selected items or cleanup to remove all database content. But a more common approach is to create a temporary DICOM database and then remove it completely (using openTemporaryDatabase/closeTemporaryDatabase - see example).

i want to show DICOM browser’s folder export dialog
preview release doesn’t support this.

Everything that the old DICOM browser could do, the new one can do, too. What code did you use previously to show the export dialog?

I just execute below python script.
slicer.util.selectModule(‘DICOM’)
slicer.modules.DICOMInstance.browserWidget.dicomBrowser.openExportDialog()

i want to call directly export dialog like import dialog
ex)
slicer.util.selectModule(‘DICOM’)
slicer.modules.DICOMInstance.browserWidget.dicomBrowser.openImportDialog()

Thank you for your concern and effort^^

You can show export dialog in recent Slicer versions like this:

exportDialog = slicer.qSlicerDICOMExportDialog()
exportDialog.setMRMLScene(slicer.mrmlScene)
exportDialog.execDialog()

Thanks Lasso^^, It workd now.

I can’t find exact script code for this issue. in other words, exact function or call flow
i already examine your related sample code and source code in slicer DICOMUtil.py
Would you plz share sample script code to delete previous data which is used for exporting^^.



If you want to add series to the database temporarily (only to allow loading), then I would recommend to create a temporary database as I described above.

Using dicomDatabase.remove... methods is more complicated: first you need to store all previously existing series in the database in a variable, then import data that you need, get all series in the database, remove all the series that did not exist previously, and finally remove all orphan studies and patients.

If you want to add series to the database temporarily (only to allow loading), then I would recommend to create a temporary database as I described above.
==> I understand now. this approach is simple for my issue. just create database and add it to new database and delete existing old database.
I will do it and let it shared in this page^^

1 Like

when i call pythonManager() in C++
I found compiler can’t find pythonManager()
(i already investigate related source codes)

in other words,
qSlicerApplication::application()->layoutManager() <== it is OK.
qSlicerApplication::application()->pythonManager() <== it is NO

A type cannot be used until it is defined. To resolve the error, be sure the type is fully defined before referencing it.

image

In C++, to use a class that is implemented in another library, you need to #include the corresponding header file and add the include directory and library to the CMakeLists.txt file of the component that you are building. There are thousands of examples for this in Slicer source code (all classes are used like this).

1 Like