 
 (defn rand-image [w h nchannels bytes-per-pixel]
   (rand-bytes (* w h nchannels )))
+
+;;;; metadata tests
 
 (def test-meta (populate-meta (new-ome-meta) 512 512 2 2 2 2))
 

    test-meta))

(defn overwrite-metadata [filename metadata]
  (overwrite-comment filename (get-xml-string metadata)))


           [java.io ByteArrayInputStream])
  (:require [clojure.xml]))

;; xml <--> str

(defn str-to-xml [s]
  (clojure.xml/parse (ByteArrayInputStream. (.getBytes s "UTF-8"))))

(defn xml-to-str [xml]
  (with-out-str (clojure.xml/emit xml)))

;; OMEXMLMetadata functions

(def ome-xml-service (. (ServiceFactory.) (getInstance OMEXMLService)))

(defn new-ome-meta []
  (. ome-xml-service createOMEXMLMetadata))

(defn get-ome-xml-string [m]
  (.getOMEXML ome-xml-service m))
                    
(defn ome-to-xml [m]
  (-> m get-ome-xml-string str-to-xml))

(defn +int [n] (PositiveInteger. n))

