diff --git a/fsl/fslview/views/plotpanel.py b/fsl/fslview/views/plotpanel.py index e49041b1d2c653dc932aed535ff6996f24967c3f..b535261eda68080c6e5c43a03ff44121e580199a 100644 --- a/fsl/fslview/views/plotpanel.py +++ b/fsl/fslview/views/plotpanel.py @@ -42,6 +42,7 @@ class DataSeries(props.HasProperties): ('-.', 'Dash-dot line'), (':', 'Dotted line')])) + def __init__(self, overlay): self.overlay = overlay @@ -257,20 +258,15 @@ class PlotPanel(viewpanel.ViewPanel): if ds.alpha == 0: return (0, 0), (0, 0) - ydata = np.array(ds.getData(), dtype=np.float32) - npoints = len(ydata) - - if self.demean: - ydata = ydata - ydata.mean() + xdata, ydata = ds.getData() if self.smooth: - tck = interp.splrep(np.arange(npoints), ydata) - ydata = interp.splev(np.linspace(0, npoints - 1, 5 * npoints), tck) - - xdata = np.linspace(0, npoints - 1, len(ydata), dtype=np.float32) - - if self.usePixdim: - xdata *= ds.overlay.pixdim[3] + tck = interp.splrep(xdata, ydata) + xdata = np.linspace(xdata[0], + xdata[-1], + len(xdata) * 5, + dtype=np.float32) + ydata = interp.splev(xdata, tck) if self.xLogScale: xdata = np.log10(xdata) if self.yLogScale: ydata = np.log10(ydata) diff --git a/fsl/fslview/views/timeseriespanel.py b/fsl/fslview/views/timeseriespanel.py index 6094bd463ba4a68f74d8d21dee91795853508f25..d4a0b7259f88fdfd8bf5bdb497f7f19b466528e8 100644 --- a/fsl/fslview/views/timeseriespanel.py +++ b/fsl/fslview/views/timeseriespanel.py @@ -30,23 +30,33 @@ log = logging.getLogger(__name__) class TimeSeries(plotpanel.DataSeries): - def __init__(self, overlay, coords): + def __init__(self, tsPanel, overlay, coords): plotpanel.DataSeries.__init__(self, overlay) - - self.coords = map(int, coords) - self.data = overlay.data[coords[0], coords[1], coords[2], :] + + self.tsPanel = tsPanel + self.coords = map(int, coords) + self.data = overlay.data[coords[0], coords[1], coords[2], :] def getData(self): - return self.data + ydata = np.array( self.data, dtype=np.float32) + xdata = np.arange(len(ydata), dtype=np.float32) + + if self.tsPanel.usePixdim: + xdata *= self.overlay.pixdim[3] + + if self.tsPanel.demean: + ydata = ydata - ydata.mean() + + return xdata, ydata class TimeSeriesPanel(plotpanel.PlotPanel): """A panel with a :mod:`matplotlib` canvas embedded within. The volume data for each of the overlay objects in the - :class:`.OverlayList`, at the current :attr:`.DisplayContext.location` is - plotted on the canvas. + :class:`.OverlayList`, at the current :attr:`.DisplayContext.location` + is plotted on the canvas. """ @@ -136,7 +146,7 @@ class TimeSeriesPanel(plotpanel.PlotPanel): vox[2] >= overlay.shape[2]: return - ts = TimeSeries(overlay, vox) + ts = TimeSeries(self, overlay, vox) ts.colour = [0.2, 0.2, 0.2] ts.lineWidth = 1 ts.lineStyle = ':'