                (if (.tags img)
                  (let [result (process-function img)]
                    (if (counted? result)
-                     (doseq [image (process-function (.poll this))]
+                     (doseq [image result]
                        (.produce this image))
                      (.produce this result)))
                  (.produce this img))))))

           (org.json JSONObject)
           (org.micromanager MMStudioMainFrame)
           (org.micromanager.api DataProcessor))
  (:use [org.micromanager.mm :only (load-mm gui mmc)]))

(load-mm (MMStudioMainFrame/getInstance))

(def acq (.getAcquisitionEngine gui))

(defn simple-data-processor
  "Make a DataProcessor whose process method is implemented by

  "Duplicates channels"
  (simple-data-processor
    (fn [img]
        (let [tags (json-clone (.tags img))]
          (update-tag! tags "ChannelIndex" #(+ 2 %))            
          (update-tag! tags "Channel" #(str % "-2"))
          [img (TaggedImage. (.pix img) tags)]))))

(defn restart-test []
  (remove-all-image-processors!)
