Commit 49da63bb authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

Merge branch 'rel/0.32.3' into 'v0.32'

Rel/0.32.3

See merge request fsl/fsleyes/fsleyes!187
parents 1f57cffa eb7b9362
......@@ -3,6 +3,13 @@
set -e
apt-get install -y bc
# Temporary: this should be done
# in docker image definition
apt install -y locales
locale-gen en_US.UTF-8
locale-gen en_GB.UTF-8
update-locale
# If running on a fork repository, we merge in the
# upstream/master branch. This is done so that merge
......
......@@ -10,6 +10,19 @@ chronological order.
0.32.3 (Monday 2nd March 2020)
------------------------------
Fixed
^^^^^
* Fixed a bug which occurred when using 3D mode on platforms with
limited OpenGL capabilities.
* Fixed some minor issues in the file tree panel.
0.32.2 (Friday 21st February 2020)
----------------------------------
......
......@@ -178,6 +178,11 @@ class FileGroup(object):
self.files)
def __repr__(self):
"""Return a string representation of this ``FileGroup``. """
return str(self)
def __eq__(self, other):
"""Return ``True`` if this ``FileGroup`` is equal to ``other``. """
return (self.varyings == other.varyings and
......@@ -570,34 +575,35 @@ def filterFileGroups(filegroups, fixedcols):
# Remove duplicate/redundant rows
for i in range(len(filegroups)):
grpi = filegroups[i]
if i in dropcols:
continue
for j in range(i + 1, len(filegroups)):
grpi = filegroups[i]
ifiles = [f for f in grpi.files if f is not None]
grpj = filegroups[j]
# drop empty rows
if len(ifiles) == 0:
dropcols.add(i)
continue
for j in range(i + 1, len(filegroups)):
if j in dropcols:
continue
ifiles = [f for f in grpi.files if f is not None]
grpj = filegroups[j]
jfiles = [f for f in grpj.files if f is not None]
# Note that the conditions below
# will cause empty groups (groups
# with no files present) to be
# dropped
# Group i contains all the files
# of group j - we can drop group j
# (this will also cause j to be
# dropped if it is empty)
if all([n in ifiles for n in jfiles]):
dropcols.add(j)
# Group j contains all the files
# in group i - we can drop group i
if all([n in jfiles for n in ifiles]):
elif all([n in jfiles for n in ifiles]):
dropcols.add(i)
break
......
......@@ -790,24 +790,25 @@ class Texture(notifier.Notifier, TextureBase, TextureSettingsMixin):
if self.nvals > 1: self.__shape = data.shape[1:]
else: self.__shape = data.shape
# If the data is of a type which cannot
# be stored natively as an OpenGL texture,
# and we don't have support for floating
# point textures, the data must be
# normalised. See determineType and
# prepareData in the data module
self.normalise = self.normalise or \
(not texdata.canUseFloatTextures()[0] and
(dtype not in (np.uint8, np.int8, np.uint16, np.int16)))
# If the caller has not provided
# a normalisation range, we have
# to calculate it.
if self.normalise and (self.normaliseRange is None):
self.normaliseRange = np.nanmin(data), np.nanmax(data)
log.debug('Calculated %s data range for normalisation: '
'[%s - %s]', self.__name, *self.__normaliseRange)
# If the data is of a type which cannot
# be stored natively as an OpenGL texture,
# and we don't have support for floating
# point textures, the data must be
# normalised. See determineType and
# prepareData in the data module
self.normalise = self.normalise or \
(not texdata.canUseFloatTextures()[0] and
(dtype not in (np.uint8, np.int8, np.uint16, np.int16)))
# If the caller has not provided
# a normalisation range, we have
# to calculate it.
if (data is not None) and \
self.normalise and \
(self.normaliseRange is None):
self.normaliseRange = np.nanmin(data), np.nanmax(data)
log.debug('Calculated %s data range for normalisation: '
'[%s - %s]', self.__name, *self.normaliseRange)
elif changed['shape'] or changed['dtype']:
self.__data = None
......@@ -1008,8 +1009,8 @@ class Texture(notifier.Notifier, TextureBase, TextureSettingsMixin):
"""
if self.nvals not in (1, 3, 4):
raise ValueError('Cannot create texture representation for %s '
'(nvals: %s)', self.dtype, self.nvals)
raise ValueError('Cannot create texture representation for {} '
'(nvals: {})'.format(self.dtype, self.nvals))
if self.__data is None: dtype = self.__dtype
else: dtype = self.__data.dtype
......
......@@ -14,7 +14,7 @@ version number. See also the :mod:`fsl.version` module.
"""
__version__ = '0.32.2'
__version__ = '0.32.3'
"""Current version number, as a string. The FSLeyes version number consists
of three numbers, separated by a period, which roughly obeys the Semantic
Versioning conventions (http://semver.org/).
......
......@@ -9,6 +9,6 @@ PyOpenGL>=3.1.0
pyparsing==2.*
scipy>=0.18
wxPython>=3.0.2.0
fslpy>=2.8
fslpy>=2.8.4
fsleyes-props>=1.6.7
fsleyes-widgets>=0.8.4
......@@ -435,6 +435,7 @@ def run_cli_tests(prefix, tests, extras=None, scene='ortho', threshold=10):
except Exception as e:
allpassed = False
print('CLI test failed [{}] {}: {}'.format(prefix, test, e))
traceback.print_exc()
if op.exists(testfile):
print('Copying {} to {}'.format(testfile, datadir))
......
......@@ -214,59 +214,68 @@ def test_filterFileGroups():
base = tw.dedent("""
subj-{subject}
T1w.nii.gz (T1w)
native
->sub space=native (surf_native)
mni
->sub space=mni (surf_mni)
surf
->sub (surf)
""").strip()
sub = tw.dedent("""
{hemi}.{space}.gii (surface)
{hemi}.{boundary}.gii (surface)
""").strip()
files = [
op.join('subj-01', 'T1w.nii.gz'),
op.join('subj-01', 'native', 'L.native.gii'),
op.join('subj-01', 'native', 'R.native.gii'),
op.join('subj-01', 'mni', 'L.mni.gii'),
op.join('subj-01', 'mni', 'R.mni.gii'),
op.join('subj-02', 'T1w.nii.gz'),
op.join('subj-02', 'native', 'L.native.gii'),
op.join('subj-02', 'native', 'R.native.gii'),
op.join('subj-02', 'mni', 'L.mni.gii'),
op.join('subj-02', 'mni', 'R.mni.gii'),
op.join('subj-01', 'surf', 'L.white.gii'),
op.join('subj-01', 'surf', 'R.white.gii'),
op.join('subj-01', 'surf', 'L.pial.gii'),
op.join('subj-01', 'surf', 'R.pial.gii'),
#op.join('subj-02', 'T1w.nii.gz'),
op.join('subj-02', 'surf', 'L.white.gii'),
op.join('subj-02', 'surf', 'R.white.gii'),
op.join('subj-02', 'surf', 'L.pial.gii'),
op.join('subj-02', 'surf', 'R.pial.gii'),
op.join('subj-03', 'T1w.nii.gz'),
op.join('subj-03', 'native', 'L.native.gii'),
op.join('subj-03', 'native', 'R.native.gii'),
op.join('subj-03', 'mni', 'L.mni.gii'),
op.join('subj-03', 'mni', 'R.mni.gii'),
op.join('subj-03', 'surf', 'L.white.gii'),
op.join('subj-03', 'surf', 'R.white.gii'),
#op.join('subj-03', 'surf', 'L.pial.gii'),
#op.join('subj-03', 'surf', 'R.pial.gii'),
]
# (invars, infixed, expgroups, expcols)
tests = [
# rows where space=t1/mni should be removed
({'subject' : ['01', '02', '03'],
'space' : ['native', 'mni']},
[('T1w', {}),
('surf_native/surface', {'hemi' : 'L'}),
('surf_native/surface', {'hemi' : 'R'})],
[ftman.FileGroup({'subject' : '01', 'space' : 'native'}, [{}, {'hemi' : 'L'}, {'hemi' : 'R'}], ['T1w', 'surf_native/surface', 'surf_native/surface'], ['subj-01/T1w.nii.gz', 'subj-01/native/L.native.gii', 'subj-01/native/R.native.gii']),
ftman.FileGroup({'subject' : '02', 'space' : 'native'}, [{}, {'hemi' : 'L'}, {'hemi' : 'R'}], ['T1w', 'surf_native/surface', 'surf_native/surface'], ['subj-02/T1w.nii.gz', 'subj-02/native/L.native.gii', 'subj-02/native/R.native.gii']),
ftman.FileGroup({'subject' : '03', 'space' : 'native'}, [{}, {'hemi' : 'L'}, {'hemi' : 'R'}], ['T1w', 'surf_native/surface', 'surf_native/surface'], ['subj-03/T1w.nii.gz', 'subj-03/native/L.native.gii', 'subj-03/native/R.native.gii'])],
# subj02 row should be filtered
({'subject' : ['01', '02', '03']},
[('T1w', {})],
[ftman.FileGroup({'subject' : '01'}, [{}], ['T1w'], ['subj-01/T1w.nii.gz']),
# ftman.FileGroup({'subject' : '02'}, [{}], ['T1w'], ['subj-02/T1w.nii.gz']),
ftman.FileGroup({'subject' : '03'}, [{}], ['T1w'], ['subj-03/T1w.nii.gz'])],
None),
# sub3/pial should be filtered
({'subject' : ['01', '02', '03'],
'boundary' : ['pial', 'white']},
[('T1w', {}),
('surf/surface', {'hemi' : 'L'}),
('surf/surface', {'hemi' : 'R'})],
[ftman.FileGroup({'subject' : '01', 'boundary' : 'pial'}, [{}, {'hemi' : 'L'}, {'hemi' : 'R'}], ['T1w', 'surf/surface', 'surf/surface'], ['subj-01/T1w.nii.gz', 'subj-01/surf/L.pial.gii', 'subj-01/surf/R.pial.gii']),
ftman.FileGroup({'subject' : '01', 'boundary' : 'white'}, [{}, {'hemi' : 'L'}, {'hemi' : 'R'}], ['T1w', 'surf/surface', 'surf/surface'], ['subj-01/T1w.nii.gz', 'subj-01/surf/L.white.gii', 'subj-01/surf/R.white.gii']),
ftman.FileGroup({'subject' : '02', 'boundary' : 'pial'}, [{}, {'hemi' : 'L'}, {'hemi' : 'R'}], ['T1w', 'surf/surface', 'surf/surface'], [None, 'subj-02/surf/L.pial.gii', 'subj-02/surf/R.pial.gii']),
ftman.FileGroup({'subject' : '02', 'boundary' : 'white'}, [{}, {'hemi' : 'L'}, {'hemi' : 'R'}], ['T1w', 'surf/surface', 'surf/surface'], [None, 'subj-02/surf/L.white.gii', 'subj-02/surf/R.white.gii']),
# ftman.FileGroup({'subject' : '03', 'boundary' : 'pial'}, [{}, {'hemi' : 'L'}, {'hemi' : 'R'}], ['T1w', 'surf/surface', 'surf/surface'], ['subj-03/T1w.nii.gz', None, None]),
ftman.FileGroup({'subject' : '03', 'boundary' : 'white'}, [{}, {'hemi' : 'L'}, {'hemi' : 'R'}], ['T1w', 'surf/surface', 'surf/surface'], ['subj-03/T1w.nii.gz', 'subj-03/surf/L.white.gii', 'subj-03/surf/R.white.gii'])],
None),
# cols where space=t1/mni should be removed
({'subject' : ['01', '02', '03'],
'hemi' : ['L']},
[('T1w', {}),
('surf_native/surface', {'space' : 'native'}),
('surf_native/surface', {'space' : 'mni'})],
[ftman.FileGroup({'subject' : '01', 'hemi' : 'L'}, [{}, {'space' : 'native'}], ['T1w', 'surf_native/surface'], ['subj-01/T1w.nii.gz', 'subj-01/native/L.native.gii']),
ftman.FileGroup({'subject' : '02', 'hemi' : 'L'}, [{}, {'space' : 'native'}], ['T1w', 'surf_native/surface'], ['subj-02/T1w.nii.gz', 'subj-02/native/L.native.gii']),
ftman.FileGroup({'subject' : '03', 'hemi' : 'L'}, [{}, {'space' : 'native'}], ['T1w', 'surf_native/surface'], ['subj-03/T1w.nii.gz', 'subj-03/native/L.native.gii'])],
[('T1w', {}),
('surf_native/surface', {'space' : 'native'})],
# pial col should be filtered
({'subject' : ['03'],
'hemi' : ['L', 'R']},
[('T1w', {}),
('surf/surface', {'boundary' : 'white'}),
('surf/surface', {'boundary' : 'pial'})],
[ftman.FileGroup({'subject' : '03', 'hemi' : 'L'}, [{}, {'boundary' : 'white'}], ['T1w', 'surf/surface'], ['subj-03/T1w.nii.gz', 'subj-03/surf/L.white.gii']),
ftman.FileGroup({'subject' : '03', 'hemi' : 'R'}, [{}, {'boundary' : 'white'}], ['T1w', 'surf/surface'], ['subj-03/T1w.nii.gz', 'subj-03/surf/R.white.gii'])],
[('T1w', {}),
('surf/surface', {'boundary' : 'white'})],
),
]
with _query(OrderedDict([('base', base), ('sub', sub)]), files) as query:
......
......@@ -5,6 +5,9 @@
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
from unittest import mock
import pytest
from . import run_cli_tests
......@@ -58,3 +61,16 @@ def test_render_3d():
extras = {
}
run_cli_tests('test_render_3d', cli_tests, extras=extras, scene='3d')
# regression test - use of depth texture on
# environments without float textures would
# cause an error because the texture normalise
# flag would not be set
def test_render_3d_no_float_textures():
with mock.patch('fsleyes.gl.textures.data.canUseFloatTextures',
return_value=(False, None, None)):
run_cli_tests('test_render_3d_no_float_textures',
'3d.nii.gz',
scene='3d')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment