The primary objective of this feature is to introduce support for JSON format to enable writing and reading the full MRML scene file and its nodes. This serves as preparatory work for:
With this setup, we would start a first step for future adoption and compatibility with standards like OpenUSD and real-time collaborative toolkits (e.g. Omniverse). For example, having MRML structured in JSON will make it much easier to convert nodes to OpenUSD.
Node Status Printing:
Nodes can now output their state in JSON format using the WriteJSONToString
method. For example, in the Python console:
crosshairNode.WriteJSONToString()
Output:
{
"Crosshair": {
"id": "vtkMRMLCrosshairNodedefault",
"name": "Crosshair",
"hideFromEditors": true,
"selectable": true,
"selected": false,
"singletonTag": "default",
"crosshairMode": "NoCrosshair",
"crosshairBehavior": "OffsetJumpSlice",
"crosshairThickness": "Fine",
"crosshairRAS": [0.0, 0.0, 0.0]
}
}
Node State Reading/Updating: Nodes can now read or update their state (either fully or partially) from a JSON string. For example:
a.ReadJSONFromString('{"Crosshair":{"crosshairRAS":[100.0,100.0,100.0]}}')
Scene-Level JSON Format Support: The format for the entire MRML scene is controlled by a macro:
vtkMRMLScene::SetUseJSONFormat(true);
When enabled, the scene file will be output in JSON format. For example, the attached sample file demonstrates the current output structure.
No response