   passable values, presumably interchangeable.  If this assumption is
   not true, then an adjustment will have to be made to this function."
   [bad-set good-set quality-coll value-coll]
-  (when (seq (filter bad-set quality-coll))
-    (let [bad-end-set (bad-ends bad-set quality-coll)
-          new-qual (replace-index-set bad-end-set
-                                      (first good-set)
-                                      quality-coll)
-          new-vals (neutralize-ends bad-set
-                                    quality-coll
-                                    value-coll)
-          good-seq (positions (complement bad-set)
-                              new-qual)]
-      (vec (flatten [(map (partial stretch-ts new-vals)
-                          (partition 2 1 good-seq))
-                     (nth new-vals (last good-seq))])))))
+  (let [qual-set (set quality-coll)]
+    (cond (empty? (seq (clojure.set/intersection good-set qual-set))) nil
+          (empty? (clojure.set/difference qual-set good-set)) value-coll
+          :else (let [bad-end-set (bad-ends bad-set quality-coll)
+                      new-qual (replace-index-set bad-end-set
+                                                  (first good-set)
+                                                  quality-coll)
+                      new-vals (neutralize-ends bad-set
+                                                quality-coll
+                                                value-coll)
+                      good-seq (positions (complement bad-set)
+                                          new-qual)]
+                  (vec (flatten [(map (partial stretch-ts new-vals)
+                                      (partition 2 1 good-seq))
+                                 (nth new-vals (last good-seq))]))))))

  `neutralize-ends` will return the original time-series. `bad-set` is a set of
  `reli-coll` values that indicate unreliable pixels."
  [bad-set reli-coll val-coll]
  (let [avg (act-on-good u/coll-avg
                         (mask bad-set reli-coll val-coll))]
    (replace-index-set (bad-ends bad-set reli-coll)
                       avg

            (map #(for [[m n] % :while (bad-set n)] m)
                 [m-coll r-coll])))))

(defn apply-to-valid
  "apply function `f` to all valid (non-nil) values within a collection `coll`"
  [f coll]
  (f (filter (complement nil?) coll)))

