How to import .json or .txt file markup file

Hi there. How do you import a .json or .txt file to use as a markup file?
I am quite new to Slicer, so a simple clear answer would be much appreciated.

When I drag and drop the json or txt file into Slicer, or else go through the load data button in Slicer, I get a ‘failed to load’ error message.

This file is a simple .txt file with four columns representing the label and x, y, z coordinates for a range of electrodes to be used with/superimposed on a brain CT scan.

The json file is created simply by changing the file type manually from .txt to .json.
I don’t mind whether I used the .txt or the .json file. My whole aim here is simply to import these x,y,z electrode coordinates rather than create the markup file manually inside 3dSlicer.

Any help much appreciated.



I think you may need to edit your file according to this documentation

Hope it helps

Thanks for this. I have re written my electrode position markup file in the format suggested for a .json file. This markup file successfully loads into Slicer on Windows, but not on Slicer on my Mac.
Any suggestions?

The following is an abbreviation of the script used:

{“@schema”: “”,
“markups”: [{“type”: “Fiducial”, “coordinateSystem”: “LPS”, “controlPoints”: [
{ “label”: “A”, “position”: [ 230.000000 , 255.000000 , 173.000000 ]},
{ “label”: “A1”, “position”: [ 254.000000 , 250.000000 , 131.000000 ]},
{ “label”: “B”, “position”: [ 281.000000 , 250.000000 , 177.000000 ]},
{ “label”: “B1”, “position”: [ 264.000000 , 249.000000 , 133.000000 ]},

you should be able to test if your file or string is json-valid using:

import json
dataDictionary = json.loads(yourString)

Please check the json module python documentation. A json markups file should be valid in any OS. Also you could create some fiducials with Slicer GUI as test data, save it and open the file on a text editor to see where the error is compared with the file you crafted

Hope it helps