 (defn pixel-size-um
   "Compute the pixel size from a stage-to-pixel transform."
   [stage-to-pixel-transform]
-  (Math/pow (.getDeterminant stage-to-pixel-transform) -1/2))
+  (Math/pow (Math/abs (.getDeterminant stage-to-pixel-transform)) -1/2))
 
 ;; tagged image stuff
 


(defn set-z-position
  [z]
  (let [stage (mm/core getFocusDevice)]
    (when (not= z (@current-z-positions stage))
      (mm/core setPosition stage z)
      (mm/core waitForDevice stage))

   :tags (mm/json-to-data (.tags tagged-image))})

;; stage communications

(defn non-empty [x]
  (when-not (empty? x) x))

(defn focus-device []
  (non-empty (mm/core getFocusDevice)))

(defn get-xy-position []
  (mm/core waitForDevice (mm/core getXYStageDevice))
