     )
     (assoc :properties (get-config (core getChannelGroup) (.config_ chan)))))
 
-(defn MultiStagePosition-to-map [^MultiStagePosition msp]
+(defn MultiStagePosition-to-map
+  "Convert a Micro-Manager MultiStagePosition object to a clojure data map."
+  [^MultiStagePosition msp]
   (if msp
     {:label (.getLabel msp)
      :axes

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

(defn get-msp [idx]
  (when idx
    (let [p-list (. gui getPositionList)]
      (when (pos? (. p-list getNumberOfPositions))
        (.getPosition p-list idx)))))

(defn get-msp-z-position [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 [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 [str-seq]
  (let [v (StrVector.)]
    (doseq [item str-seq]
      (.add v item))
    v))

(defn double-vector [doubles]
  (let [v (DoubleVector.)]
    (doseq [item doubles]
      (.add v item))

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


(defmacro core
  "Run args as a method and parameters on Micro-Manager core.
   If debugging, log the command and the returned value to the
   Micro-Manager log output."
  [& args]
  `(log-cmd 3 (. mmc ~@args)))

(defmacro when-lets
