            (org.micromanager AcqEngine MMStudioMainFrame)
            (org.micromanager.utils GUIUpdater ImageUtils JavaUtils MDUtils)
            (org.micromanager.acquisition TaggedImageQueue))
-  (:use [org.micromanager.mm :only (core edt mmc load-mm json-to-data)]))
+  (:use [org.micromanager.mm :only (core edt mmc load-mm json-to-data)]
+        [slide-explorer.image :only (overlay lut-object)]))
+
+
+; Order of operations:
+;  Stitch/crop
+;  Flatten fields
+;  Max intensity projection (z)
+;  Rescale
+;  Color Overlay
+
 
 (load-mm)
 
 ;; hardware communications
 
+(defn set-stage-to-pixel-transform []
+  (let [prefs (Preferences/userNodeForPackage MMStudioMainFrame)]
+    (JavaUtils/getObjectFromPrefs
+      prefs (str "affine_transform_" (core getCurrentPixelSizeConfig))
+      (AffineTransform. 2.0 0.0 0.0 2.0 0.0 0.0))))
+
 (defn get-stage-to-pixel-transform []
-  (AffineTransform. 2.0 0.0 0.0 2.0 0.0 0.0))
-;  (let [prefs (Preferences/userNodeForPackage MMStudioMainFrame)]
-;    (JavaUtils/getObjectFromPrefs
-;      prefs (str "affine_transform_" (core getCurrentPixelSizeConfig)) nil)))
+  (let [prefs (Preferences/userNodeForPackage MMStudioMainFrame)]
+    (JavaUtils/getObjectFromPrefs
+      prefs (str "affine_transform_" (core getCurrentPixelSizeConfig))
+      (AffineTransform. 2.0 0.0 0.0 2.0 0.0 0.0))))
 
 (def angle (atom 0))
 


;; tests

(defn test-tile [nx ny]
  (add-to-available-tiles at 0 [nx ny 0 0 0]))

(defn test-tiles [nx ny]
  (.start (Thread.

                           RenderingHints/VALUE_ANTIALIAS_OFF)))))
       
(defn paint-tiles [^Graphics2D g available-tiles zoom]
  (doseq [[{:keys [nx ny nz nt nc]} image] (get available-tiles zoom)]
    (let [[x y] (tile-to-pixels [nx ny] [512 512] zoom)]
      (when image
        (.drawImage g image
