vkt1414 / slicer-idc-viewer

A custom loadable script enabling viewing of IDC data in a locally installed 3D Slicer app
MIT License
0 stars 0 forks source link

Automate registration of slicer:// on ubuntu #1

Open pieper opened 6 months ago

pieper commented 6 months ago

Nice work @vkt1414 ๐Ÿ‘

It would be great if you could simplify this for users by automatically registering the URL handler. Probably this could be integrated with the SlicerIDCBrowser extension or we could do it automatically as part of the Slicer install like it is in windows.

Note that from python you can use slicer.app.applicationDirPath() so the user doesn't need to enter the path (which could be error prone).

https://github.com/vkt1414/slicer-idc-viewer/blob/599453b491dbe1b7e6ffe0217409d9749ec5785a/register_slicer_protocol.sh.edit#L7

As an aside it would be great to investigate doing the same on MacOS.

vkt1414 commented 6 months ago

Thank you @pieper!

I think I see your point. If I understand correctly, whenever someone installs the SlicerIDCBrowser, we'll handle the registration of the slicer:// automatically. I'll try it on Ubuntu first.

I do not have a Mac to test but I'll borrow one in the lab to automate this on Mac too. There are well-defined instructions for Mac on the internet. So it should be possible.

I found this is where Slicer is registering on Windows. If registering slicer:// works well in IDCBrowser for Ubuntu and MacOS, we can try to incorporate it in slicer. I found the feature to be extremely useful. https://github.com/Slicer/Slicer/blob/2f04e07a57b4565127864bde603265181cc01a49/Modules/Scripted/DICOMLib/DICOMUtils.py#L1027

Looking forward to your guidance on making this feature better.

@fedorov can I move this repo to IDC?

fedorov commented 6 months ago

Probably this could be integrated with the SlicerIDCBrowser extension or we could do it automatically as part of the Slicer install like it is in windows.

That's exactly what I suggested when we discussed this yesterday! :-D

But @pieper can you advice (I admit I have not studied the code) - is it possible and acceptable to change the handler from "viewer" to "idc-browser" (for example) to make it explicit that 1) a specific component of Slicer is responsible for opening this URL; and 2) the data is coming from IDC? Can we "route" this request to SlicerIDCBrowser?

Maybe it's easier to discuss this when you are back and also at the PW to coordinate with @lassoan.

can I move this repo to IDC?

Instead, can we reconcile the content of this repo with SlicerIDCBrowser? I do not see the need for a new repository. If you are concerned about making this part of the deployed extension, it can go into a branch and live in a draft PR.

pieper commented 6 months ago

is it possible and acceptable to change the handler from "viewer" to "idc-browser" (for example)

Yes, I think there's room for expanding the URL to be more explicit about what handlers are expected to be able to handle a specific URL pattern. It could be a different route, as you suggest @fedorov (i.e. using "slicer://idc-browser" instead of the generic "slicer://viewer" for links that should be handled by that specific module so that module-specific URL parameters can be passed). It would be good to investigate any other software that works like this to see what conventions there are and what limits the browsers impose.

vkt1414 commented 6 months ago

Great. I'll then work towards registering slicer://idc-browser to work with SlicerIDCBrowser and make this repo code part of it.

lassoan commented 6 months ago

You can use any url path. If you use slicer://viewer then the DICOM module will recognize it and will load the study in the viewers using DICOMweb protocol. However, you can very easily add handlers in your module that recognize some other URL paths and do something special (e.g., if you don't want to use DICOMweb or you don't want to load the image just highlight it in the IDC browser).

vkt1414 commented 6 months ago

Thank you Dr @lassoan!

Also, your guide here was so helpful to get started on this feature for IDC, that Steve had in mind for some time!

How to load nifti file from web browser link? - Development - 3D Slicer Community SlicerSandbox/LoadRemoteFile/LoadRemoteFile.py at master ยท PerkLab/SlicerSandbox (github.com)

lassoan commented 6 months ago

You may find this useful, too: detailed description of how to register custom URL handlers on Windows, macOS, and linux.

https://web.archive.org/web/20200618072827/https://support.shotgunsoftware.com/hc/en-us/articles/219031308-Launching-Applications-Using-Custom-Browser-Protocols