           (json-to-data (.get json i))))
     json))
 
-(def iso8601modified (SimpleDateFormat. "yyyy-MM-dd HH:mm:ss Z"))
-
-(defn get-current-time-str []
+(def ^{:doc "the ISO8601 data standard format modified to make it
+             slightly more human-readable."}
+       iso8601modified (SimpleDateFormat. "yyyy-MM-dd HH:mm:ss Z"))
+
+(defn get-current-time-str 
+  "Get the current time and date in modified ISO8601 format."
+  []
   (. iso8601modified format (Date.)))
 
-(defn get-pixel-type []
+(defn get-pixel-type
+  "Get the current pixel type."
+  []
   (str ({1 "GRAY", 4 "RGB"} (int (core getNumberOfComponents))) (* 8 (core getBytesPerPixel))))
 
-(defn ChannelSpec-to-map [^ChannelSpec chan]
+(defn ChannelSpec-to-map
+  "Convert a Micro-Manager ChannelSpec object to a clojure data map
+   with friendly keys."
+  [^ChannelSpec chan]
   (-> chan
     (data-object-to-map)
     (select-and-rekey

   ([expr] `(log-cmd 1 ~expr)))


(defmacro core [& args]
  `(log-cmd 3 (. mmc ~@args)))

(defmacro when-lets

                  1 [(.x stage-pos)]
                  2 [(.x stage-pos) (.y stage-pos)])])))}))

(defn get-msp
  "Get a MultiStagePosition object from the Position List with the specified
   index number."
  [idx]
  (when idx
    (let [p-list (. gui getPositionList)]
      (when (pos? (. p-list getNumberOfPositions))
        (.getPosition p-list idx)))))

(defn get-msp-z-position
  "Get the z position for a given z-stage from the MultiStagePosition
   with the given index in the Position List."
  [idx z-stage]
  (if-let [msp (get-msp idx)]
    (if-let [stage-pos (. msp get z-stage)]
      (. stage-pos x))))

(defn set-msp-z-position
  "Set the z position for a given z-stage from the MultiStagePosition
   with the given index in the Position List."
  [idx z-stage z]
  (when-let [msp (get-msp idx)]
    (when-let [stage-pos (. msp (get z-stage))]
      (set! (. stage-pos x) z))))

(defn str-vector
  "Convert a sequence of strings into a Micro-Manager StrVector."
  [str-seq]
  (let [v (StrVector.)]
    (doseq [item str-seq]
      (.add v item))
    v))

(defn double-vector [doubles]
  "Convert a sequence of numbers to a Micro-Manager DoubleVector."
  (let [v (DoubleVector.)]
    (doseq [item doubles]
      (.add v item))
