-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: create idcbrowser:// protocol to interact with slicer #43
base: main
Are you sure you want to change the base?
Conversation
…DC request handler
use shell quote to be resilient to spaces in paths add acknowledgement text reformat code using black code formatter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for getting this working @vkt1414 👍
I haven't had a chance to try it, but I'm back from vacation now so we should be able to get a good version of this going. What I'd like to do is have you give a demo, possibly during the IDC meeting today or at some other convenient time and then walk through the python code.
The one thing I'm concerned about is the concept of the 'resolver script' -- at first review that seems to add extra complexity to me, but perhaps you can explain.
Sure @pieper I may or may not be able to join today's weekly as I have a dentist appointment. If I can join, I will show the demo today itself. As for the resolver script, it simply parses the idcbrowser:// URL entered by the user, and then passes along the request to the slicer webserver. We can definitely discuss more when we can meet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks cool - I'm looking forward to giving it a try 👍
Just a few questions/suggestions and then I think we should merge it for testing.
Yes, in the ideal world this should also include an uninstaller that resets everything. Then you could have a UI option to install and uninstall the feature, with the default being off in the testing phase. |
Another suggestion: in the |
Thanks @pieper for the review. I'll make suggested changes and test them.
I wish I knew qt to implement this..as I believe all we need is fetch and execute a script upon clicking a button in slicer extension UI. |
We can certainly invoke slicer if it is not running yet. I'll try to add that. Currently I do display a message when a series is downloaded and loaded into slicer. We can show something like if there is no instance of slicer web server running.
|
May I know the safety concerns? This feature does impact a regular user who just wants to browse |
IMHO, anything that modifies Registry on Windows has at least a potential for causing problems. To ease the rollout and reduce the risks, to me it would make sense to make this feature available for testing for those who want to enable it knowingly. We can enable it by default in a subsequent update. It does not need to be done by GUI - this could be a setting flag initialized in the Slicer config. |
You'd surprised that even though editing registry is locked on MGB official PCs with GUI, there were no issues modifying with code! I do not disagree with other points. And I have no idea about slicer config |
My thought would just to be the opposite of registering the custom protocol - just delete all the files and registry keys you create in the registration step. |
This is really nice! The only think I would change is to get user consent before permanently changing any computer configuration. Instead of silently calling |
Thanks @lassoan ! I really like this suggestion. |
@vkt1414 are you still working on this, do you plan to address the suggestion in #43 (comment) and suggestions from Steve? |
I would not be able to work on the Qt component anytime soon. It would be great if someone with qt expertise can take over that part. @LennyN95 suggestion to solve this was to create a file to record the state of the user's preference for two things, like a database.
Both of these will require qt components that I'm not familiar and will require significant time to able to implement |
Thanks for the update @vkt1414. We'll try to get someone with Slicer Qt development experience to work on this. |
It'd be also great if the user could specify the port the server is running on. Although conflicts are unlikely, giving the user a) feedback which port is occupied and b) the option to manually update this will provide transparency and allow to resolve any potential conflicts. |
We tested this branch with @ccosmin97 and @deepakri201 on mac. It worked for Deepa. When trying to open this URL idcbrowser://series/1.2.840.113654.2.55.154809705591242159075253605419469935510 I was prompted to open the app, but nothing happened in Slicer. I see the messages below in the python console, but nothing happens. Another note is that Slicer app does not become modal.
![]() Testing on Linux JetStream, I am getting this runtime error on startup, which makes sense, since ![]() After installing idc-index it worked in linux! |
These all sounds fixable, just a matter of investing some time in it. I'm happy to meet and discuss. We can use Slicer's Qt environment to give feedback to the user if something fails. The one piece of the process that needs to be implemented that's not a slicer-specific coding task is the functions to undo all the installation steps on each platform (i.e. removing any files and registry keys. If someone else takes on this task I could do the Slicer/Qt parts. |
I can help with undoing the changes, but will not be able to test until the weekend after the upcoming holiday weekend. But if someone would like to go ahead..we will need a function like this to remove the folder/files
|
@pieper I agree most should be easy to address, with the exception of the one where it just did not work for me on my mac as I described in the issue. I am not sure what is going on there. I will also test on Windows a bit later. |
From what you mentioned, slicer-app.app is already present on your system. Could you remove it and try again? as I currently do not overwrite if one is already present also is |
For configuring persistent properties, like whether the url handler is enabled or not, what port to use, and perhaps which slicer to run if there are multiples versions installed, we could use the |
This was a project born during PW 40 when @pieper once mentioned the idea of using Slicer just the way we use zoom. This post showed that it was indeed possible, and the current implementation is inspired from it, and the slicerio package.
See here for more discussion:
https://projectweek.na-mic.org/PW40_2024_GranCanaria/Projects/Launch3DslicerViaClickableUrlsForViewingIdcDataViaSliceridcbrowserAndIdcIndex/
https://discord.com/channels/843934857620357130/1197786173637132368
While the progress made during that PW was good, there was room for improvement as the previous approach was launching a new slicer instance with every URL request.
This PR aims to address some of the deficiencies. It is now possible to reuse the slicer instance. The key component to achieving this was using a web server. Significant progress was made during the next project week (PW41 at MIT) even though there was no official continuation of the project on the PW41 page. Once the webserver was able to handle
localhost
requests, the idcbrowser:// custom protocol was designed to launch a Python script (using PythonSlicer binary) that will parse the URL and send the requests to the slicer webserver.It's been tested on all three major OSs Ubuntu, Windows, and MacOS. On Ubuntu, only the Firefox browser works. On Windows and MacOS any browser can handle idcbrowser:// requests. However, localhost:2042/idc requests work seamlessly on any browser/OS and are also clickable. idcbrowser:// is not recognized as a URL in markdown due to security reasons. However, in MS Excel, hyperlinks were recognized as URLs.
Pending tasks are:
It took a village (huge thanks to @pieper, @lassoan, @jcfr, @fedorov, @deepakri201, and @ccosmin97) to get to this phase but this was a very cool project, and hope others can take it to further heights in the future.