# Show 3D reconstruction rendered by Slicer in a web browser

**URL:** <https://discourse.slicer.org/t/show-3d-reconstruction-rendered-by-slicer-in-a-web-browser/24045>\
**Category:** Development\
**Tags:** extensions-manager\
**Created:** [June 25, 2022, 1:03pm UTC](https://discourse.slicer.org/t/show-3d-reconstruction-rendered-by-slicer-in-a-web-browser/24045 "2022-06-25T13:03:11Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [June 25, 2022, 1:03pm UTC](https://discourse.slicer.org/t/show-3d-reconstruction-rendered-by-slicer-in-a-web-browser/24045/1 "2022-06-25T13:03:11Z")

</div>

I have my Slicer app run background on WIN10 , How can I activate Slicer app to show 3D reconstruction by a message sends from browser

I would donate 200$ to Slicer for soving this problems, because it puzzled me a very long time.

---

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [June 25, 2022, 2:04pm UTC](https://discourse.slicer.org/t/show-3d-reconstruction-rendered-by-slicer-in-a-web-browser/24045/2 "2022-06-25T14:04:21Z")

</div>

> [@zhang\_ming](#):
>
> I would donate 200$ to Slicer for soving this problems, because it puzzled me a very long ti

this problem means a lot to me , any one can solve this , I would pay for solution \> 200 $

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [June 25, 2022, 2:43pm UTC](https://discourse.slicer.org/t/show-3d-reconstruction-rendered-by-slicer-in-a-web-browser/24045/3 "2022-06-25T14:43:46Z")

</div>

Customization is required, but basically you can activate Slicer’s WebServer and connect to it from a browser by accessing the localhost port.

[https://slicer.readthedocs.io/en/latest/user\_guide/modules/webserver.html?highlight=webserver](https://slicer.readthedocs.io/en/latest/user_guide/modules/webserver.html?highlight=webserver)

---

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [June 26, 2022, 12:32am UTC](https://discourse.slicer.org/t/show-3d-reconstruction-rendered-by-slicer-in-a-web-browser/24045/4 "2022-06-26T00:32:44Z")

</div>

message from web-app PACS/HIS, with a chrome plugin, was sent to windows app like _“”" kview:////info=studyuid=1.2.826.0.1.3680043.2.461.13073401.3329453282#userid=9999#pacssvrip=172.16.0.59#pacssvrport=7008#pacssvrip1=#pacssvrport1=#security=1 “”"_, I wander if I can modify message to activate Slicer to get 3D reconstruction like this, thank you very much

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 26, 2022, 12:52am UTC](https://discourse.slicer.org/t/show-3d-reconstruction-rendered-by-slicer-in-a-web-browser/24045/5 "2022-06-26T00:52:42Z")

</div>

Yes, this should be no problem at all.

1. You need to [associate `kview://` protocol with Slicer](https://github.com/shotgunsoftware/developer.shotgunsoftware.com/blob/master/docs/en/action-menu-items/custom-browser-protocols.md) in your operating system. Then when you click on the link the operating system will automatically launch Slicer.
2. When Slicer is launched with a URL then the Slicer application object emits the `urlReceived` signal that your custom script can interpret (similarly [how it is done in DICOM module](https://github.com/Slicer/Slicer/blob/5794e16fd72035310301e545c345c372e38facdf/Modules/Scripted/DICOM/DICOM.py#L111)), for example it can retrieve the selected study based on the information in the URL, render the image, and make it available via the WebServer API.

I hope someone will show up here who can put this all together for you.

---

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [June 26, 2022, 2:44am UTC](https://discourse.slicer.org/t/show-3d-reconstruction-rendered-by-slicer-in-a-web-browser/24045/7 "2022-06-26T02:44:37Z")

</div>

thank you for answering. In our hospital, we use chrome browser to read dicom pic, and we can put a button on html , direct to Slicer, by sending message “https:// protocol with Slicer”? can any one help me for remote controll? I would pay for the help. this means a lot to our hospital.

---

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [June 26, 2022, 6:09am UTC](https://discourse.slicer.org/t/show-3d-reconstruction-rendered-by-slicer-in-a-web-browser/24045/8 "2022-06-26T06:09:48Z")

</div>

thank you, but I can’t find WebServer module in 3D Slicaer , my version is 5.0.2

---

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [June 26, 2022, 6:18am UTC](https://discourse.slicer.org/t/show-3d-reconstruction-rendered-by-slicer-in-a-web-browser/24045/9 "2022-06-26T06:18:39Z")

</div>

thank you , I foud the version 5.10 is ok

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 26, 2022, 3:44pm UTC](https://discourse.slicer.org/t/show-3d-reconstruction-rendered-by-slicer-in-a-web-browser/24045/11 "2022-06-26T15:44:26Z")

</div>

`https` protocol is associated with your web browser (so if you open an `https` URL then the operating system launches the default web browser; and if you click the link in the web browser then of course it will just open the link within the browser). Therefore, you need to use a custom protocol, such as `slicer` and the URL would look something like this:

```
slicer://viewer/?studyUID=2.16.840.1.113669.632.20.121711.10000158860&access_token=k0zR6WAPpNbVguQ8gGUHp6&dicomweb_endpoint=http%3A%2F%2Fdemo.kheops.online%2Fapi&dicomweb_uri_endpoint=%20http%3A%2F%2Fdemo.kheops.online%2Fapi%2Fwado

```

---

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [June 27, 2022, 8:18am UTC](https://discourse.slicer.org/t/show-3d-reconstruction-rendered-by-slicer-in-a-web-browser/24045/13 "2022-06-27T08:18:23Z")

</div>

I find another way to solve the problem, WebServer is ok, and use ‘localhost:2016/slicer/exec’ post to exec python with the operation I need. but I have not find the way to get dicom by patient name and studyId, could you please tell me how to exec this operation by python scripts, not just paste a [script\_repo](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#load-dicom-files-into-the-scene-from-a-folder), to judge all kind of opeartions, thank you very much!

Specially, post /slicer/exec, how can I make the Volume Rendering opeartion executed automatically?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [June 27, 2022, 7:32pm UTC](https://discourse.slicer.org/t/show-3d-reconstruction-rendered-by-slicer-in-a-web-browser/24045/14 "2022-06-27T19:32:24Z")

</div>

You can send any slicer python code (e.g. any of the code from the script repository or other python code) to the slicer/exec endpoint. This makes it very powerful, so be sure you have total control over what gets posted there (you may wish to wrap this in a security layer like a proxy).

But assuming you have that under control, then from what I can tell from your earlier posts you would need to take the information from the posted URL, like the study uid and pacs info, probably together with other pre-defined info like the pacs ip address, and download the study on to the local disk and import it through the dicom database. From there you can load and render using the rest of the slicer api. It’s not a huge job but there’s some programming you need to learn.

---

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [June 28, 2022, 12:42am UTC](https://discourse.slicer.org/t/show-3d-reconstruction-rendered-by-slicer-in-a-web-browser/24045/15 "2022-06-28T00:42:40Z")

</div>

Thank you for replying me in detail sincerely, and I am coing python to your open source program. sorry to disturbe again for some questions while in programing I found .

1. can Web Server start automatically in .slicerrc.py by python code (I have reading you code in webserver.py, and I have no idea )
2. add node from dicom database, using function " DICOMUtils.loadByInstanceUID(insUid) " failed with the error code " DICOM Plugin failed: tuple index out of range ", deatiled info added in below.
3. can only just display 3d view full screen with rendering tools, not other frame or view is need

error info:  
File “H:\Program Files (x86)\Slicer 5.1.0-2022-06-21\lib\Slicer-5.1\qt-scripted-modules\DICOMLib\DICOMUtils.py”, line 744, in getLoadablesFromFileLists  
loadablesByPlugin[plugin] = plugin.examineForImport(fileLists)  
File “H:/Program Files (x86)/Slicer 5.1.0-2022-06-21/bin/…/lib/Slicer-5.1/qt-scripted-modules/DICOMScalarVolumePlugin.py”, line 151, in examineForImport  
loadablesForFiles = self.examineFiles(files)  
File “H:/Program Files (x86)/Slicer 5.1.0-2022-06-21/bin/…/lib/Slicer-5.1/qt-scripted-modules/DICOMScalarVolumePlugin.py”, line 175, in examineFiles  
seriesUID = slicer.dicomDatabase.fileValue(files[0],self.tags[‘seriesUID’])  
IndexError: tuple index out of range  
DICOM Plugin failed: tuple index out of range  
Traceback (most recent call last):  
File “H:\Program Files (x86)\Slicer 5.1.0-2022-06-21\lib\Slicer-5.1\qt-scripted-modules\DICOMLib\DICOMUtils.py”, line 748, in getLoadablesFromFileLists  
loadablesByPlugin[plugin] = plugin.examine(fileLists)  
File “H:/Program Files (x86)/Slicer 5.1.0-2022-06-21/bin/…/lib/Slicer-5.1/qt-scripted-modules/MultiVolumeImporterPlugin.py”, line 119, in examine  
loadables += self.examineFilesIPPAcqTime(files)  
File “H:/Program Files (x86)/Slicer 5.1.0-2022-06-21/bin/…/lib/Slicer-5.1/qt-scripted-modules/MultiVolumeImporterPlugin.py”, line 357, in examineFilesIPPAcqTime  
desc = slicer.dicomDatabase.fileValue(files[0],self.tags[‘seriesDescription’]) # SeriesDescription  
IndexError: tuple index out of range  
DICOM Plugin failed: tuple index out of range  
Traceback (most recent call last):  
File “”, line 1, in   
File “H:\Program Files (x86)\Slicer 5.1.0-2022-06-21\lib\Slicer-5.1\qt-scripted-modules\DICOMLib\DICOMUtils.py”, line 263, in loadByInstanceUID  
return loadLoadables(filteredLoadablesByPlugin)  
File “H:\Program Files (x86)\Slicer 5.1.0-2022-06-21\lib\Slicer-5.1\qt-scripted-modules\DICOMLib\DICOMUtils.py”, line 770, in loadLoadables  
if loadable.selected:  
AttributeError: ‘NoneType’ object has no attribute ‘selected’

---

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [June 28, 2022, 3:27am UTC](https://discourse.slicer.org/t/show-3d-reconstruction-rendered-by-slicer-in-a-web-browser/24045/16 "2022-06-28T03:27:47Z")

</div>

I found another question in WebServer  
if a patient has many studies, I want to load one of studies use study id as a node to watch, but source file DICOMUtils.py did not implement this. wish for your answering.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 28, 2022, 3:45am UTC](https://discourse.slicer.org/t/show-3d-reconstruction-rendered-by-slicer-in-a-web-browser/24045/17 "2022-06-28T03:45:42Z")

</div>

If you load a DICOM study via DICOMweb then you can specify the study UID:

```
slicer.app.openUrl("slicer://viewer/?studyUID=2.16.840.1.113669.632.20.121711.10000155501&access_token=eyJhbGciO...SC1NR0GA&dicomweb_endpoint=https%3A%2F%2Fdemo.kheops.online%2Fapi&dicomweb_uri_endpoint=https%3A%2F%2Fdemo.kheops.online%2Fapi%2Fwado"

```

If you load from a folder then you can load a specific study or series, the same way as it is done in `loadPatientByUID`:

> <https://github.com/Slicer/Slicer/blob/23744ee0e374928b76dc4c1209faa07377bee518/Modules/Scripted/DICOMLib/DICOMUtils.py#L62-L79>

---

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [June 28, 2022, 5:50am UTC](https://discourse.slicer.org/t/show-3d-reconstruction-rendered-by-slicer-in-a-web-browser/24045/18 "2022-06-28T05:50:10Z")

</div>

I had read this code yet , does that mea I need to code this part ,and the push to you main repo? or will your team add this function in later version?

---

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [June 28, 2022, 5:50am UTC](https://discourse.slicer.org/t/show-3d-reconstruction-rendered-by-slicer-in-a-web-browser/24045/19 "2022-06-28T05:50:28Z")

</div>

I had read this code yet , does that mea I need to code this part ,and the push to you main repo? or will your team add this function in later version?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [June 28, 2022, 12:22pm UTC](https://discourse.slicer.org/t/show-3d-reconstruction-rendered-by-slicer-in-a-web-browser/24045/20 "2022-06-28T12:22:11Z")

</div>

You can do everything you describe in your own code. No need to add anything to our repository unless you develop some helper utilities that others might find useful.

You can look for slicerrc.py to find how to script the startup behavior of Slicer and can start/configure the WebServer module from there. You can also program the dicom module to retrieve / load data and can customize the rendering. @lassoan and I are busy this week with [Project Week](https://projectweek.na-mic.org/PW37_2022_Virtual/) and may not have time to provide details, but if you join Project Week you can find people to discuss your use case and help.
