{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ngff.openmicroscopy.org/0.6.dev3/schemas/image.schema",
  "title": "Image",
  "description": "OME-Zarr image.",
  "type": "object",
  "properties": {
    "ome": {
      "description": "The versioned OME-Zarr Metadata namespace",
      "type": "object",
      "properties": {
        "omero": {
          "$ref": "#/$defs/omero"
        },
        "multiscales": {
          "$ref": "#/$defs/multiscales"
        },
        "version": {
          "$ref": "https://ngff.openmicroscopy.org/0.6.dev3/schemas/_version.schema"
        }
      },
      "required": [
        "multiscales",
        "version"
      ]
    }
  },
  "required": [
    "ome"
  ],
  "$defs": {
    "multiscales": {
      "description": "The multiscale datasets for this image",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "datasets": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "properties": {
                "path": {
                  "type": "string"
                },
                "coordinateTransformations": {
                  "type": "array",
                  "uniqueItems": true,
                  "items": {
                    "oneOf": [
                      {
                        "allOf": [
                          {"$ref": "https://ngff.openmicroscopy.org/0.6.dev3/schemas/coordinate_transformations.schema#/$defs/scale"},
                          {
                            "type": "object",
                            "properties": {
                              "input": {"type": "string"},
                              "output": {"type": "string"},
                              "name": {"type": "string"}
                            },
                            "required": ["input", "output"]
                          }
                        ]
                      },
                      {
                        "allOf": [
                          {"$ref": "https://ngff.openmicroscopy.org/0.6.dev3/schemas/coordinate_transformations.schema#/$defs/identity"},
                          {
                            "type": "object",
                            "properties": {
                              "input": {"type": "string"},
                              "output": {"type": "string"},
                              "name": {"type": "string"}
                            },
                            "required": ["input", "output"]
                          }
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {"const": "sequence"},
                          "transformations": {
                            "type": "array",
                            "items": {
                              "oneOf": [
                                {"$ref": "https://ngff.openmicroscopy.org/0.6.dev3/schemas/coordinate_transformations.schema#/$defs/scale"},
                                {"$ref": "https://ngff.openmicroscopy.org/0.6.dev3/schemas/coordinate_transformations.schema#/$defs/translation"}
                              ]
                            },
                            "minItems": 2,
                            "maxItems": 2
                          },
                          "input": {"type": "string"},
                          "output": {"type": "string"},
                          "name": {"type": "string"}
                        },
                        "required": ["type", "transformations", "input", "output"]
                      }
                    ]
                  },
                  "minItems": 1,
                  "maxItems": 1,
                  "description": "Multiscale transformations (identity/scale/sequence of scale and translation) from this dataset to the coordinate system specified by 'output'."
                }
              },
              "required": [
                "path",
                "coordinateTransformations"
              ]
            }
          },
          "coordinateSystems": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "https://ngff.openmicroscopy.org/0.6.dev3/schemas/coordinate_systems.schema#/$defs/coordinateSystem"
            }
          },
          "coordinateTransformations": {
            "type": "array",
            "minItems": 1,
            "items": {
              "allOf": [
                {
                  "$ref": "https://ngff.openmicroscopy.org/0.6.dev3/schemas/coordinate_transformations.schema#/$defs/coordinateTransformation"
                },
                {
                  "type": "object",
                  "properties": {
                    "input": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "path": {
                              "type": "string"
                            }
                          }
                        }
                      ]
                    },
                    "output": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "path": {
                              "type": "string"
                            }
                          }
                        }
                      ]
                    }
                  },
                  "required": [
                    "input",
                    "output"
                  ]
                }
              ]
            }
          }
        },
        "required": [
          "datasets",
          "coordinateSystems"
        ]
      },
      "minItems": 1,
      "uniqueItems": true
    },
    "omero": {
      "type": "object",
      "properties": {
        "channels": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "window": {
                "type": "object",
                "properties": {
                  "end": {
                    "type": "number"
                  },
                  "max": {
                    "type": "number"
                  },
                  "min": {
                    "type": "number"
                  },
                  "start": {
                    "type": "number"
                  }
                },
                "required": [
                  "start",
                  "min",
                  "end",
                  "max"
                ]
              },
              "label": {
                "type": "string"
              },
              "family": {
                "type": "string"
              },
              "color": {
                "type": "string"
              },
              "active": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "required": [
        "channels"
      ]
    }
  }
}
