System: WIN 10
Slicer version: Slicer 5.0.3
Hi There,
I’m trying to save markups ROI node as a markups JSON file programmatically.
First, I added a markups ROI node to the 3d view using ‘Markups’ module manually.
And then, I saved the markups ROI node to a JSON file. I referenced the code snippet in the Script repository to do that: Save markups to file
As shown in the figure below, here is the code I executed in the Python console:
markupsNode = slicer.util.getNode('R')
slicer.util.saveNode(markupsNode, slicer.app.defaultScenePath + "/" + "MyMarkups.mrk.json")
However, When I trying to load the markups from the JSON file, the ROI cannot be reloaded into 3D view, it is displayed as a dot instead of the box:
Here is the JSON file automatically created by the code snippet (MyMarkups.mrk.json):
{
    "@schema": "https://raw.githubusercontent.com/slicer/slicer/master/Modules/Loadable/Markups/Resources/Schema/markups-schema-v1.0.3.json#",
    "markups": [
        {
            "type": "ROI",
            "coordinateSystem": "LPS",
            "coordinateUnits": "mm",
            "locked": false,
            "fixedNumberOfControlPoints": false,
            "labelFormat": "%N-%d",
            "lastUsedControlPointNumber": 1,
            "controlPoints": [
                {
                    "id": "1",
                    "label": "R-1",
                    "description": "",
                    "associatedNodeID": "",
                    "position": [-46.1154670715332, -0.0, -11.705148696899414],
                    "orientation": [-1.0, -0.0, -0.0, -0.0, -1.0, -0.0, 0.0, 0.0, 1.0],
                    "selected": true,
                    "locked": false,
                    "visibility": true,
                    "positionStatus": "defined"
                }
            ],
            "measurements": [
                {
                    "name": "volume",
                    "enabled": false,
                    "units": "cm3",
                    "printFormat": "%-#4.4g%s"
                }
            ],
            "display": {
                "visibility": true,
                "opacity": 1.0,
                "color": [0.4, 1.0, 0.0],
                "selectedColor": [0.9372549019607843, 0.34901960784313726, 0.3843137254901961],
                "activeColor": [0.4, 1.0, 0.0],
                "propertiesLabelVisibility": true,
                "pointLabelsVisibility": false,
                "textScale": 3.0,
                "glyphType": "Sphere3D",
                "glyphScale": 1.0,
                "glyphSize": 5.0,
                "useGlyphScale": true,
                "sliceProjection": false,
                "sliceProjectionUseFiducialColor": true,
                "sliceProjectionOutlinedBehindSlicePlane": false,
                "sliceProjectionColor": [1.0, 1.0, 1.0],
                "sliceProjectionOpacity": 0.6,
                "lineThickness": 0.2,
                "lineColorFadingStart": 1.0,
                "lineColorFadingEnd": 10.0,
                "lineColorFadingSaturation": 1.0,
                "lineColorFadingHueOffset": 0.0,
                "handlesInteractive": true,
                "translationHandleVisibility": true,
                "rotationHandleVisibility": false,
                "scaleHandleVisibility": true,
                "interactionHandleScale": 3.0,
                "snapMode": "toVisibleSurface"
            }
        }
    ]
}
I found that the JSON file is missing the following keys under the “markups”:
"roiType":,
"center": ,
"orientation": ,
"size": ,
"insideOut",
Why is this happening? How do I need to modify the code snippet so that it can automatically generates a full JSON file containing the above keys to be able to reload the ROI box in the 3d view?
Thank you very much!

