diff --git a/downsample_images.py b/downsample_images.py
index c3f0f1b346f1697de3fbad33ec0065eb85ac7de6..6ce0f932bc71b139de48efae4a6c91b4491b045e 100644
--- a/downsample_images.py
+++ b/downsample_images.py
@@ -11,6 +11,7 @@
 from builtins import *
 
 import dolfin
+import glob
 import math
 import numpy
 import os
diff --git a/generate_images_Image.py b/generate_images_Image.py
index 52bbabd88c0fda91cab76f644153d8bac07f3dc2..6b5e838438689974ae255ddff2f36732b89bd76d 100644
--- a/generate_images_Image.py
+++ b/generate_images_Image.py
@@ -232,16 +232,6 @@ class Image():
         G[1] *= 0.
         G[2] *= math.copysign(1, math.sin(math.pi*X[2]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[2]/self.s)
 
-    def I0_texture_tagging_XY_wDifferentiableCombination(self, X, I):
-        I[0] *= (1 + 3 * abs(math.sin(math.pi*X[0]/self.s))
-                       * abs(math.sin(math.pi*X[1]/self.s)))**(1./2) - 1
-
-    def I0_texture_tagging_XY_wDifferentiableCombination_wGrad(self, X, I, G):
-        self.I0_texture_tagging_XY_wDifferentiableCombination(X, I)
-        G[0] *= 3 * math.copysign(1, math.sin(math.pi*X[0]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[0]/self.s) * abs(math.sin(math.pi*X[1]/self.s)) / 2 / (I[0] + 1)
-        G[1] *= 3 * math.copysign(1, math.sin(math.pi*X[1]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) / 2 / (I[0] + 1)
-        G[2] *= 0.
-
     def I0_texture_tagging_XY_wAdditiveCombination(self, X, I):
         I[0] *= (abs(math.sin(math.pi*X[0]/self.s))
                + abs(math.sin(math.pi*X[1]/self.s)))/2
@@ -262,16 +252,26 @@ class Image():
         G[1] *= math.copysign(1, math.sin(math.pi*X[1]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) / 2 / I[0]
         G[2] *= 0.
 
-    def I0_texture_tagging_XYZ_wDifferentiableCombination(self, X, I):
-        I[0] *= (1 + 7 * abs(math.sin(math.pi*X[0]/self.s))
-                       * abs(math.sin(math.pi*X[1]/self.s))
-                       * abs(math.sin(math.pi*X[2]/self.s)))**(1./3) - 1
+    def I0_texture_tagging_XY_wDifferentiableCombination(self, X, I):
+        I[0] *= (1 + 3 * abs(math.sin(math.pi*X[0]/self.s))
+                       * abs(math.sin(math.pi*X[1]/self.s)))**(1./2) - 1
 
-    def I0_texture_tagging_XYZ_wDifferentiableCombination_wGrad(self, X, I, G):
-        self.I0_texture_tagging_XYZ_wDifferentiableCombination(X, I)
-        G[0] *= 7 * math.copysign(1, math.sin(math.pi*X[0]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[0]/self.s) * abs(math.sin(math.pi*X[1]/self.s)) * abs(math.sin(math.pi*X[2]/self.s)) / 3 / (I[0] + 1)
-        G[1] *= 7 * math.copysign(1, math.sin(math.pi*X[1]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) * abs(math.sin(math.pi*X[2]/self.s)) / 3 / (I[0] + 1)
-        G[2] *= 7 * math.copysign(1, math.sin(math.pi*X[2]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[2]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) * abs(math.sin(math.pi*X[1]/self.s)) / 3 / (I[0] + 1)
+    def I0_texture_tagging_XY_wDifferentiableCombination_wGrad(self, X, I, G):
+        self.I0_texture_tagging_XY_wDifferentiableCombination(X, I)
+        G[0] *= 3 * math.copysign(1, math.sin(math.pi*X[0]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[0]/self.s) * abs(math.sin(math.pi*X[1]/self.s)) / 2 / (I[0] + 1)
+        G[1] *= 3 * math.copysign(1, math.sin(math.pi*X[1]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) / 2 / (I[0] + 1)
+        G[2] *= 0.
+
+    def I0_texture_tagging_XYZ_wAdditiveCombination(self, X, I):
+        I[0] *= (abs(math.sin(math.pi*X[0]/self.s))
+               + abs(math.sin(math.pi*X[1]/self.s))
+               + abs(math.sin(math.pi*X[2]/self.s)))/3
+
+    def I0_texture_tagging_XYZ_wAdditiveCombination_wGrad(self, X, I, G):
+        self.I0_texture_tagging_XYZ_wAdditiveCombination(X, I)
+        G[0] *= math.copysign(1, math.sin(math.pi*X[0]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[0]/self.s) / 3
+        G[1] *= math.copysign(1, math.sin(math.pi*X[1]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s) / 3
+        G[2] *= math.copysign(1, math.sin(math.pi*X[2]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[2]/self.s) / 3
 
     def I0_texture_tagging_XYZ_wMultiplicativeCombination(self, X, I):
         I[0] *= (abs(math.sin(math.pi*X[0]/self.s))
@@ -284,6 +284,17 @@ class Image():
         G[1] *= math.copysign(1, math.sin(math.pi*X[1]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) * abs(math.sin(math.pi*X[2]/self.s)) / 3 / I[0]**2
         G[2] *= math.copysign(1, math.sin(math.pi*X[2]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[2]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) * abs(math.sin(math.pi*X[1]/self.s)) / 3 / I[0]**2
 
+    def I0_texture_tagging_XYZ_wDifferentiableCombination(self, X, I):
+        I[0] *= (1 + 7 * abs(math.sin(math.pi*X[0]/self.s))
+                       * abs(math.sin(math.pi*X[1]/self.s))
+                       * abs(math.sin(math.pi*X[2]/self.s)))**(1./3) - 1
+
+    def I0_texture_tagging_XYZ_wDifferentiableCombination_wGrad(self, X, I, G):
+        self.I0_texture_tagging_XYZ_wDifferentiableCombination(X, I)
+        G[0] *= 7 * math.copysign(1, math.sin(math.pi*X[0]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[0]/self.s) * abs(math.sin(math.pi*X[1]/self.s)) * abs(math.sin(math.pi*X[2]/self.s)) / 3 / (I[0] + 1)
+        G[1] *= 7 * math.copysign(1, math.sin(math.pi*X[1]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) * abs(math.sin(math.pi*X[2]/self.s)) / 3 / (I[0] + 1)
+        G[2] *= 7 * math.copysign(1, math.sin(math.pi*X[2]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[2]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) * abs(math.sin(math.pi*X[1]/self.s)) / 3 / (I[0] + 1)
+
     def I0_texture_tagging_signed_X(self, X, I):
         I[0] *= (1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2
 
@@ -311,6 +322,26 @@ class Image():
         G[1] *= 0.
         G[2] *= (math.pi/self.s) * math.cos(math.pi*X[2]/self.s-math.pi/2) / 2
 
+    def I0_texture_tagging_signed_XY_wAdditiveCombination(self, X, I):
+        I[0] *= ((1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2
+              +  (1+math.sin(math.pi*X[1]/self.s-math.pi/2))/2) / 2
+
+    def I0_texture_tagging_signed_XY_wAdditiveCombination_wGrad(self, X, I, G):
+        self.I0_texture_tagging_signed_XY_wAdditiveCombination(X, I)
+        G[0] *= (math.pi/self.s) * math.cos(math.pi*X[0]/self.s-math.pi/2)/2 / 2
+        G[1] *= (math.pi/self.s) * math.cos(math.pi*X[1]/self.s-math.pi/2)/2 / 2
+        G[2] *= 0.
+
+    def I0_texture_tagging_signed_XY_wMultiplicativeCombination(self, X, I):
+        I[0] *= ((1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2
+             *   (1+math.sin(math.pi*X[1]/self.s-math.pi/2))/2)**(1./2)
+
+    def I0_texture_tagging_signed_XY_wMultiplicativeCombination_wGrad(self, X, I, G):
+        self.I0_texture_tagging_XY_wMultiplicativeCombination(X, I)
+        G[0] *= (math.pi/self.s) * math.cos(math.pi*X[0]/self.s-math.pi/2)/2 / 2 / I[0]
+        G[1] *= (math.pi/self.s) * math.cos(math.pi*X[1]/self.s-math.pi/2)/2 / 2 / I[0]
+        G[2] *= 0.
+
     def I0_texture_tagging_signed_XY_wDifferentiableCombination(self, X, I):
         I[0] *= (1 + 3 * (1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2
                        * (1+math.sin(math.pi*X[1]/self.s-math.pi/2))/2)**(1./2) - 1
@@ -321,15 +352,27 @@ class Image():
         G[1] *= 3 * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s-math.pi/2)/2 * (1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2 / 2 / (I[0] + 1)
         G[2] *= 0.
 
-    def I0_texture_tagging_signed_XY_wAdditiveCombination(self, X, I):
+    def I0_texture_tagging_signed_XYZ_wAdditiveCombination(self, X, I):
         I[0] *= ((1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2
-              +  (1+math.sin(math.pi*X[1]/self.s-math.pi/2))/2) / 2
+              +  (1+math.sin(math.pi*X[1]/self.s-math.pi/2))/2
+              +  (1+math.sin(math.pi*X[2]/self.s-math.pi/2))/2) / 3
 
-    def I0_texture_tagging_signed_XY_wAdditiveCombination_wGrad(self, X, I, G):
-        self.I0_texture_tagging_signed_XY_wAdditiveCombination(X, I)
-        G[0] *= (math.pi/self.s) * math.cos(math.pi*X[0]/self.s-math.pi/2)/2 / 2
-        G[1] *= (math.pi/self.s) * math.cos(math.pi*X[1]/self.s-math.pi/2)/2 / 2
-        G[2] *= 0.
+    def I0_texture_tagging_signed_XYZ_wAdditiveCombination_wGrad(self, X, I, G):
+        self.I0_texture_tagging_signed_XYZ_wAdditiveCombination(X, I)
+        G[0] *= (math.pi/self.s) * math.cos(math.pi*X[0]/self.s-math.pi/2)/2 / 3
+        G[1] *= (math.pi/self.s) * math.cos(math.pi*X[1]/self.s-math.pi/2)/2 / 3
+        G[2] *= (math.pi/self.s) * math.cos(math.pi*X[2]/self.s-math.pi/2)/2 / 3
+
+    def I0_texture_tagging_signed_XYZ_wMultiplicativeCombination(self, X, I):
+        I[0] *= ((1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2
+             *   (1+math.sin(math.pi*X[1]/self.s-math.pi/2))/2
+             *   (1+math.sin(math.pi*X[2]/self.s-math.pi/2))/2)**(1./3)
+
+    def I0_texture_tagging_signed_XYZ_wMultiplicativeCombination_wGrad(self, X, I, G):
+        self.I0_texture_tagging_XYZ_wMultiplicativeCombination(X, I)
+        G[0] *= (math.pi/self.s) * math.cos(math.pi*X[0]/self.s-math.pi/2)/2 / 3 / I[0]
+        G[1] *= (math.pi/self.s) * math.cos(math.pi*X[1]/self.s-math.pi/2)/2 / 3 / I[0]
+        G[2] *= (math.pi/self.s) * math.cos(math.pi*X[2]/self.s-math.pi/2)/2 / 3 / I[0]
 
     def I0_texture_tagging_signed_XYZ_wDifferentiableCombination(self, X, I):
         I[0] *= (1 + 7 * (1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2
@@ -342,17 +385,6 @@ class Image():
         G[1] *= 7 * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s-math.pi/2)/2 * (1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2 * (1+math.sin(math.pi*X[2]/self.s-math.pi/2))/2 / 3 / (I[0] + 1)
         G[2] *= 7 * (math.pi/self.s) * math.cos(math.pi*X[2]/self.s-math.pi/2)/2 * (1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2 * (1+math.sin(math.pi*X[1]/self.s-math.pi/2))/2 / 3 / (I[0] + 1)
 
-    def I0_texture_tagging_signed_XYZ_wAdditiveCombination(self, X, I):
-        I[0] *= ((1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2
-              +  (1+math.sin(math.pi*X[1]/self.s-math.pi/2))/2
-              +  (1+math.sin(math.pi*X[2]/self.s-math.pi/2))/2) / 3
-
-    def I0_texture_tagging_signed_XYZ_wAdditiveCombination_wGrad(self, X, I, G):
-        self.I0_texture_tagging_signed_XYZ_wAdditiveCombination(X, I)
-        G[0] *= (math.pi/self.s) * math.cos(math.pi*X[0]/self.s-math.pi/2)/2 / 3
-        G[1] *= (math.pi/self.s) * math.cos(math.pi*X[1]/self.s-math.pi/2)/2 / 3
-        G[2] *= (math.pi/self.s) * math.cos(math.pi*X[2]/self.s-math.pi/2)/2 / 3
-
     def I0_noise_no(self, I):
         pass