'Return the cell row, column from `pos` in local coordinates.'

def cell_at(self, pos):

    if (self.__pixmap.isNull() or (not (self.heatmap_item.geometry().contains(pos) or self.averages_item.geometry().contains(pos)))):
        return ((-1), (-1))
    if self.heatmap_item.geometry().contains(pos):
        item_clicked = self.heatmap_item
    elif self.averages_item.geometry().contains(pos):
        item_clicked = self.averages_item
    pos = self.mapToItem(item_clicked, pos)
    size = self.heatmap_item.size()
    (x, y) = (pos.x(), pos.y())
    (N, M) = self.__data.shape
    fx = (x / size.width())
    fy = (y / size.height())
    i = min(int(math.floor((fy * N))), (N - 1))
    j = min(int(math.floor((fx * M))), (M - 1))
    return (i, j)
