Paraview Glance - loading multiple files

Hi,

I am customizing PV Glance to add to our app, something that we struggle with is to load multiple datasets with different color maps pre-set at load.
We were able to add custom features inside the code that we can change the colormap during load, but how can we pass multiple files with different settings to the app?

Thanks

The way to go is to load a single *.glance file that can refer to other remote dataset while enabling to configure any rendering settings, color, representations and views…

Sebastien,

Thank you so much for the response. I’ve spent last a few days trying to figure out the structure of the glance file but I couldnt find any reference. Can you please share a resource to help me build the glance file inside my python code? Because we need to build that inside our code.
Thanks

The way to go is to load 1 remote dataset, tune the UI the way you want and save the state (*.glance) file.
At that point, you unzip that glance file and look at the JSON structure of the file. That file should be fairly simple to follow. And from your learning, you should be able to add as many remote dataset as you want with all the required tuning you may be looking for. You can always start with the glance files available here.

Sebastien,

Thank you so much, this is exactly what I was looking for. Using this template I can easily change the UI setting, now the question would be can I give nii.gz url inside this JSON or should I put the vtk array in it directly? If I can just put url in it, can you please provide an example. All examples you have are using Girder to load file, I am trying to load file from source directly.

Thanks for the help

Just the url. Girder is still using just a url that looks weird, but it is still just a url for an HTTP Get request.

What do you mean by loading file from source? Since you are on the web, you need to be able to download your file from a URL.

I meant URL, I think I got it, thank you so much, I will let you know if I have any difficulties

Sebastian,

I’ve edited the source section of the JSON file into the following:
“sources”:
[
{
“id”:“6”,
“group”:“Sources”,
“name”:“TrivialProducer”,
“props”:
{
“name”:“headAndNeck-HybridPrediction.nii”,
“type”:“vtkImageData”,
“dataset”:
{
“serializedType”:“girder”,
“provenance”:
{
“description”:"",
“meta”:{},
“name”:“Girder COVID19 Demo”,
“public”:true,
“notPublic”:false,
“apiRoot”:"~/GIT/pv-glance/static/"
},
“item”:
{
“itemName”:“headAndNeck-HybridPrediction.nii”
},
“meta”:{}
}
}
}
],

And I am getting the following error: Uncaught TypeError: source.getDataset(…).isA is not a function

Any ideas what’s my mistake?

It should be simpler than that. Load an external file using url and save a glance file. At that point the data does-not come from Girder and you will see how the url get used.

That’s my problem, when I am using url and save the state file, the entire file is paste there as vtk array. Basically the glance file, becomes a vtk array + UI settings.

@Forrest_Li it seems that a bug got introduced as the remote nature of the data was not kept like it use to in the glance output.

I don’t know if it still works but downloading an old glance file from v3.0.0, I found

    "sources": [
        {
            "id": "3",
            "props": {
                "name": "f1.obz",
                "dataset": {
                    "name": "f1.obz",
                    "url": "https://kitware.github.io/vtk-js-datasets/data/obj-mtl/Ferrari%20F1.zip"
                }
            }
        }
    ],

state.json (5.3 KB)

This is what I’ve wrote based on combination of COVID example and your code. I am still getting the same error:

Uncaught TypeError: source.getDataset(…).isA is not a function

Verified the remote bug. I’ve pushed a PR to fix it: https://github.com/Kitware/paraview-glance/pull/331

Thanks guys for the great help.

After a lot of different tries, I am still getting the glance file.

Are you still trying the state.json file you’ve attached in your previous post? Or are you re-generating your glance file via the save state button? if you’re using your aforementioned state.json file, you need to modify your sources object like so:

"id": "6",                 
"group": "Sources",        
"name": "TrivialProducer", 
"props": {                 
    "name": "test.nii",    
    "type": "vtkImageData",
    "dataset": {           
        "name": "test.nii",
        "url": "....."
    }                      

Easiest way is to still re-generate the glance file.

No I regenerated from a new installation. Basically I re-built the code on my computer and trying to export, gives me the same file as before. I made sure that I have the latest version as well.

It works for me when I use this URL: https://localhost:9999/?name=head-mr.vti&url=https://kitware.github.io/vtk-js-datasets/data/vti/head-binary-zlib.vti

I load it, save state, then I can load the resulting glance file and the dataset shows up. Can you provide more details as to what is the error you get now, if it’s different from before?