<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"  xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.connectome.ch/2009/Connectome/xmlns" xmlns="http://www.connectome.ch/2009/Connectome/xmlns" xmlns:graphml="http://www.connectome.ch/Network" xmlns:xlink="http://www.w3.org/1999/xlink" elementFormDefault="qualified">

<xsd:annotation xml:lang="en">
    <xsd:documentation>
    Stephan Gerhard, Version 1.0
    </xsd:documentation>
</xsd:annotation>

<xs:complexType name="labelstype">
  
    <xs:attribute name="labelid" type="xs:string">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      The labelid uniquely defining the set of vertices labels in the given Gifti file.
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>

    <xs:attribute name="src" type="xs:string">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      The source of the surface (in the zipped CFF file), including the relative pathname to the Gifti/ folder
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>
    
    <xs:attribute name="fileformat" type="xs:string">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      So far, only Gifit formats (ending .gii) are supported. Write here "gifti"
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>
    
</xs:complexType>


<xs:complexType name="surfacetype">

    <xs:attribute name="name" type="xs:string">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      Descriptive name of the surface container, seen as a node in the Connectome Viewer TreeView
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>

    <xs:attribute name="src" type="xs:string">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      The source of the surface (in the zipped CFF file), including the relative pathname to the Gifti/ folder
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>
    
    <xs:attribute name="fileformat" type="xs:string">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      So far, only Gifit formats (ending .gii) are supported. Write here "gifti"
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>

    <xs:attribute name="addatlas" type="xs:string">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      This indicates, that an additional set of surfaces from this atlas is added
      to each network, e.g. for standardized visualization. ConnectomeViewer has
      the following atlases for species included:
      Homo sapiens:
      - template_atlas_homo_sapiens_01
        Extracted atlas from Freesurfer using fsaverage mesh
      - template_atlas_homo_sapiens_02 (not yet included)
        Possibly the SPL_PNL_Brain_Atlas2008
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>


  <xs:all>
    <xs:element name="surface-label" type="labelstype" minOccurs="0">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      Reference the to Gifti file containing the labels. In this Gifti file, the labelid for a particular NIFTI_INTENT_LABEL
      should be the same as the labelid as attibute of this element for the ConnectomeViewer to parse correctly
      </xsd:documentation>
    </xsd:annotation>
    </xs:element>
  </xs:all>
  
</xs:complexType>

<xs:complexType name="volumetype">
    <xs:attribute name="name" type="xs:string">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      Name of the volume
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>
    
    <xs:attribute name="src" type="xs:string">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      Including the relative pathname to the Nifti/ folder
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>
    
    <xs:attribute name="fileformat" type="xs:string">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      Roughly with what we have it to do, coforms to filename ending.
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>
    
    <xs:attribute name="segmentation" type="xs:boolean">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      If set to true, this means that the volume contains a segmentation labels, potentially used in conjuction with trackvis.
      Otherwise, this could be any other volume information, like raw MRI data.
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>
        
  <xs:all>
    <xs:element name="description" type="xs:string" minOccurs="0">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      Description of the content of the file, for example wheter it is raw MRI data or a segmentation.
      </xsd:documentation>
    </xsd:annotation>
    </xs:element>
  </xs:all>
</xs:complexType>

<xs:complexType name="tracktype">

<xs:complexType name="datakeyvaluetype">
    <xs:attribute name="key" type="xs:string">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      The key to be used later in the dictionary
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>
</xs:complexType>

    <xs:attribute name="name" type="xs:string">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      Name of the track
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>
    
    <xs:attribute name="src" type="xs:string">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      Including the relative pathname to the Tracks/ folder
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>
    
    <xs:attribute name="fileformat" type="xs:string">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      So far, only track files from the TrackVis suite with ending .trk are supported
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>
    
  <xs:all>
    <xs:element name="description" type="xs:string" minOccurs="0">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      Description of the content of the file, e.g tractography algorithms
      </xsd:documentation>
    </xsd:annotation>
    </xs:element>
    
  </xs:all>
</xs:complexType>
<xs:complexType name="nwmetadatatype">

  <xs:all>
    <xs:element name="data" type="datakeyvaluetype" minOccurs="0" maxOccurs="unbounded">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      A data element containing the key as attribute and the value as a tag
      </xsd:documentation>
    </xsd:annotation>
    </xs:element>
  </xs:all>
</xs:complexType>

<xs:complexType name="networkstype">

    <xs:attribute name="name" type="xs:string">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      The short name of the network as it appears in the ConnectomeViewer TreeView as node
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>
    
    <xs:attribute name="src" type="xs:string">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      The name of the network.graphml file in the package
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>
    
    <xs:attribute name="hierarchical" type="xs:boolean">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      Is the graph hierarchical, i.e. do nodes contain subgraphs (not yet supported)
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>
    
    <xs:attribute name="hypergraph" type="xs:boolean">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      Is the graph a hypergraph? (not yet supported)
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>
    
    <xs:attribute name="directed" type="xs:boolean">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      Is the graph directed? Should be the same value as in the corresponding GraphML file.
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>
    
  <xs:all>
  
          <xs:element name="network-surface" type="surfacetype" minOccurs="0" maxOccurs="unbounded">
          <xsd:annotation xml:lang="en">
            <xsd:documentation>
            All the surfaces corresponding to this network are stored in one Gifti file in the Gifti/ folder. Since the vertices id should be corresponding over all surfaces,
            the nodes in the GraphML file have an unique intensityvalue integer corresponding to a set of surface vertices. This information is stored in the label Gifti file.
           </xsd:documentation>
          </xsd:annotation>
          </xs:element>

          <xs:element name="network-metadata" type="nwmetadatatype" minOccurs="0" maxOccurs="1">
          <xsd:annotation xml:lang="en">
            <xsd:documentation>
            Often, there is particular metadata for networks one wants to use for later processing. For example one can annotate networks that represent subjects with
            information about being member of the control or test group. The very flexible schema of a dictionary (key/value pairs) is adopted to represent any kind of
            metadata. This is not typed yet and just uses strings for key and value.
           </xsd:documentation>
          </xsd:annotation>
          </xs:element>
        
          <xs:element name="network-volume" type="volumetype" minOccurs="0" maxOccurs="unbounded">
          <xsd:annotation xml:lang="en">
            <xsd:documentation>
            All the volumes found in the Nifti directory for this specific network. It is not yet clear how exactly they will be used by the ConnectomeViewer application
            </xsd:documentation>
          </xsd:annotation>
          </xs:element>
       
          <xs:element name="network-track" type="tracktype" minOccurs="0" maxOccurs="1">
          <xsd:annotation xml:lang="en">
            <xsd:documentation>
            The track file in the Tracks/ directory that were the basis for the networks, if any.
            </xsd:documentation>
          </xsd:annotation>
          </xs:element>

  </xs:all>
</xs:complexType>


<xs:complexType name="metadata">
  <xs:all>
   <xs:element name="generator" type="xs:string" minOccurs="0">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      Software version/Converter etc. this file was generated
      </xsd:documentation>
    </xsd:annotation>
  </xs:element>
  
   <xs:element name="initial-creator" type="xs:string" minOccurs="0">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      Author(s) of the data
      </xsd:documentation>
    </xsd:annotation>
    </xs:element>
    
   <xs:element name="creation-date" type="xs:date" minOccurs="0">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      When was the file created?
      </xsd:documentation>
    </xsd:annotation>
    </xs:element>
    
   <xs:element name="modification-date" type="xs:date" minOccurs="0">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      When was the file modified?
      </xsd:documentation>
    </xsd:annotation>
    </xs:element>

   <xs:element name="name" type="xs:string" minOccurs="0">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      What is the short name of this Connectome File?
      </xsd:documentation>
    </xsd:annotation>
    </xs:element>    
    
   <xs:element name="species" type="xs:string" minOccurs="0">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      Which species is dealt with? According to the ConnectomeWiki Category:Species taxonomy (case-sensitive!)
      </xsd:documentation>
    </xsd:annotation>
    </xs:element>
    
   <xs:element name="legal-notice" type="xs:string" minOccurs="0">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      Some legal notice concerning usage rights for the data.
      </xsd:documentation>
    </xsd:annotation>
    </xs:element>
    
   <xs:element name="reference" type="xs:string" minOccurs="0">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      References to paper where the data has been published.
      </xsd:documentation>
    </xsd:annotation>
    </xs:element>
    
   <xs:element name="url" type="xs:string" minOccurs="0">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      References to URL with further information or download location.
      </xsd:documentation>
    </xsd:annotation>
    </xs:element>
    
   <xs:element name="description" type="xs:string" minOccurs="0">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      Description of the dataset.
      </xsd:documentation>
    </xsd:annotation>
    </xs:element>

<!--

Probably some more information has to be included concerning the coordinate spaces.
Nifti and Gifti files already allow to define the coordinate spaces/voxel ordering of their data.

Corresponding to the information in the Gifti files!!!
http://www.nitrc.org/frs/download.php/158/gifti.xsd

CoordinateSystemTransformMatrix
NIFTI_XFORM_UNKNOWN
NIFTI_XFORM_SCANNER_ANAT
NIFTI_XFORM_ALIGNED_ANAT
NIFTI_XFORM_TALAIRACH
NIFTI_XFORM_MNI_152

//-->


   <xs:element name="nr_of_networks" type="xs:integer" minOccurs="1" maxOccurs="1">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      The numbers of existing network files in the current Connectome File.
      </xsd:documentation>
    </xsd:annotation>
    </xs:element>
    
  </xs:all>
   <xs:attribute name="version" type="xs:string">
    <xsd:annotation xml:lang="en">
      <xsd:documentation>
      Defines the version of the Connectome Schema Definition the current Connectome File is compatible with. Should be 1.0
      </xsd:documentation>
    </xsd:annotation>
    </xs:attribute>
    
</xs:complexType>
  
  <xs:element name="viewer">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="viewer-meta" type="metadata" minOccurs="1" maxOccurs="1">
        <xsd:annotation xml:lang="en">
          <xsd:documentation>
          All meta data information that has nothing particularly to do with one instance of a network
          </xsd:documentation>
        </xsd:annotation>
        </xs:element>
        
        <xs:element name="viewer-network" type="networkstype" minOccurs="0" maxOccurs="unbounded">
        <xsd:annotation xml:lang="en">
          <xsd:documentation>
          The name of the network file in the current Connectome File. This defines a data source in the ConnectomeViewer.
          </xsd:documentation>
        </xsd:annotation>
        </xs:element>
        
        <!-- later: 
            viewer-styles: Styles: styles.xml (later, depending on ConnectomeViewer implementation)
            viewer-scene: Scene Settings: scene_settings.xml (later, depending on ConnectomeViewer implementation)
          //-->

     </xs:sequence>
    </xs:complexType>
    
  </xs:element>
</xs:schema>
