BICCN / cell-locator

manually align specimens to annotated 3D spaces
https://cell-locator.readthedocs.io
Other
19 stars 7 forks source link

Pretty-print annotation file #144

Closed jcfr closed 4 years ago

jcfr commented 4 years ago

Description

Annotation saved to a file are not saved in a file easily readable by a human.

**Expected format:***

{
    "markups": [
        {
            "markup": {
                "type": "ClosedCurve",
                "coordinateSystem": "LPS",
                "locked": false,
                "labelFormat": "%N-%d",
                "controlPoints": [
                    {
                        "id": "1",
                        "label": "MarkupsClosedCurve-1",
                        "description": "",
                        "associatedNodeID": "vtkMRMLScalarVolumeNode1",
                        "position": [
                            -7725.476777936878,
                            5071.924649397559,
                            -2858.6838622146615
                        ],
                        "orientation": [
                            -1,
                            0,
                            0,
                            0,
                            -1,
                            0,
                            0,
                            0,
                            1
                        ],
                        "selected": true,
                        "locked": false,
                        "visibility": true,
                        "positionStatus": "defined"
                    },
                    {
                        "id": "2",
                        "label": "MarkupsClosedCurve-2",
                        "description": "",
                        "associatedNodeID": "vtkMRMLScalarVolumeNode1",
                        "position": [
                            -8785.61316343005,
                            5514.035987881592,
                            -4251.158410257692
                        ],
                        "orientation": [
                            -1,
                            0,
                            0,
                            0,
                            -1,
                            0,
                            0,
                            0,
                            1
                        ],
                        "selected": true,
                        "locked": false,
                        "visibility": true,
                        "positionStatus": "defined"
                    },
                    {
                        "id": "3",
                        "label": "MarkupsClosedCurve-3",
                        "description": "",
                        "associatedNodeID": "vtkMRMLScalarVolumeNode1",
                        "position": [
                            -7732.355384361564,
                            5984.77667260136,
                            -4339.759187924226
                        ],
                        "orientation": [
                            -1,
                            0,
                            0,
                            0,
                            -1,
                            0,
                            0,
                            0,
                            1
                        ],
                        "selected": true,
                        "locked": false,
                        "visibility": true,
                        "positionStatus": "defined"
                    },
                    {
                        "id": "4",
                        "label": "MarkupsClosedCurve-4",
                        "description": "",
                        "associatedNodeID": "vtkMRMLScalarVolumeNode1",
                        "position": [
                            -6980.525470132225,
                            5682.868336976309,
                            -3371.0529631232225
                        ],
                        "orientation": [
                            -1,
                            0,
                            0,
                            0,
                            -1,
                            0,
                            0,
                            0,
                            1
                        ],
                        "selected": true,
                        "locked": false,
                        "visibility": true,
                        "positionStatus": "defined"
                    },
                    {
                        "id": "5",
                        "label": "MarkupsClosedCurve-5",
                        "description": "",
                        "associatedNodeID": "vtkMRMLScalarVolumeNode1",
                        "position": [
                            -6735.759199784232,
                            5461.593738502808,
                            -2856.7326570107934
                        ],
                        "orientation": [
                            -1,
                            0,
                            0,
                            0,
                            -1,
                            0,
                            0,
                            0,
                            1
                        ],
                        "selected": true,
                        "locked": false,
                        "visibility": true,
                        "positionStatus": "defined"
                    }
                ],
                "display": {
                    "visibility": true,
                    "opacity": 1,
                    "color": [
                        0.4,
                        1,
                        1
                    ],
                    "selectedColor": [
                        1,
                        0.5000076295109483,
                        0.5000076295109483
                    ],
                    "propertiesLabelVisibility": true,
                    "pointLabelsVisibility": false,
                    "textScale": 3,
                    "glyphType": "Sphere3D",
                    "glyphScale": 1,
                    "glyphSize": 5,
                    "useGlyphScale": true,
                    "sliceProjection": false,
                    "sliceProjectionUseFiducialColor": true,
                    "sliceProjectionOutlinedBehindSlicePlane": false,
                    "sliceProjectionColor": [
                        1,
                        1,
                        1
                    ],
                    "sliceProjectionOpacity": 0.6,
                    "lineThickness": 0.2,
                    "lineColorFadingStart": 1,
                    "lineColorFadingEnd": 10,
                    "lineColorFadingSaturation": 1,
                    "lineColorFadingHueOffset": 0,
                    "handlesInteractive": false,
                    "snapMode": "toVisibleSurface"
                }
            },
            "orientation": [
                0.9423723483536421,
                -0.10260749019479301,
                -0.3184431817677528,
                5686.499999999999,
                0.32619099971630533,
                0.49341126738558755,
                0.8063155417831328,
                -6574.999999999999,
                -0.07438943985890348,
                0.863722770437872,
                -0.49844677455532305,
                -3987.4999999999995,
                0,
                0,
                0,
                1
            ],
            "representationType": "spline",
            "thickness": 50
        }
    ],
    "currentId": 0,
    "referenceView": "Coronal",
    "ontology": "Structure",
    "stepSize": 24.999999999999996,
    "cameraPosition": [
        5864.945206940424,
        -50233.77100882346,
        -4015.7997990419617
    ],
    "cameraViewUp": [
        0,
        0,
        1
    ]
}

Current format:

{"markups": [{"markup": {"type": "ClosedCurve", "coordinateSystem": "LPS", "locked": false, "labelFormat": "%N-%d", "controlPoints": [{"id": "1", "label": "MarkupsClosedCurve-1", "description": "", "associatedNodeID": "vtkMRMLScalarVolumeNode1", "position": [-7725.476777936878, 5071.924649397559, -2858.6838622146615], "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"}, {"id": "2", "label": "MarkupsClosedCurve-2", "description": "", "associatedNodeID": "vtkMRMLScalarVolumeNode1", "position": [-8785.61316343005, 5514.035987881592, -4251.158410257692], "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"}, {"id": "3", "label": "MarkupsClosedCurve-3", "description": "", "associatedNodeID": "vtkMRMLScalarVolumeNode1", "position": [-7732.355384361564, 5984.77667260136, -4339.759187924226], "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"}, {"id": "4", "label": "MarkupsClosedCurve-4", "description": "", "associatedNodeID": "vtkMRMLScalarVolumeNode1", "position": [-6980.525470132225, 5682.868336976309, -3371.0529631232225], "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"}, {"id": "5", "label": "MarkupsClosedCurve-5", "description": "", "associatedNodeID": "vtkMRMLScalarVolumeNode1", "position": [-6735.759199784232, 5461.593738502808, -2856.7326570107934], "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"}], "display": {"visibility": true, "opacity": 1.0, "color": [0.4, 1.0, 1.0], "selectedColor": [1.0, 0.5000076295109483, 0.5000076295109483], "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": false, "snapMode": "toVisibleSurface"}}, "orientation": [0.9423723483536421, -0.10260749019479301, -0.3184431817677528, 5686.499999999999, 0.32619099971630533, 0.49341126738558755, 0.8063155417831328, -6574.999999999999, -0.07438943985890348, 0.863722770437872, -0.49844677455532305, -3987.4999999999995, 0.0, 0.0, 0.0, 1.0], "representationType": "spline", "thickness": 50}], "currentId": 0, "referenceView": "Coronal", "ontology": "Structure", "stepSize": 24.999999999999996, "cameraPosition": [5864.945206940424, -50233.77100882346, -4015.7997990419617], "cameraViewUp": [0.0, 0.0, 1.0]}

Proposed solution

json.dumps(dict_, sort_keys=True, indent=4)

How to Reproduce

  1. Start application
  2. Create annotation
  3. Save to file
jcfr commented 4 years ago

Closing. Fixed in https://github.com/BICCN/cell-locator/commit/ab29a68be78253b2260335a43dcb0fc6007bfb3a