Extracting data from multiple JSON files.

I have multiple (14 to be exact) closed curve measurements for each scan (measurement of artery lumen). I ideally would like to extract the length, curvature mean, curvature max and area from each JSON file into excel.

I can do this manually as seen in the attached picture but doing so for each measurement takes 14 clicks so for each scan that will be 196 clicks with each bit of data on a separate sheet. Then I work out the averages.

I’m fine getting the data the long winded way already explained here and youtube. I was hoping there might be a quicker was to extract this data with a power query maybe but I have tried to search and attempt my own but with no luck.

Yes, unfortunately Excel’s json support is quite poor (requires lots of clicks).

If you want to copy measurements from many markups at once then you can write a short Python code snippet to scan for all the markups in the scene and copy all its measurements to the clipboard, so that you can paste them into Excel.

There is a full example in the script repository that you can customize it a bit (e.g., for getting curves, change it to getNodesByClass('vtkMRMLMarkupsCurveNode') and you can enable curvature mean and curvature max measurements in addition to length), and then copy-paste it to the Python console in Slicer.

To run this script automatically instead of manual copy-pasting, you can put it in the application startup script.

Many thanks for the quick reply. I did like the fact the JSON file is still connected to the data if it is updated it can be refreshed but your option will save me a huge amount of time. I have hundreds of patients to do quite quickly.

Thanks so much :slight_smile: