 (defn create-loops [dimensions]
   (reduce #(apply (partial nest-loop %1) %2) [{:task :snap}] dimensions))
 
-(defn make-main-loops []
-  (create-loops (make-dimensions)))
+(defn make-main-loops [settings]
+  (create-loops (make-dimensions settings)))
 
-(defn manage-shutter [events]
-  (for [[e1 e2] (pairs events)]
-    (assoc e1 :close-shutter
-      (if e2 (or
-               (and
-                 (not (settings :keep-shutter-open-channels))
-                 (not= (e1 :channel) (e2 :channel)))
-               (and
-                 (not (settings :keep-shutter-open-slices))
-                 (not= (e1 :slice) (e2 :slice)))
-               (not= (e1 :frame) (e2 :frame))
-               (not= (e1 :position) (e2 :position)))
-        true))))
-
-(defn process-skip-z-stack [events]
-  (let [slices (settings :slices)
-        middle-slice (nth slices (int (/ (count slices) 2)))]
+(defn process-skip-z-stack [events slices]
+  (let [middle-slice (nth slices (int (/ (count slices) 2)))]
     (filter
       #(or
          (nil? (% :channel))
          (-> % :channel :use-z-stack)
          (= middle-slice (% :slice)))
       events)))
+
+(defn manage-shutter [events keep-shutter-open-channels keep-shutter-open-slices]
+  (for [[e1 e2] (pairs events)]
+    (assoc e1 :close-shutter
+      (if e2 (or
+               (and
+                 (not keep-shutter-open-channels)
+                 (not= (e1 :channel) (e2 :channel)))
+               (and
+                 (not keep-shutter-open-slices)
+                 (not= (e1 :slice) (e2 :slice)))
+               (not= (e1 :frame) (e2 :frame))
+               (not= (e1 :position) (e2 :position)))
+        true))))
 
 (defn process-channel-skip-frames [events]
   (filter

      (assoc event dim dim-val))
    events))

(defn make-dimensions []
  (let [{:keys [slices channels frames positions
                slices-first time-first]} settings
        a [[slices :slice] [channels :channel]]

(defstruct acq-settings :frames :positions :channels :slices :slices-first
  :time-first :keep-shutter-open-slices :keep-shutter-open-channels
  :use-autofocus :autofocus-skip :relative-slices :exposure)

(defn pairs [x]
  (partition 2 1 (concat x [nil])))
