Water bubbles in the middle of a 3d stack

As I obtain a 3d stack, I am sometimes left with water bubbles in the middle of my stack that disappears later on. Is there a command that can recognize an artifact based on the prior images in the stack and remove it accordingly?

Can you post a couple of representative images, along with specifics describing exactly what you want to have happen? E.g.: another image which you have manually adjusted to illustrate?