Newer
Older
notebooks / behaverse / validators / nback.schema.json
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "http://xcit.org/nback.schema.json",
  "title": "Behaverse N-back Dataset",
  "description": "A list of events collected using Behaverse N-back task.",
  "type": "array",
  "items": {
    "$ref": "#/definitions/Event"
  },
  "definitions": {
    "Event":{
      "title": "A N-back Event",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "base": { "$ref": "#/definitions/Base" },
        "types": { "$ref": "#/definitions/Types" },
        "custom": { "$ref": "#/definitions/Custom" }
      },
      "required": ["base", "types", "custom"]
    },
    "Base":{
      "title": "Basic N-back Event Data",
      "type": "object",
      "properties": {
        "tsGenerated": {
          "type": "string",
          "format": "date-time"
        },
        "userId": {
          "type": "string",
          "format": "uuid"
        },
        "sessionId": {
          "type": "string",
          "format": "uuid"
        }
      },
      "required": ["tsGenerated", "userId", "sessionId"]
    },
    "Types":{
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string"
      }
    },
    "Custom":{
      "type": "object",
      "$comment": "extract custom keys using this JQ query: '[.[] | .custom | keys | .[]] | unique | sort'",
      "properties": {
        "accuracy": {"type": "number"},
        "buttons": {"type": "array"},
        "correctRejectionCount": {"type": "number"},
        "falseAlarmCount": {"type": "number"},
        "gameObject": {"type": "string", "enum": ["Button"]},
        "hitCount": {"type": "number", "minimum": 0},
        "id": {"type": "number"},
        "isMatch": {"type": "boolean"},
        "missCount": {"type": "number", "minimum": 0},
        "name": {"type": "string"},
        "parameters": {"type": "object"},
        "pressDuration": {"type": "number"},
        "pressTime": {"type": "string", "format": "date-time"},
        "responseDuration": {"type": ["number", "null"]},
        "responseTime": {"type": ["number", "null"]},
        "seed": {"type": "number"},
        "stream": {"type": "number"},
        "streamIndex": {"type": "number"},
        "streamResults": {"type": "array"},
        "timeline": {"type": "string"},
        "timeOutCount": {"type": "number", "minimum": 0},
        "type": {"type": "string", "enum": [null, "Game", "Instructions"]},
        "value": {"type": ["number", "null"]},
        "viewportPosition": { "$ref": "#/definitions/XY_Position" },
        "worldPosition": { "$ref": "#/definitions/XY_Position" }
      },
      "additionalProperties": true,
      "anyOf": [
        {
          "if": {
            "properties": {"types": {"enum": ["NBack.TaskStart"]}}
          },
          "then": {
            "required": ["timeline", "seed"]
          }
        },
        {
          "if": {
            "properties": {
              "types": {"enum": ["NBack.BlockStart"]}
            }
          },
          "then": {
            "required": ["id", "type"]
          }
        },
        {
          "if": {
            "properties": {"types": {"enum": ["NBack.BlockEnd"]}},
            "$comment": "jq command to extract required parameters: [.[] | select(.types | .[] | contains(\"NBack.BlockEnd\")) | .custom | keys] | unique | .[][]"
          },
          "then": {
            "required": ["id","type","name","seed","accuracy","hitCount","missCount", "falseAlaram", "correctRejectionCount", "timeOutCount"]
          }
        },
        {
          "if": {
            "properties": {"types": {"enum": ["NBack.TaskEnd"]}}
          },
          "then": {
            "required": []
          }
        },
        {
          "if": {
            "properties": {"types": {"enum": ["NBack.TrialEnd"]}}
          },
          "then": {
            "required": []
          }
        },
        {
          "if": {
            "properties": {"types": {"enum": ["NBack.TrialStart"]}}
          },
          "then": {
            "required": ["id", "seed"]
          }
        },
        {
          "if": {
            "properties": {"types": {"enum": ["NBack.MatchingButtonClick"]}}
          },
          "then": {
            "required": ["worldPosition", "viewportPosition", "pressTime", "pressDuration", "isMatch", "streamIndex", "responseTime"]
          }
        }
      ]
    },
    "XY_Position": {
      "title": "XY Spatial Position",
      "type": ["null", "object"],
      "additionalProperties": false,
      "properties": {
        "x": {"type": "number"},
        "y": {"type": "number"}
      },
      "required": ["x", "y"]
    },
    "InstructionCustom": {
      "title": "Custom element for instruction blocks",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {"type": "number"},
        "type": {"type": "string", "enum": ["Instruction"]}
      },
      "required": ["id", "type"]
    }
  }
}