Skip to content
Snippets Groups Projects
Commit a2b84c22 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Handle NIFTI images which have the wrong number of dimensions in their

header
parent fb12da26
No related branches found
No related tags found
No related merge requests found
......@@ -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):
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment