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

Bugfix in VolumeOpts - was crashing on images with all

NaNs. TimeSeriesPanel uses the same (random) colour for unselected
overlays. It's a bit dodgy, I will refactor it some time in the future.
parent db741249
No related branches found
No related tags found
No related merge requests found
......@@ -267,11 +267,15 @@ class VolumeOpts(ImageOpts):
# on whether the image is 3D or 4D)
if np.prod(overlay.shape) > 2 ** 30:
sample = overlay.data[..., overlay.shape[-1] / 2]
self.dataMin = float(sample.min())
self.dataMax = float(sample.max())
self.dataMin = float(np.nanmin(sample))
self.dataMax = float(np.nanmax(sample))
else:
self.dataMin = float(overlay.data.min())
self.dataMax = float(overlay.data.max())
self.dataMin = float(np.nanmin(overlay.data))
self.dataMax = float(np.nanmax(overlay.data))
if np.any(np.isnan((self.dataMin, self.dataMax))):
self.dataMin = 0
self.dataMax = 0
dRangeLen = abs(self.dataMax - self.dataMin)
dMinDistance = dRangeLen / 10000.0
......
......@@ -26,6 +26,7 @@ import fsl.data.featimage as fslfeatimage
import fsl.data.image as fslimage
import fsl.data.strings as strings
import fsl.fslview.displaycontext as fsldisplay
import fsl.fslview.colourmaps as fslcmaps
import fsl.fslview.controls as fslcontrols
import fsl.utils.transform as transform
......@@ -463,6 +464,7 @@ class TimeSeriesPanel(plotpanel.PlotPanel):
self.__currentOverlay = None
self.__currentTs = None
self.__overlayColours = {}
self.Layout()
self.draw()
......@@ -620,9 +622,12 @@ class TimeSeriesPanel(plotpanel.PlotPanel):
currOverlay = current.overlay
if self.showAllCurrent:
overlays = [o for o in self._overlayList
if o is not currOverlay]
# Remove overlays for which the
# current location is out of bounds
locs = map(self.__getTimeSeriesLocation, overlays)
locovl = filter(lambda (l, o): l is not None,
zip(locs, overlays))
......@@ -635,9 +640,18 @@ class TimeSeriesPanel(plotpanel.PlotPanel):
extras.extend([ts for ts in tss if ts is not None])
for ts in tss:
ts.alpha = 0.5
ts.alpha = 1
ts.lineWidth = 0.5
# Use a random colour for each overlay,
# but use the same random colour each time
colour = self.__overlayColours.get(
ts.overlay,
fslcmaps.randomBrightColour())
ts.colour = colour
self.__overlayColours[ts.overlay] = colour
if isinstance(ts, FEATTimeSeries):
extras.extend(ts.getModelTimeSeries())
......
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