Testing I/O of JSONs

for eventually creating config files to drive fMRI analysis


In [2]:
import json

In [3]:
con = 'cdmainrel'
tt='CD'
debug = True
write = False
roi = 'grayMatter'
dstype = 'raw'
r = 4  # searchlight radius
sg_params = [119, 2]

In [4]:
analysisConfig = {'con': 'cdmainrel', 'tt': 'CD', 'write': 'False', 'roi': 'grayMatter', 'dstype': 'raw', 'r': 4, 'sg_params': [119, 2]}

In [11]:
json.dumps([analysisConfig, analysisConfig, analysisConfig])


Out[11]:
'[{"roi": "grayMatter", "sg_params": [119, 2], "dstype": "raw", "tt": "CD", "write": "False", "r": 4, "con": "cdmainrel"}, {"roi": "grayMatter", "sg_params": [119, 2], "dstype": "raw", "tt": "CD", "write": "False", "r": 4, "con": "cdmainrel"}, {"roi": "grayMatter", "sg_params": [119, 2], "dstype": "raw", "tt": "CD", "write": "False", "r": 4, "con": "cdmainrel"}]'

In [12]:
newAnalysisConfig = json.loads(json.dumps([analysisConfig, analysisConfig, analysisConfig]))

In [13]:
newAnalysisConfig[0]


Out[13]:
{u'con': u'cdmainrel',
 u'dstype': u'raw',
 u'r': 4,
 u'roi': u'grayMatter',
 u'sg_params': [119, 2],
 u'tt': u'CD',
 u'write': u'False'}

Seems like we can just save all the arguments as a dict of dicts... easy!

Necessary fields:

  1. Analysis parameters

  2. File paths

  3. Write paths

  4. Complicated stuff (like cross validation, etc...) solve with pickle? how to set these up? with Jupyter notebook?


In [8]:
type(analysisConfig) == dict


Out[8]:
True

In [ ]: