From a7fcf7e28aa101bd164f99c36b666d4846bff86a Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Wed, 8 Jul 2015 15:12:15 +0100 Subject: [PATCH] Bug fix to contrast vector normalisation - sum of squares, not squared sum. 'Current time course' settings only shown if current time course is being shown. Other little changes. --- fsl/data/featimage.py | 2 +- .../controls/timeseriescontrolpanel.py | 65 +++++++++++++------ fsl/fslview/views/timeseriespanel.py | 11 +++- 3 files changed, 53 insertions(+), 25 deletions(-) diff --git a/fsl/data/featimage.py b/fsl/data/featimage.py index 77eeb1ee6..384dfd0a5 100644 --- a/fsl/data/featimage.py +++ b/fsl/data/featimage.py @@ -210,7 +210,7 @@ class FEATImage(fslimage.Image): if not fullmodel: contrast = np.array(contrast) - contrast /= np.sqrt(contrast.sum() ** 2) + contrast /= np.sqrt((contrast ** 2).sum()) x, y, z = xyz numEVs = self.numEVs() diff --git a/fsl/fslview/controls/timeseriescontrolpanel.py b/fsl/fslview/controls/timeseriescontrolpanel.py index 461eefc96..bdec0f8e0 100644 --- a/fsl/fslview/controls/timeseriescontrolpanel.py +++ b/fsl/fslview/controls/timeseriescontrolpanel.py @@ -30,11 +30,6 @@ class TimeSeriesControlPanel(fslpanel.FSLViewPanel): tsProps = ['demean', 'usePixdim', 'showCurrent'] - curProps = ['currentColour', - 'currentAlpha', - 'currentLineWidth', - 'currentLineStyle'] - plotProps = ['xLogScale', 'yLogScale', 'smooth', @@ -48,22 +43,6 @@ class TimeSeriesControlPanel(fslpanel.FSLViewPanel): props.makeWidget(self.__widgets, tsPanel, prop), displayName=strings.properties[tsPanel, prop]) - self.__widgets.AddGroup('currentSettings', - strings.labels[self, 'currentSettings']) - - # TODO Hide these when tsPanel.showCurrent is false - for prop in curProps: - if prop == 'currentAlpha': - kwargs = {'showLimits' : False, 'spin' : False} - else: - kwargs = {} - - self.__widgets.AddWidget( - props.makeWidget(self.__widgets, tsPanel, prop, **kwargs), - displayName=strings.properties[tsPanel, prop], - groupName='currentSettings') - - self.__widgets.AddGroup( 'plotSettings', strings.labels[tsPanel, 'plotSettings']) @@ -115,6 +94,12 @@ class TimeSeriesControlPanel(fslpanel.FSLViewPanel): self._name, self.__selectedOverlayChanged) + tsPanel.addListener('showCurrent', + self._name, + self.__showCurrentChanged) + + self.__showCurrentChanged() + # This attribute keeps track of the currently # selected overlay, but only if said overlay # is a FEATImage. @@ -131,6 +116,44 @@ class TimeSeriesControlPanel(fslpanel.FSLViewPanel): display.removeListener('name', self._name) + def __showCurrentChanged(self, *a): + widgets = self.__widgets + tsPanel = self.__tsPanel + showCurrent = tsPanel.showCurrent + areShown = widgets.HasGroup('currentSettings') + + if (not showCurrent) and areShown: + widgets.RemoveGroup('currentSettings') + + elif showCurrent and (not areShown): + + self.__widgets.AddGroup('currentSettings', + strings.labels[self, 'currentSettings']) + + colour = props.makeWidget(widgets, tsPanel, 'currentColour') + alpha = props.makeWidget(widgets, tsPanel, 'currentAlpha', + showLimits=False, spin=False) + lineWidth = props.makeWidget(widgets, tsPanel, 'currentLineWidth') + lineStyle = props.makeWidget(widgets, tsPanel, 'currentLineStyle') + + self.__widgets.AddWidget( + colour, + displayName=strings.properties[tsPanel, 'currentColour'], + groupName='currentSettings') + self.__widgets.AddWidget( + alpha, + displayName=strings.properties[tsPanel, 'currentAlpha'], + groupName='currentSettings') + self.__widgets.AddWidget( + lineWidth, + displayName=strings.properties[tsPanel, 'currentLineWidth'], + groupName='currentSettings') + self.__widgets.AddWidget( + lineStyle, + displayName=strings.properties[tsPanel, 'currentLineStyle'], + groupName='currentSettings') + + def __selectedOverlayNameChanged(self, *a): display = self._displayCtx.getDisplay(self.__selectedOverlay) self.__widgets.RenameGroup( diff --git a/fsl/fslview/views/timeseriespanel.py b/fsl/fslview/views/timeseriespanel.py index 0668476e1..e5c26f64c 100644 --- a/fsl/fslview/views/timeseriespanel.py +++ b/fsl/fslview/views/timeseriespanel.py @@ -29,6 +29,7 @@ import fsl.utils.transform as transform log = logging.getLogger(__name__) + class TimeSeries(plotpanel.DataSeries): @@ -198,7 +199,7 @@ class FEATTimeSeries(TimeSeries): self.overlay, self.coords) - pets.colour = (1, 0, 0) + pets.colour = (0.7, 0, 0) pets.alpha = self.alpha pets.label = self.label pets.lineWidth = self.lineWidth @@ -322,7 +323,6 @@ class TimeSeriesPanel(plotpanel.PlotPanel): self.addListener('usePixdim', self._name, self.draw) self.addListener('showCurrent', self._name, self.draw) - csc = self.__currentSettingsChanged self.addListener('currentColour', self._name, csc) self.addListener('currentAlpha', self._name, csc) @@ -344,7 +344,12 @@ class TimeSeriesPanel(plotpanel.PlotPanel): tss.extend(self.__currentTs.getModelTimeSeries()) for ts in tss: - ts.colour = self.currentColour + + # Don't change the colour for associated + # time courses (e.g. model fits) + if ts is self.__currentTs: + ts.colour = self.currentColour + ts.alpha = self.currentAlpha ts.lineWidth = self.currentLineWidth ts.lineStyle = self.currentLineStyle -- GitLab