def _nav_naxis(self, viewer, axis, direction, msg=True):
        """Interactively change the slice of the image in a data cube
        by scrolling.
        """
        image = viewer.get_image()
        if image is None:
            return
        mddata = image.get_mddata()
        if len(mddata.shape) < (axis + 1):
            # image dimensions < 3D
            return

        naxispath = list(image.naxispath)
        axis_lim = mddata.shape[axis]
        m = axis - 2

        idx = naxispath[m]
        if direction == 'down':
            idx = (idx + 1) % axis_lim
        else:
            idx = idx - 1
            if idx < 0:
                idx = axis_lim - 1

        naxispath[m] = idx
        image.set_naxispath(naxispath)
Interactively change the slice of the image in a data cube
        by scrolling.