Create json of node name and node number from annotation or atlas file

I am attempting to extract node names and node numbers from either an annotation file or from a volumetric atlas (I currently have both, so I’m open to whatever is easiest).

The resulting file should look something like the following:

  "gordon333": {
    "file": "gordon333MNI_lps_mni.nii.gz",
    "node_names": [
    "node_ids": [

and so on.

I would like to extract this in json format to run through QSI prep.

Any help on this would be greatly appreciated!

If you want to create the JSON using a shell script, jq is great for querying JSON and setting new variables in existing JSON and jo makes it easier to create pretty-printed JSON files from scratch

I anticipate using some python tool like json dumps…etc. However, my question is about loading in a Freesurfer annotation file and then extracting the ROIs and corresponding numbers from them.

Ah, NiBabel provides a function for reading .annot files that returns labels and names

1 Like