Closed kmader closed 7 years ago
fixed by making a new 'robust' read function which automatically removes these lines
def patch_json(in_jsontxt):
"""
Remove DICOM tags from a JSON file
Created explicitly for the new data from files like
/Volumes/USBData/LungStage_PET/AnnotationResults/slicer_data/day8/TNM_StagingD20170210T160708859006_by_Alex_of_ACC24479266/lsa.json
:param in_jsontxt:
:return:
Examples
>>> patch_json(_kill_tag_bad_json).strip()
'{"ct_header": [[[24, 4096], "DeviceSerialNumber", [-1, "LO", 6, "31023 ", 1820, false, true]]], "name": "bob"}'
"""
return re.sub('\([\w\n]{4}, [\w\n]{4}\)', '', in_jsontxt) # remove all dicom-like keys
The JSON files produced when including the dicom header are invalid due to a bug in the json library see https://www.na-mic.org/Bug/view.php?id=4342