Are MRML node attributes saved and loaded by Sequences? My suspicion is that they are not. I tried adding attributes to an image and scrolling the Sequence Browser to new images. But the attributes stayed. I also tried recording a sequence of images with attributes, but as I’m replaying the sequence the attributes in the proxy node seem to remain unchanged.
What I wanted to do is record a sequence of segmentations (for a sequence of ultrasound images) and make note in the recorded nodes which original sequence index corresponded to them. I wanted to avoid duplicate segmentations by checking if the original sequence index has been saved in the segmentation sequence, and overwrite the segmentation if that same index already existed.
If attributes are not saved/loaded with sequences, what other option do I have to tag MRML nodes in a sequence?
@lassoan Is this possibly the read/write issue that tricked us when changing segmentations with each frame of video?
@ungi You may try playing with the checkboxes in the sequence browser or sequences module.
It seems that attributes have not been copied to/from the proxy node. I’ve fixed this now, so tomorrow you can try if it works as you would expect.
Thank you! I will test it tomorrow.
Today, attributes values are saved and replayed with sequences. Thank you!
However, I think there are two use case that is not handled correctly yet.
Attributes are not restored after saving and loading the scene.
I’ve created a sequence with different attribute values, and they were nicely replayed. Then I saved the scene, restarted Slicer, and reloaded the scene. The attribute value remained what it was when the scene was saved, but never changed anymore when the sequence was replayed.
If a proxy node has a new attribute, which did not exist when previous instances were saved in a sequence, I expect that attribute to be deleted when previous instances are replayed. Today, those attributes remain unchanged with replay, keeping “random” values from previous instances.
E.g. when I segment a recorded ultrasound sequence, I tag already segmented images with attributes before recording them in another sequence. I was planning to check if that attribute exists, to decide if the image has been previously segmented or not. But when I step to brand new instances (never segmented) in the input sequence, the attribute and its value remains in the proxy node, making it appear as if the image was already segmented.
I’ve tested this and it worked fine for me. If you change the attribute after you created the snapshot then you need to enable “Save node changes” (that’s what @adamrankin referred to above). If it still does not work then let me know.
I’ve fixed this, it should work well in Sequences extension installed/updated on Monday or later.
We have reviewed this with Andras offline. Turns out attributes are not saved in sequences when the proxy node is an image, because image sequences are saved in nrrd format. On the long run, probably all MRML node sequences should be able to preserve attributes when changed. But for now, we need to make sure attributes are only used in sequences that can preserve them. E.g. a sequence of segmentations is fine.