def add(self, layers, above=None, below=None):
def add_named_layer(name, image):<EOL><INDENT>image = self.get_image(image, output='<STR_LIT>')<EOL>if above is not None:<EOL><INDENT>image[image < above] = <NUM_LIT:0.><EOL><DEDENT>if below is not None:<EOL><INDENT>image[image > below] = <NUM_LIT:0.><EOL><DEDENT>self.layers[name] = image<EOL>self.stack.append(name)<EOL><DEDENT>if isinstance(layers, dict):<EOL><INDENT>for (name, image) in layers.items():<EOL><INDENT>add_named_layer(name, image)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if not isinstance(layers, list):<EOL><INDENT>layers = [layers]<EOL><DEDENT>for image in layers:<EOL><INDENT>name = '<STR_LIT>' % len(self.stack)<EOL>add_named_layer(name, image)<EOL><DEDENT><DEDENT>self.set_mask()<EOL>
Add one or more layers to the stack of masking layers.
        Args:
            layers: A string, NiBabel image, list, or dict. If anything other
                than a dict is passed, assigns sequential layer names based on
                the current position in stack; if a dict, uses key as the name
                and value as the mask image.