  Producing images from interferometer data requires accurate modeling of the
sources in the field of view, which is typically done using the CLEAN
algorithm. Given the large number of degrees of freedom in interferometeric
images, one constrains the possible model solutions for CLEAN by masking
regions that contain emission. Traditionally this process has largely been done
by hand. This approach is not possible with today's large data volumes which
require automated imaging pipelines. This paper describes an automated masking
algorithm that operates within CLEAN called AUTO-MULTITHRESH. This algorithm
was developed and validated using a set of ~1000 ALMA images chosen to span a
range of intrinsic morphology and data characteristics. It takes a top-down
approach to producing masks: it uses the residual images to identify
significant peaks and then expands the mask to include emission associated with
these peaks down to lower signal-to-noise noise. The AUTO-MULTITHRESH algorithm
has been implemented in CASA and has been used in production as part of the
ALMA Imaging Pipeline starting with Cycle 5. It has been shown to be able to
mask a wide range of emission ranging from simple point sources to complex
extended emission with minimal tuning of the parameters based on the point
spread function of the data. Although the algorithm was developed for ALMA, it
is general enough to have been used successfully with data from other
interferometers with appropriate parameter tuning. Integrating the algorithm
more deeply within the minor cycle could lead to future performance
improvements.
