Solved by Nikronic in post #2 
              
              
                Hi, 
I think there is problem with your conditioning that leads to NoneType in IMG1 and IMG2. Try to write python a function outside of and test that your approach is currect or not. Actually, I do not know about your data structure but I cannot understand the idea behind imgx and IMGx, mostly here. …