Commit f79a64b6 authored by Franziska Koehn's avatar Franziska Koehn
Browse files

functions and files for reading search-types and their fields from file added

parent c44822d4
{"root-type":"xnat:mrScanData",
"fields":[
{"label":"type", "field":"xnat:mrScanData/TYPE"},
{"label":"fov_x", "field":"xnat:mrScanData/PARAMETERS_FOV_X"},
{"label":"fov_y", "field":"xnat:mrScanData/PARAMETERS_FOV_Y"},
{"label":"tr", "field": "xnat:mrScanData/PARAMETERS_TR"},
{"label":"te", "field": "xnat:mrScanData/PARAMETERS_TE"},
{"label":"ti", "field": "xnat:mrScanData/PARAMETERS_TI"},
{"label":"flip", "field": "xnat:mrScanData/PARAMETERS_FLIP"},
{"label":"voxel_res_x", "field":"xnat:mrScanData/PARAMETERS_VOXELRES_X"},
{"label":"voxel_res_y", "field":"xnat:mrScanData/PARAMETERS_VOXELRES_Y"},
{"label":"voxel_res_z", "field":"xnat:mrScanData/PARAMETERS_VOXELRES_Z"}
]
}
......@@ -38,18 +38,52 @@ def main(host):
else:
print "download canceled"
def read_json_from_file():
pass
def get_data_types():
from os import listdir
from os.path import isfile, join
import json
DIR = 'datatypes/'
files = [ f for f in listdir(DIR) if isfile(join(DIR,f)) ]
for file in files:
with open(join(DIR,file)) as f:
try:
yield json.loads(f.read())['root-type']
except ValueError:
yield None
def get_fields_of_type(type):
from os import listdir
from os.path import isfile, join
import json
DIR = 'datatypes/'
files = [ f for f in listdir(DIR) if isfile(join(DIR,f)) ]
for file in files:
with open(join(DIR,file)) as f:
try:
t = json.loads(f.read())
if t['root-type'] == type:
return t['fields']
except ValueError:
pass
def get_search_fields():
return [{'label':'type', 'field':'xnat:mrScanData/TYPE'},
{'label':'fov_x', 'field':'xnat:mrScanData/PARAMETERS_FOV_X'},
{'label':'fov_y', 'field':'xnat:mrScanData/PARAMETERS_FOV_Y'},
{'label':'tr', 'field': 'xnat:mrScanData/PARAMETERS_TR'},
{'label':'te', 'field': 'xnat:mrScanData/PARAMETERS_TE'},
{'label':'ti', 'field': 'xnat:mrScanData/PARAMETERS_TI'},
{'label':'flip', 'field': 'xnat:mrScanData/PARAMETERS_FLIP'},
{'label':'voxel_res_x', 'field':'xnat:mrScanData/PARAMETERS_VOXELRES_X'},
{'label':'voxel_res_y', 'field':'xnat:mrScanData/PARAMETERS_VOXELRES_Y'},
{'label':'voxel_res_z', 'field':'xnat:mrScanData/PARAMETERS_VOXELRES_Z'}
]
import json
return json.loads("""[{"label":"type", "field":"xnat:mrScanData/TYPE"},
{"label":"fov_x", "field":"xnat:mrScanData/PARAMETERS_FOV_X"},
{"label":"fov_y", "field":"xnat:mrScanData/PARAMETERS_FOV_Y"},
{"label":"tr", "field": "xnat:mrScanData/PARAMETERS_TR"},
{"label":"te", "field": "xnat:mrScanData/PARAMETERS_TE"},
{"label":"ti", "field": "xnat:mrScanData/PARAMETERS_TI"},
{"label":"flip", "field": "xnat:mrScanData/PARAMETERS_FLIP"},
{"label":"voxel_res_x", "field":"xnat:mrScanData/PARAMETERS_VOXELRES_X"},
{"label":"voxel_res_y", "field":"xnat:mrScanData/PARAMETERS_VOXELRES_Y"},
{"label":"voxel_res_z", "field":"xnat:mrScanData/PARAMETERS_VOXELRES_Z"}
]""")
def get_query_methods():
return ["AND", "OR"]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment