'Return the result of ROI.getArrayRegion(), masked by the shape of the
ROI. Values outside the ROI shape are set to 0.'

def getArrayRegion(self, data, img, axes=(0, 1), **kwds):

    br = self.boundingRect()
    if (br.width() > 1000):
        raise Exception()
    sliced = ROI.getArrayRegion(self, data, img, axes=axes, fromBoundingRect=True, **kwds)
    if (img.axisOrder == 'col-major'):
        mask = self.renderShapeMask(sliced.shape[axes[0]], sliced.shape[axes[1]])
    else:
        mask = self.renderShapeMask(sliced.shape[axes[1]], sliced.shape[axes[0]])
        mask = mask.T
    shape = ([1] * data.ndim)
    shape[axes[0]] = sliced.shape[axes[0]]
    shape[axes[1]] = sliced.shape[axes[1]]
    mask = mask.reshape(shape)
    return (sliced * mask)
