Hi slicer experts,
I am working to load >100 .mgh files overlay model which I want to make a video for demo.
I can load the model by:
model = slicer.util.loadModel(‘lh.pial’)
But, how to load the surface file (.mgh) overlay the model. I tested these command but failed.
surface = slicer.util.loadScalarOverlay(‘lh_filed.mgh’)
I found the function (slicer.util.openAddScalarOverlayDialog()) works, but you had to select the (.mgh) file manually.
Is there a function can load .mgh automatically to overlay the loaded model?
(this above works on recent Slicer Preview Releases, for stable release, you need to specify returnNode=True for loadModel and it returns a success flag and a model node)
I’ll update slicer.util.loadScalarOverlay to take an optional model node ID.
Thanks, Iassoan.
I found it still cannot overlay.
I run as follows:
modelNode = slicer.util.loadModel('lh.pial', returnNode=True) % it can load the model to 3DSlicer, but I fount the modelNode did not have attribution GetID
slicer.util.loadNodeFromFile(overlayFilename, 'ScalarOverlayFile', {'modelNodeId': modelNode.GetID()})
% it failed.
The error message as follows:
AttributeError: ‘tuple’ object has no attribute ‘GetID’
Can you tell me how to deal with the problem? how to obtain the node ID as you said above?