<?xml version = "1.0" encoding = "UTF-8"?>
<!--
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	#
	# Copyright (C) 2003-2008 Open Microscopy Environment
	#       Massachusetts Institute of Technology,
	#       National Institutes of Health,
	#       University of Dundee,
	#       University of Wisconsin at Madison
	#
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<!--
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	# Written by:  Josiah Johnston <siah@nih.gov>, Andrew J Patterson
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<schema xmlns = "http://www.w3.org/2001/XMLSchema"
	targetNamespace = "http://www.openmicroscopy.org/Schemas/MLI/2008-02"
	xmlns:MLI = "http://www.openmicroscopy.org/Schemas/MLI/2008-02"
	xmlns:xml="http://www.w3.org/XML/1998/namespace"
	version="1"
	elementFormDefault = "qualified">
	<import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
	
	<element name = "ExecutionInstructions">
		<annotation>
			<documentation>Instructions for executing a matlab function.</documentation>
		</annotation>
		<complexType>
			<sequence>
				<element ref = "MLI:FunctionInputs"/>
				<element ref = "MLI:FunctionOutputs"/>
				<element ref = "MLI:Templates" minOccurs = "0"/>
				<element ref = "MLI:VectorDecoder" minOccurs = "0" maxOccurs = "unbounded"/>
			</sequence>
			<attribute name = "ExecutionGranularity" use = "required">
				<annotation>
					<documentation>Assigns a execution point for the analysis. Refer to the Analysis Engine for more Info. Alternately, plague ome-devel with requests for more documentation.</documentation>
				</annotation>
				<simpleType>
					<restriction base = "string">
						<enumeration value = "G"/>
						<enumeration value = "D"/>
						<enumeration value = "I"/>
						<enumeration value = "F"/>
					</restriction>
				</simpleType>
			</attribute>
		</complexType>
	</element>
	<element name = "FunctionInputs">
		<annotation>
			<documentation>An ordered list of the function's inputs</documentation>
		</annotation>
		<complexType>
			<sequence>
				<element ref = "MLI:Input" maxOccurs = "unbounded"/>
			</sequence>
		</complexType>
	</element>
	<element name = "FunctionOutputs">
		<annotation>
			<documentation>An ordered list of the function's outputs</documentation>
		</annotation>
		<complexType>
			<sequence>
				<element ref = "MLI:Output" maxOccurs = "unbounded"/>
			</sequence>
		</complexType>
	</element>
	<element name = "Input">
		<complexType>
			<choice>
				<element name = "PixelsArray">
					<annotation>
						<documentation>Will pass a numeric matrix into the function.
Translates a module input of Semantic Type Pixels (or any psuedo subclass of Pixels) to a numeric matrix. Limits specified by PixelsSlice or its subclasses will be honored.
						</documentation>
					</annotation>
					<complexType>
						<attribute name = "FormalInput" use = "required" type = "string">
							<annotation>
								<documentation>References a FormalInput by name</documentation>
							</annotation>
						</attribute>
						<attribute name = "ID" type = "string">
							<annotation>
								<documentation>An input ID. 
In the future, can be used to establish references.
								</documentation>
							</annotation>
						</attribute>
						<attribute name = "ConvertToDatatype">
							<annotation>
								<documentation>The Pixels array will be converted to the (MATLAB) datatype specified.</documentation>
							</annotation>
							<simpleType>
								<restriction base = "string">
									<enumeration value = "uint8"/>
									<enumeration value = "uint16"/>
									<enumeration value = "uint32"/>
									<enumeration value = "uint64"/>
									<enumeration value = "int8"/>
									<enumeration value = "int16"/>
									<enumeration value = "int32"/>
									<enumeration value = "int64"/>
									<enumeration value = "single"/>
									<enumeration value = "double"/>
									<enumeration value = "logical"/>
								</restriction>
							</simpleType>
						</attribute>
					</complexType>
				</element>
				<element name = "Scalar">
					<annotation>
						<documentation>A 1x1 numeric or logical matrix -OR- a char matrix. Used only with inputs of arity 1 (i.e. Count='!')</documentation>
					</annotation>
					<complexType>
						<attribute name = "InputLocation" use = "required" type = "string">
							<annotation>
								<documentation>Refers to a semantic element of a formal input. Syntax is formal input name, a period, and the semantic elment name. i.e. "Texture Direction.Direction_Value"</documentation>
							</annotation>
						</attribute>
						<attribute name = "ConvertToDatatype">
							<annotation>
								<documentation>The MATLAB scalar will be converted to the (MATLAB) datatype specified.</documentation>
							</annotation>
							<simpleType>
								<restriction base = "string">
									<enumeration value = "uint8"/>
									<enumeration value = "uint16"/>
									<enumeration value = "uint32"/>
									<enumeration value = "uint64"/>
									<enumeration value = "int8"/>
									<enumeration value = "int16"/>
									<enumeration value = "int32"/>
									<enumeration value = "int64"/>
									<enumeration value = "single"/>
									<enumeration value = "double"/>
									<enumeration value = "logical"/>
									<enumeration value = "char"/>
								</restriction>
							</simpleType>
						</attribute>
					</complexType>
				</element>
				<element name = "ConstantScalar">
					<annotation>
						<documentation>Specifies a constant scalar input.</documentation>
					</annotation>
					<complexType>
						<attribute name = "Value" use = "required" type = "string"/>
					</complexType>
				</element>
			</choice>
		</complexType>
	</element>
	<element name = "Output">
		<complexType>
			<choice>
				<element name = "PixelsArray">
					<annotation>
						<documentation>Will translate a numeric array to a Formal Output of Semantic Type Pixels (or any psuedo subclass of Pixels). If PixelsSlice appears in the pseudo inheritance chain, the extents will be set to the extents of the Pixels.</documentation>
					</annotation>
					<complexType>
						<attribute name = "FormalOutput" use = "required" type = "string">
							<annotation>
								<documentation>References a FormalOutput by name</documentation>
							</annotation>
						</attribute>
						<attribute name = "ID" type = "string">
							<annotation>
								<documentation>An output ID. 
In the future, can be used to stitch together data from different function outputs into a single module output, or establish references.
								</documentation>
							</annotation>
						</attribute>
						<attribute name = "ConvertToDatatype">
							<annotation>
								<documentation>Useful when a function outputs a Pixels type that is unsupported by OME. The permitted list is the matlab types supported by OME.
Note to perl developers: This list should stay syncronized with the Matlab Class to OME pixel-type mapping hash $self->{ _matlab_class_to_pixel_type } that is defined in OME::Analysis::Handlers::MatlabHandler->new()
								</documentation>
							</annotation>
							<simpleType>
								<restriction base = "string">
									<enumeration value = "uint8"/>
									<enumeration value = "uint16"/>
									<enumeration value = "uint32"/>
									<enumeration value = "single"/>
									<enumeration value = "int8"/>
									<enumeration value = "int16"/>
									<enumeration value = "int32"/>
								</restriction>
							</simpleType>
						</attribute>
					</complexType>
				</element>
				<element name = "Scalar">
					<annotation>
						<documentation>A 1x1 numeric or logical matrix -OR- a char matrix.</documentation>
					</annotation>
					<complexType>
						<attribute name = "UseTemplate" type = "string">
							<annotation>
								<documentation>References a Template this value will be inserted into.</documentation>
							</annotation>
						</attribute>
						<attribute name = "OutputLocation" use = "required" type = "string">
							<annotation>
								<documentation>Refers to a semantic element of a formal output. Syntax is formal output name, a period, and the semantic elment name. i.e. "Angular Second Moment.ASM"</documentation>
							</annotation>
						</attribute>
						<attribute name = "ConvertToDatatype">
							<annotation>
								<documentation>The MATLAB scalar will be converted to the (MATLAB) datatype specified. The permitted list is the matlab types supported by OME.
Note to perl developers: This list should stay syncronized with the Matlab Class to OME SE Type mapping hash $self->{ _matlab_class_to_ome_datatype} that is defined in OME::Analysis::Handlers::MatlabHandler->new()
								</documentation>
							</annotation>
							<simpleType>
								<restriction base = "string">
									<enumeration value = "uint8"/>
									<enumeration value = "uint16"/>
									<enumeration value = "uint32"/>
									<enumeration value = "int8"/>
									<enumeration value = "int16"/>
									<enumeration value = "int32"/>
									<enumeration value = "int64"/>
									<enumeration value = "single"/>
									<enumeration value = "double"/>
									<enumeration value = "logical"/>
									<enumeration value = "char"/>
								</restriction>
							</simpleType>
						</attribute>
					</complexType>
				</element>
				<element name = "Struct">
					<annotation>
						<documentation>Struct outputs are expected to have the same structure and field names as the STs of their formal outputs. We do not anticipate this to be a widely used feature.</documentation>
					</annotation>
					<complexType>
						<attribute name = "FormalOutput" use = "required" type = "string">
							<annotation>
								<documentation>References a FormalOutput by name</documentation>
							</annotation>
						</attribute>
						<attribute name = "ID" type = "string">
							<annotation>
								<documentation>An output ID. 
In the future, can be used to stitch together data from different function outputs into a single module output, or establish references.
								</documentation>
							</annotation>
						</attribute>
					</complexType>
				</element>
				<element name = "Vector">
					<annotation>
						<documentation>A one dimensional matrix output.</documentation>
					</annotation>
					<complexType>
						<attribute name = "DecodeWith" use = "required" type = "string">
							<annotation>
								<documentation>Specifies decoding instructions. This should match the ID of a VectorDecoder element</documentation>
							</annotation>
						</attribute>
					</complexType>
				</element>
			</choice>
		</complexType>
	</element>
	<element name = "Templates">
		<annotation>
			<documentation>Used to add structure &amp; explicit data description to function outputs such as ChannelComponents or LogicalChannels.
The contents of this element should follow CustomAttribute syntax and conventions.
			</documentation>
		</annotation>
	</element>
	<element name = "VectorDecoder">
		<annotation>
			<documentation>Instructions for extracting data from a one dimensional matlab matrix. </documentation>
		</annotation>
		<complexType>
			<sequence>
				<element name = "Element" maxOccurs = "unbounded">
					<annotation>
						<documentation>Maps a location on the Vector to an output data location. Can be used in conjuction with Templates.</documentation>
					</annotation>
					<complexType>
						<attribute name = "OutputLocation" use = "required" type = "string">
							<annotation>
								<documentation>Refers to a semantic element of a formal output. Syntax is formal output name, a period, and the semantic elment name. i.e. "Angular Second Moment.ASM"</documentation>
							</annotation>
						</attribute>
						<attribute name = "Index" use = "required" type = "string">
							<annotation>
								<documentation>A numeric index into the matlab vector. Numbering starts at 1 to follow matlab convention.</documentation>
							</annotation>
						</attribute>
						<attribute name = "UseTemplate" type = "string">
							<annotation>
								<documentation>References a Template this value will be inserted into.</documentation>
							</annotation>
						</attribute>
						<attribute name = "ID" type = "string">
							<annotation>
								<documentation>An output ID. 
In the future, can be used to stitch together data from different function outputs into a single module output, or establish references.
								</documentation>
							</annotation>
						</attribute>
						<attribute name = "ConvertToDatatype">
							<annotation>
								<documentation>The MATLAB scalar that is part of a MATLAB vector will be converted to the (MATLAB) datatype specified. The permitted list is the matlab types supported by OME.
Note to perl developers: This list should stay syncronized with the Matlab Class to OME SE Type mapping hash $self->{ _matlab_class_to_ome_datatype} that is defined in OME::Analysis::Handlers::MatlabHandler->new()
								</documentation>
							</annotation>
							<simpleType>
								<restriction base = "string">
									<enumeration value = "uint8"/>
									<enumeration value = "uint16"/>
									<enumeration value = "uint32"/>
									<enumeration value = "int8"/>
									<enumeration value = "int16"/>
									<enumeration value = "int32"/>
									<enumeration value = "int64"/>
									<enumeration value = "single"/>
									<enumeration value = "double"/>
									<enumeration value = "logical"/>
									<enumeration value = "char"/>
								</restriction>
							</simpleType>
						</attribute>
					</complexType>
				</element>
			</sequence>
			<attribute name = "ID" use = "required" type = "string">
				<annotation>
					<documentation>An output ID. 
In the future, can be used to stitch together data from different function outputs into a single module output, or establish references.
					</documentation>
				</annotation>
			</attribute>
		</complexType>
	</element>
</schema>