Proxy Node Attributes lost after scene load

I have created a sequence, sequence browser and proxy volume node. I gave the proxy volume node a whole bunch of attributes. However, after reloading the scene, the only attribute that is reloaded into the node is the Sequences.BaseName attribute.

Is this a bug? Is there a way to ensure that the node attributes will be preserved throughout scene save/reload?

Any help is greatly appreciated!

Here is how I initially set up the volume node:

volume = slicer.mrmlScene.AddNewNodeByClass(
    "vtkMRMLScalarVolumeNode",
    f"BMode_volume_{cineloop_number}",
)
volume.SetSpacing(bimg_spacing)
for name, parameter in params.items():
    volume.SetAttribute(name, str(parameter))
    volume.SetAttribute('SlicerExactVu.loadedAsType', 'Volume')
    volume.SetAttribute('SlicerExactVu.loadedFromPath', bimg_path)
    volume.SetAttribute('cineloop_number', cineloop_number)

At each step I updated its data using slicer.util.updateVolumeFromArray.

Paul

When a volume sequence is saved in .mrb format then all the attributes are preserved. However, currently saving of custom attributes is not implemented in the volume sequence reader, which saves the volume sequence in .seq.nrrd format. It would make sense to implement this - I’ve submitted a feature request to track this task:

We’ll probably need this for one of the funded projects at some point, but if you can make any contributions (ideally implement attribute saving/reading in the storage node) then it can happen sooner.

In the meantime, you can force saving into .mrb format (zip file containing each volume as a separate file and a .mrml file storing the node attributes) like this:

storageNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLSequenceStorageNode')
getNode('Sequence').SetAndObserveStorageNodeID(storageNode.GetID())

Thanks so much Andras, the suggested quick fix worked perfectly.

I unfortunately don’t have the bandwidth to help with the feature request right now, but i’ll pay attention in case I do get the time.

Paul

1 Like