{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "title": "CORA config file",
    "description": "Configuration file for CORA tool",
    "type": "object",
    "properties": {
        "cases": {
            "description": "Each object defines a case which can be run, which has title information and then the reference and simulation curves.",
            "type": "array",
            "items": {
                "type": "object",
                "additionalProperties": false,
                "required": [],
                "properties": {
                    "run_title": {
                        "description": "Case title will be used in curve names and graphs titles. It is recommended to use a unique channel identifier when running many analyses.",
                        "type": "string",
                        "pattern": "^[\\s\\S]*$"
                    },
                    "ref_id": {
                        "description": "The curve ID(s) of curves that are derived from experimental testing. If multiple curves are selected then the average curve will be used to perform the ratings calculation. Used to derive the 'reference curve.'",
                        "type": "array",
                        "minItems": 1,
                        "items": {
                            "type": "number",
                            "exclusiveMinimum": 0
                        }
                    },
                    "sim_id": {
                        "description": "The curve ID of the curve that originates from simulation.",
                        "type": "number",
                        "exclusiveMinimum": 0
                    }
                }
            }
        },
        "curve_output": {
            "description": "Adds curves from correlation calculation to your T/HIS session if true.",
            "type": "boolean",
            "default": true
        },
        "show_results_gui": {
            "description": "Shows results panel GUI if true.",
            "type": "boolean",
            "default": false
        },
        "file_output": {
            "description": "Outputs correlation results to a csv file if a file path is specified as a string; otherwise, can be set to false for no output.",
            "type": ["string", "boolean"],
            "pattern": "^.+.csv$",
            "default": false
        },
        "append": {
            "description": "If file output is on, results will be appended to the csv file instead of overwriting the csv file if true.",
            "type": "boolean",
            "default": true
        },
        "method": {
            "description": "The methodology used to perform the ratings calculation.",
            "type": "string",
            "enum": ["CORAplus 4.0.4", "ISO/TS 18571:2014", "ISO/TS 18571:2024", "ISO/TS 18571 Euro NCAP v1.0"],
            "default": "CORAplus 4.0.4"
        },
        "y_norm": {
            "description": "The absolute peak value of the reference curve. Either specify a value or 'extremum' to be calculated from the derived reference curve.",
            "type": ["string", "number"],
            "pattern": "^extremum$",
            "default": "extremum"
        },
        "t_step": {
            "description": "The initial time / sampling step to be assumed for both simulation and reference signals. A value of 0 will automatically calculate the step dependant on the value used for step_type. If 0, then it is automatically calculated, or if it is greater than zero, then it is explicitly set.",
            "type": "number",
            "minimum": 0,
            "default": 0
        },
        "pre_interp": {
            "description": "The evaluation interval is calculated based on the test curves alone. The test and simulation curves might have different sampling rates. If set checked/true the test curves will be interpolated, prior to the calculation of the evaluation interval, with a sampling rate that takes into account that of the simulation curve. 'yes' is consistent with the default CORA method. If 'no', there will be no interpolation of test curves if there are consistent steps and start/end points.",
            "type": "boolean",
            "default": true
        },
        "i_type": {
            "description": "Cubic spline interpolation type.",
            "type": "string",
            "enum": ["natural", "periodic", "linear"],
            "default": "natural"
        },
        "step_factor": {
            "description": "Factor to apply to the calculated or specified step for interpolation.",
            "type": "number",
            "default": 1.0
        },
        "step_type": {
            "description": "If the time step is to be determined automatically (i.e t_step = 0 ), then either the maximum or minimum value from the test and simulation curves can be used. 'max' is consistent with the default CORA method.",
            "type": "string",
            "enum": ["max", "min"],
            "default": "max"
        },
        "tmin": {
            "description": "The minimum time in which the rating is calculated. The reference and simulation curve are effectively truncated to these times. A value of 'automatic' will result in its calculation in accordance with the CORA method. A value of 'full' will result in the interval of evaluation starting at the first point of the curve.",
            "type": ["string", "number"],
            "pattern": "^automatic$|^auto$|^full$",
            "default_cora": "automatic",
            "default_iso": "full"
        },
        "tmax": {
            "description": "The maximum time in which the rating is calculated. The reference and simulation curve are effectively truncated to these times. A value of 'automatic' will result in its calculation in accordance with the CORA method. A value of 'full' will result in the interval of evaluation finishing at the last point of the curve.",
            "type": ["string", "number"],
            "pattern": "^automatic$|^auto$|^full$",
            "default_cora": "automatic",
            "default_iso": "full"
        },
        "a_thres": {
            "description": "Used in the automatic interval of evaluation calculation. It is used to determine the first point in time that the curve has an absolute value that is greater than or equal to y_norm x a_thres.",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.03
        },
        "b_thres": {
            "description": "Used in the automatic interval of evaluation calculation. It is used to determine the first point in time that the curve has an absolute value that is greater than or equal to y_norm x a_thres.",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.075
        },
        "a_eval": {
            "description": "Used in the automatic interval of evaluation calculation. The interval calculated using a_thres and b_thres is increased by an amount equal to the interval factored by a_eval at the start and end of the interval. e.g. a value of 0.0 results in no increase and a value of 0.5 doubles the interval of evaluation.",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.01
        },
        "b_delta_end": {
            "description": "Used in the automatic interval of evaluation calculation. If the test data has oscillations towards the end of the signal, the interval of evaluation can be be reduced to exclude these oscillations using this parameter. Working backwards from the end of the interval calculated using b_thres, the running maximum peak to peak amplitude is calculated. i.e. the difference between the most positive value considered so far, to the most negative value. When this amplitude value is greater than or equal to b_delta_end x YNORM this becomes the new 'end' of the interval. Note that if a_eval is greater than zero then this new interval will still be extended by a_eval multiplied by the interval originally derived from a_thres and b_thres.",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.2
        },
        "a_0": {
            "description": "Used in the Corridor rating calculation. y_norm is factored by this value to obtain the inner corridor half width. i.e. the inner, upper corridor is the reference curve value + y_norm x a_0. Similarly the inner, lower corridor is the reference curve value - y_norm x a_0. Note: the total inner corridor half width is the sum of all of all components calculated from a_0, a_1 and a_s. If you do not wish to include a component, set its parameter to a value of zero. ",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.05
        },
        "b_0": {
            "description": "Used in the Corridor rating calculation. y_norm is factored by this value to obtain the outer corridor half width. i.e. the outer, upper corridor is the reference curve value + y_norm x b_0. Similarly the outer, lower corridor is the reference curve value - y_norm x b_0. Note: the total outer corridor half width is the sum of all of all components calculated from b_0, b_1 and b_s. If you do not wish to include a component, set its parameter to a value of zero.",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.5
        },
        "a_1": {
            "description": "Used in the Corridor rating calculation. This value is the inner corridor half width. i.e. the inner, upper corridor is the reference curve value + a_1. Similarly the inner, lower corridor is the reference curve value - a_1. Note: the total inner corridor half width is the sum of all of all components calculated from a_0, a_1 and a_s. If you do not wish to include a component, set its parameter to a value of zero.",
            "type": "number",
            "default": 0.0
        },
        "b_1": {
            "description": "Used in the Corridor rating calculation. This value is the outer corridor half width. i.e. the outer, upper corridor is the reference curve value + b_1. Similarly the outer, lower corridor is the reference curve value - b_1. Note: the total outer corridor half width is the sum of all of all components calculated from b_0, b_1 and b_s. If you do not wish to include a component, set its parameter to a value of zero.",
            "type": "number",
            "default": 0.0
        },
        "a_sigma": {
            "description": "Used in the Corridor rating calculation. Only valid if multiple test curves are being used.  This value is the factor on the standard deviation (SD) that is used for the inner corridor half width. i.e. the inner, upper corridor is the reference curve value + a_s x SD (i.e. the standard deviation for this point in the reference curve). Similarly the inner, lower corridor is the reference curve value - a_s x SD. Note: the total inner corridor half width is the sum of all of all components calculated from a_0, a_1 and a_s. If you do not wish to include a component, set its parameter to a value of zero.",
            "type": "number",
            "default": 0
        },
        "b_sigma": {
            "description": "Used in the Corridor rating calculation. Only valid if multiple test curves are being used.  This value is the factor on the standard deviation (SD) that is used for the outer corridor half width. i.e. the outer, upper corridor is the reference curve value + b_s x SD (i.e. the standard deviation for this point in the reference curve). Similarly the outer, lower corridor is the reference curve value - b_s x SD. Note: the total outer corridor half width is the sum of all of all components calculated from b_0, b_1 and b_s. If you do not wish to include a component, set its parameter to a value of zero.",
            "type": "number",
            "default": 0
        },
        "k_c": {
            "description": "Used in the corridor rating calculation. Defines how severe the transition from a high rating to a low rating is. 1 is essentially linear, 2 is quadratic.",
            "type": "number",
            "default": 2.0
        },
        "k_z": {
            "description": "Used in the corridor rating calculation. Defines how severe the transition from a high rating to a low rating is. 1 is essentially linear, 2 is quadratic.",
            "type": "number",
            "default": 2
        },
        "sd_type": {
            "description": "Used in the corridor rating calculation. If a_s or b_s are greater than zero and multiple test curves are selected, then the standard deviation is calculated. Options for 'sample' and 'population' standard deviation calculation are available.",
            "type": "string",
            "enum": ["population", "sample"],
            "default": "sample"
        },
        "int_min": {
            "description": "Used in the cross correlation rating calculation. Represents the minimum overlap of the reference and simulation curves when shifting the curves. i.e a value of 0.7 means that 70% of the curves will overlap when the curve is shifted and the peak curve shift is given by (1-int_min) x (T_MAX-T_MIN).",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.8
        },
        "epsilon_p": {
            "description": "Used in the cross correlation rating calculation. Represents the minimum overlap of the reference and simulation curves when shifting the curves. i.e a value of 0.7 means that 70% of the curves will overlap when the curve is shifted and the peak curve shift is given by (1-int_min) x (T_MAX-T_MIN).",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.2
        },
        "epsilon_m": {
            "description": "Maximum allowable magnitude error for ISO18571",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.5
        },
        "d_min": {
            "description": "Used in the cross correlation rating calculation. Used to obtain the minimum amount of the interval of evaluation used when calculating the phase shift rating in accordance with the CORA method. i.e. d_min x (T_MAX - T_MIN).",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.01
        },
        "d_max": {
            "description": "Used in the cross correlation rating calculation. Used to obtain the maximum amount of the interval of evaluation used when calculating the phase shift rating in accordance with the CORA method. i.e. d_max x (T_MAX - T_MIN).",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.12
        },
        "k_v": {
            "description": "Used in the cross correlation rating calculation. Defines how severe the transition from a high rating to a low rating is for the progression rating.",
            "type": "number",
            "default": 10
        },
        "k_s": {
            "description": "Used in the cross correlation rating calculation. Defines how severe the transition from a high rating to a low rating is for the slope rating.",
            "type": "number",
            "default": 1
        },
        "k_p": {
            "description": "Used in the cross correlation rating calculation. Defines how severe the transition from a high rating to a low rating is for the phase shift rating.",
            "type": "number",
            "default": 1
        },
        "k_g": {
            "description": "Used in the cross correlation rating calculation. Defines how severe the transition from a high rating to a low rating is for the size rating.",
            "type": "number",
            "default": 1
        },
        "k_m": {
            "description": "Used in the cross correlation rating calculation. Defines how severe the transition from a high rating to a low rating is for the magnitude rating.",
            "type": "number",
            "default": 1
        },
        "g_v": {
            "description": "Used in the cross correlation rating calculation. The progression rating weighting factor.",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.5
        },
        "g_p": {
            "description": "Used in the cross correlation rating calculation. The phase rating weighting factor.",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.25
        },
        "g_g": {
            "description": "Used in the cross correlation rating calculation. The size rating weighting factor.",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.25
        },
        "w_s": {
            "description": "Used in the cross correlation rating calculation. The progression rating weighting factor.",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.2
        },
        "w_p": {
            "description": "Used in the cross correlation rating calculation. The phase rating weighting factor.",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.2
        },
        "w_m": {
            "description": "Used in the cross correlation rating calculation. The size rating weighting factor.",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.2
        },
        "g_1": {
            "description": "Used in the overall rating calculation. The slope weighting factor.",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.5
        },
        "g_2": {
            "description": "Used in the overall rating calculation. The cross correlation weighting factor.",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.5
        },
        "w_z": {
            "description": "Used in the overall rating calculation. The slope weighting factor.",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.4
        },
        "corridor_graph": {
            "description": "Creates a graph object with corridor rating visualisation if true.",
            "type": "boolean",
            "default": true
        },
        "correlation_graph": {
            "description": "Creates a graph object with cross correlation rating visualisation if true.",
            "type": "boolean",
            "default": true
        },
        "add_scores_to_title": {
            "description": "Adds correlation and corridor ratings to graph title(s) if true.",
            "type": "boolean",
            "default": true
        },
        "add_method_to_legend": {
            "description": "Adds rating method to graph legend(s) if true.",
            "type": "boolean",
            "default": true
        },
        "add_runtitle_to_curve_titles": {
            "description": "Adds run title to curve titles if true.",
            "type": "boolean",
            "default": true
        },
        "add_scores_to_legend": {
            "description": "Adds correlation and corridor ratings to graph legend(s) if true.",
            "type": "boolean",
            "default": true
        }
    },
    "additionalProperties": false,
    "required": ["method"]
}
