Embedding URI in a mrml scene file, for viewing the mrml scene on a remote slicer application

This is a sample .mrml scene file. It is having a local filepath embedded in it which points to the niftii file corresponding to a particular segmentation result shown in the mrml scene.

Is it possible to replace the path with a URI (universal resource identifier) of the “segmentation result niftii file” and sent this mrml scene file to a remote system, so that this same .mrml scene can be viewed on a “remote system slicer application” ? Will the slicer application of the remote system be able to download the niftii file mentioned in the URI ?


Like this

As @lassoan mentioned we used to have a feature like this in mrml, but it turned out to be messy and difficult to deal with security tokens/logins and similar issues in a generic way. If you really need something like this I’d suggest writing a python script that accepts a mrml file as input, detects URIs fileName fields, and downloads them to the local filesystem and replaces the URI with a local path so the user can load from there.

You can also use custom URLs to open a .nrrd file from a link directly Slicer using custom URL (slicer://). Slicer core has built-in handler for DICOMweb URIs, but you can add handlers for additional data types by adding a very short scripted module that recognizes the URL content and processes it. I provided an example for loading a .nrrd file and some description here.

@pieper What do you think about adding this module to Slicer core (changing it to allow open .mrb files and a few other common file formats; or allow it to open all supported file formats)?

If it helps solve a problem or facilitate a common use case then yes, it makes sense to have a module like that in the core.

@Rajesh_Ds for your scenario is it just the segmentation that you would like to download via URI or all the contents of the MRML scene (e.g. the background MR or CT).

Yes Steve, I would like to all contents, not just segmentation.

A practical way for many projects is to share .mrb files via dropbox or a similar service. There have been some problems reported when people save directly to a virtual drive, so best practice is to save to a local disk and then copy the files up to the cloud drive.

Is it possible to download a niftii file from an URI as follows ?

import requests
URL = “https://drive.google.com/file/d/1jnkq9TORuCRCvwWFXhUhxsgLs7bOIZeu/view?usp=sharing
response = requests.get(URL)
open(“abc.nii.gz”, “wb”).write(response.content)

See the source of ImportFromURL module in SlicerMorph. You need to have the correct storageNode to store the downloaded data (assuming your goal is not just to download but open it in Slicer).

@Rajesh_Ds Do we understand correctly that you want to avoid popping up of the web browser and doing an extra click there? If that’s the issue then the solution I described should work well. On Windows the Slicer installer already associates the slicer:// custom URL protocol with Slicer, so you just need to use the example file that I provided and change nrrd to mrb.

I have created a slicer scene .mrml file, using python code. The attached image shows one of the niftii file that takes part in the scene.

If I transfer this scene file to a remote system, where (which folder in his system) must the recipient at the remote system store these nifii files. Is it possible to make slicer pick the niftii file from any folder that he wishes by inserting appropriate path information in the above identified location in the .mrml file (please see the attached image above)