<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- 
     This is the scheme describing the storing of 
     manual segmentations of the myocardial perfusion series. 
     
     Copyright (c) Leipzig, Madrid 1999-2015 Gert Wollny
     
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 3 of the License, or
     (at your option) any later version.
     
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
     
     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     -->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <!-- definition of attributes -->
  <xs:attribute name="x" type="xs:decimal"/>
  <xs:attribute name="y" type="xs:decimal"/>
  <xs:attribute name="r" type="xs:decimal"/>
  <xs:attribute name="size" type="xs:decimal"/>
  <xs:attribute name="value" type="xs:integer"/>
  <xs:attribute name="version" type="xs:integer"/>
  <xs:attribute name="brightness" type="xs:decimal"/>
  <xs:attribute name="contrast" type="xs:decimal"/>
  <xs:attribute name="quality" type="xs:decimal"/>
  <xs:attribute name="image" type="xs:string"/>
  <xs:attribute name="color" type="xs:string"/>
  <xs:attribute name="open" type="xs:boolean"/>
  
  <!-- complex elements -->

  <!-- The 2D point used for the lines  
       Attributes:
       x,y: coordinates 
       size: reported size of the touch event. When using a mouse 
             or a stylus this will should be set to zero. 
  --> 
  <xs:element name="point">
    <xs:complexType>
      <xs:attribute ref="x" use="required"/>
      <xs:attribute ref="y" use="required"/>
      <xs:attribute ref="size"/>
    </xs:complexType>
  </xs:element>

  <!-- The star describing a simple approximation of the myocardium and 
       its separation into equal sized parts. 
       
       Attributes: 
       x,y: coordinates of the center 
       r: radius of the enclosing circle
       
       Elements are:
       3 points that define directions of six rays starting from the circle center, three 
       rays in the directions indicated by the points and three in the opposite direction.
       Of importance is te first ray as its intersection with the circle is set to indicate 
       the location of the RV-LV insertion point. 
  --> 
  <xs:element name="star">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="point" minOccurs="3" maxOccurs="3" /> 
      </xs:sequence>
      <xs:attribute ref="x" use="required"/>
      <xs:attribute ref="y" use="required"/>
      <xs:attribute ref="r" use="required"/>
    </xs:complexType>
  </xs:element>

  <!--
      A segmented image area. 
      
      Attributes: 
      color: the line color 
      open: true if the line is not closed, false if the line is closed. 
      
      Elements: 
      points that define the line. depending on the attribute "open" the last point 
      should or not should be connected to the first point when interpreting the line 
  -->  
  <xs:element name="section">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="point" minOccurs="3" maxOccurs="unbounded"/> 
      </xs:sequence>
      <xs:attribute ref="color" use="required"/>
      <xs:attribute ref="open"/>
    </xs:complexType>
  </xs:element>

  <!--
      A frame in a series of 2D images including its segmentation. 
      
      Attributes: 
      image: the name of the corresponding image file 
      quality: a subjective image quality rating
      brightness: brightness adjustment used for better visualization of the image 
      contrast; contrast  adjustment used for better visualization of the image 
      
      Elements: 
      star: the circle defined above describing the an approximation of the LV endocardium. 
      section: an abitraty number of segmented components. If two sections overlap, or
      one section is completely enclosed by another, then the proper approach to interpret the 
      segmentation is to combine the enclosed area by the XOR operation to obtain the full segmentation.
      
      Todo: 
      An interpretation attribute should probably be added to make the segmentations usable for other data. 
  -->
  <xs:element name="frame">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="star" minOccurs="0" maxOccurs="1"/> 
        <xs:element ref="section" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:attribute ref="image" use="required"/>
      <xs:attribute ref="quality"/>
      <xs:attribute ref="brightness"/>
      <xs:attribute ref="contrast"/>
    </xs:complexType>
  </xs:element>
  <!-- An element to indicate the right ventricle peak enhancement frame in a perfusion series 
       
       Attributes: 
       value: the index of the frame (0 = first frame) 
  -->   
  <xs:element name="RVpeak">
    <xs:complexType>
      <xs:attribute ref="value"/>
    </xs:complexType>
  </xs:element>

  <!-- An element to indicate the left ventricle peak enhancement frame in a perfusion series 
       
       Attributes: 
       value: the index of the frame (0 = first frame) 
  -->   
  <xs:element name="LVpeak">
    <xs:complexType>
      <xs:attribute ref="value"/>
    </xs:complexType>
  </xs:element>

  <!-- A description of the set 
       
       Elements: 
       RVpeak: see above 
       LVpeak: see above 
       PreferedRef: preferred reference frame for perfusion analysis
  -->   
  <xs:element name="description">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="RVpeak" maxOccurs="1" />
        <xs:element ref="LVpeak" maxOccurs="1" />
        <xs:element ref="PreferedRef" maxOccurs="1" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  
  <!-- The complete series 
       
       Attributes: 
       version: available for future reference
       
       Elements: 
       description: see above 
       frame:  an abitrary number of segmentation frames
  -->
  <xs:element name="workset">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="description" maxOccurs="1" />
        <xs:element ref="frame" maxOccurs="unbounded"/> 
      </xs:sequence>
      <xs:attribute ref="version"/>
    </xs:complexType>
  </xs:element>
</xs:schema>
