diff --git a/fsl/data/image.py b/fsl/data/image.py index e1a839dc0b2039af959322074a02f464acea7739..5e8df119357b397374a32e7692b7be7f2de7ee86 100644 --- a/fsl/data/image.py +++ b/fsl/data/image.py @@ -190,8 +190,28 @@ class Image(props.HasProperties): be called if the ``loadData`` parameter passed to :meth:`__init__` was ``False``. """ - self.data = self.nibImage.get_data() - self.data.flags.writeable = False + + data = self.nibImage.get_data() + + # Squeeze out empty dimensions, as + # 3D image can sometimes be listed + # as having 4 or more dimensions + shape = data.shape + + for i in reversed(range(len(shape))): + if shape[i - 1] == 1: + data = data.squeeze(axis=i - 1) + + data.flags.writeable = False + + log.debug('Loaded image data ({}) - original ' + 'shape {}, squeezed shape {}'.format( + self.name, + shape, + data.shape)) + + self.data = data + def applyChange(self, offset, newVals, vol=None): diff --git a/fsl/fslview/gl/textures.py b/fsl/fslview/gl/textures.py index ee84237ad9ffb5d9b699833d1988200de7c6f054..9737c2aafb0d8472dfe5787f9b26a826a1f32c0e 100644 --- a/fsl/fslview/gl/textures.py +++ b/fsl/fslview/gl/textures.py @@ -354,6 +354,49 @@ class ImageTexture(object): voxValXform = transform.scaleOffsetXform(scale, offset) + if log.getEffectiveLevel() == logging.DEBUG: + + if texDtype == gl.GL_UNSIGNED_BYTE: + sTexDtype = 'GL_UNSIGNED_BYTE' + elif texDtype == gl.GL_UNSIGNED_SHORT: + sTexDtype = 'GL_UNSIGNED_SHORT' + + if texFmt == gl.GL_LUMINANCE: + sTexFmt = 'GL_LUMINANCE' + elif texFmt == gl.GL_LUMINANCE_ALPHA: + sTexFmt = 'GL_LUMINANCE_ALPHA' + elif texFmt == gl.GL_RGB: + sTexFmt = 'GL_RGB' + elif texFmt == gl.GL_RGBA: + sTexFmt = 'GL_RGBA' + + if intFmt == gl.GL_LUMINANCE8: + sIntFmt = 'GL_LUMINANCE8' + elif intFmt == gl.GL_LUMINANCE16: + sIntFmt = 'GL_LUMINANCE16' + elif intFmt == gl.GL_LUMINANCE8_ALPHA8: + sIntFmt = 'GL_LUMINANCE8_ALPHA8' + elif intFmt == gl.GL_LUMINANCE16_ALPHA16: + sIntFmt = 'GL_LUMINANCE16_ALPHA16' + elif intFmt == gl.GL_RGB8: + sIntFmt = 'GL_RGB8' + elif intFmt == gl.GL_RGB16: + sIntFmt = 'GL_RGB16' + elif intFmt == gl.GL_RGBA8: + sIntFmt = 'GL_RGBA8' + elif intFmt == gl.GL_RGBA16: + sIntFmt = 'GL_RGBA16' + + log.debug('Image texture ({}) is to be stored as {}/{}/{} ' + '(normalised: {} - scale {}, offset {})'.format( + self.image, + sTexDtype, + sTexFmt, + sIntFmt, + self.normalise, + scale, + offset)) + return texFmt, intFmt, texDtype, voxValXform