SampleData to register sample data to be used in Slicer-Liver. Part of that data is 3D models, which don’t preserve the visual properties when saved as
.vtk models. Is there anyway to set up the visual properties of these models automatically when they are loaded again? Thanks!
You can use an .mrb file as sample data, which contains the VTK models and all the display properties. If you want you can keep only the model, storage, and display node in the .mrml file (in the mrb zip file) and remove everything else (such as layout node, slice nodes, etc. that would update a bunch of other things when the mrb file is loaded).
Thanks @lassoan. I wonder if it would be an option to add a new parameter in
SampleData.SampleDataLogic.registerCustomSampleDataSource with a list of setup functions to be called after the data is loaded.
See example in SampleData.py:
filePaths = logic.downloadFromSource(SampleDataSource( uris=TESTING_DATA_URL + 'SHA256/5a1c78c3347f77970b1a29e718bfa10e5376214692d55a7320af94b9d8d592b8', loadFiles=True, fileNames='slicer4minute.mrb'))
You need to set
loadFiles=True to load the .mrb file (by default it is only downloaded).
You can do this by specifying a custom loader function. I would not recommend to use it for modifying the loaded data, setting display properties, etc., as it would make the result hard to reproduce. The outcome would depend on both the data on the server and the loading script: two different locations, two different ways of specifying data.
I see. Thanks a lot @lassoan!