Hi,
I’m currently using the qSlicerWeb widget to build an embedded Dicom manage system based on the web. I’m wondering if there’s any way to programming set the file download save folder by python? we have the custom script that needs to scan the file in a specific location.
Thanks!
You can configure all folders that Slicer uses in the application settings (Slicer.ini file). You can edit it by using the qt.QSettings()
object. Paths can be relative path in the Slicer installation tree or an absolute path; shared between all Slicer instances or specific to one Slicer install tree.
We have implemented several features that allow serving a DICOM database from an internal or external web browser (on the same computer or from remote computers) or launch Slicer from the web browser (e.g., using Kheops or OHIF viewer). We are also adding a new module to the Slicer core within a week or so, which exposes Slicer as a web service (ENH: add WebServer module by pieper · Pull Request #5999 · Slicer/Slicer · GitHub).
Tell us a bit about the workflow that you are planning to implement (how the images are imported, how the user browses the data sets, what happens with created/modified data) and how (what framework do you use as a patient browser and viewer, how do you trigger launching Slicer and loading images, etc.) and we can give advice about how to take advantage of all the existing features.
Hi, lassoan,
Thanks for your reply
Our workflow requires using an embed browser running on the slicer end to allow the doctors to manage their images. The browser’s URL is set to a custom build web-based Dicom management system, pretty much like the kheops you did. but the different is all the operations need to be done using the embed browser in the slicer.
for example import image, we want the user would be able to click a button (from the web-based Dicom management running at embed browser in slicer), the slicer will automatically download, opened and store the requested image file to our set location and close the browser window, without pop-ups asking the user to load or save as every time in order to simplify the doctor’s workflow.
We need more controls of the qSlicerWeb widget. one of the challenges we faced is not much documentation about qSlicerWeb available, majority of the docs is the C++ one, I have tried one on the apidocs.slicer.org e.g. the onLinkClicked() seems not many of them are implemented on the python end.
QObject::connect() signal ‘onLinkClicked’ does not exist on qSlicerWebWidget
Qt has removed its nice and simple webkit-based browser (QWebView) and added a huge, very complicated, but very powerful Chromium-based browser instead (QWebEngine). I loved the onLinkClicked
signal in QWebView, but it does not exist anymore. You need to set up web sockets instead. See details in qSlicerWebWidget implementation.
See current documentation of the Slicer web widget here.
If you find Slicer’s built-in browser inconvenient then you can serve your web application from Slicer but open it in an external browser. You can communicate with Slicer using the REST API provided by the WebServer module.
When you use Kheops (or you set up OHIF like that) then you can open the the selected study in Slicer without any popups (your browser asks first if you want to always ask before opening the custom URL in Slicer but if you choose not to ask again then there are no more popups) with a single click.
With a short Python script you can suppress scene saving confirmation popups and discard all changes or save all changes automatically.
Thanks for the additional information about your workflow. It explains a few things, but not everything is clear yet.
- What do you mean by “web-based DICOM management system”? Do you want to just browse the patient/study/series list in the web browser or also view or even annotate and segment images in the browser?
- Do you want to use your web-browser based DICOM browser because you prefer the appearance? Is there any particular functional limitation or other issue with Slicer’s DICOM browser or you just don’t like how it looks? Are there any other desktop applications (OsiriX, Weasis, …?) that have a DICOM browser that you think looks nicer and your users would accept?
- Do you use the web-based DICOM browser only on the same computer where Slicer is running or users may connect to it from other computers?
- Where do you store the data sets? In a DICOMweb database? Do you need to manage any non-DICOM data?
As of this commit you can override the download behavior for the web widget so that Slicer handles it in whatever way you choose.
Also, when you are using the qSlicerWebWidget
you have total bidirectional control via JavaScript and Python. For example in SlicerMorph, this is used to enter username and password to the web page, but really anything is possible to control, like changing the contents of the links, adding new buttons etc. The js code can also control Slicer’s python environment using window.slicerPython.evalPython()
. See the test code for examples.
Hi lassoan,
Thanks for your reply,
The “web-based DICOM management system” is just an online patient studies system running on the web and we’d like to do all the images related operations such as annotation and segmentation in the slicer and open with the selected images through a button on the web.
We attempted the restful API approach that you just recommend before, one biggest problem we encountered is it will open multiple instances of slicer application, we want to keep the slicer in singleton instance and if the doctors click another image link in the web, it doesn’t open another slicer, the old slicer should pop-ups a prompts asking the doctor whatever he would like to open and view another file before he saved.
From your description of the desired behavior I would say the same behavior could be accomplished using either the qSlicerWebWidget or the WebServer approach, but probably the widget is easier and has the advantage that the widget running the web app can be positioned by Slicer and even packed into the layout like the dicom browser is.
See this thread on how to open a file in an already running Slicer instance using the new WebServer module:
Call slicer.app.openUrl
instead of slicer.addp.loadFiles([...])
in the last line of the code snippet to load from a DICOMweb URL instead of a local file.
Thanks
It does work on my local machine, but the request seems to be blocked on the remote server by the browser’s CORS policy, is there any way to enable ‘Access-Control-Allow-Origin’, ‘*’ in the WebServer module for /slicer/repl ?
Good question - I haven’t tried CORS in the Slicer WebServer, but it should just be a matter of adding a header or two in the right place. Typically I host the web app statically from the WebServer’s docroot so the repl requests are from the same origin.