from typing import Dict
import json


def _read_prediction_variables(filename: str) -> Dict[str, int]:
    """Reads prediction variables from a JSON file."""
    with open(filename) as file_json:
        pred_vars = json.load(file_json)

    expected_keys = ('folder',
                     'path',
                     'file_ext',
                     'has_goldstd',
                     'path_goldstd',
                     'segmentation_interval',
                     'registered_path')

    for key in expected_keys:
        # if (key not in train_vars.keys()) or (not train_vars[key]):
        if (key not in pred_vars.keys()):
            raise RuntimeError(f'{key} is not defined in {filename}.')

    return pred_vars