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

Moved demean/usePixdim logic from PlotPanel to TSPanel where it belongs

parent 9a4da06a
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,7 @@ class DataSeries(props.HasProperties): ...@@ -42,6 +42,7 @@ class DataSeries(props.HasProperties):
('-.', 'Dash-dot line'), ('-.', 'Dash-dot line'),
(':', 'Dotted line')])) (':', 'Dotted line')]))
def __init__(self, overlay): def __init__(self, overlay):
self.overlay = overlay self.overlay = overlay
...@@ -257,20 +258,15 @@ class PlotPanel(viewpanel.ViewPanel): ...@@ -257,20 +258,15 @@ class PlotPanel(viewpanel.ViewPanel):
if ds.alpha == 0: if ds.alpha == 0:
return (0, 0), (0, 0) return (0, 0), (0, 0)
ydata = np.array(ds.getData(), dtype=np.float32) xdata, ydata = ds.getData()
npoints = len(ydata)
if self.demean:
ydata = ydata - ydata.mean()
if self.smooth: if self.smooth:
tck = interp.splrep(np.arange(npoints), ydata) tck = interp.splrep(xdata, ydata)
ydata = interp.splev(np.linspace(0, npoints - 1, 5 * npoints), tck) xdata = np.linspace(xdata[0],
xdata[-1],
xdata = np.linspace(0, npoints - 1, len(ydata), dtype=np.float32) len(xdata) * 5,
dtype=np.float32)
if self.usePixdim: ydata = interp.splev(xdata, tck)
xdata *= ds.overlay.pixdim[3]
if self.xLogScale: xdata = np.log10(xdata) if self.xLogScale: xdata = np.log10(xdata)
if self.yLogScale: ydata = np.log10(ydata) if self.yLogScale: ydata = np.log10(ydata)
......
...@@ -30,23 +30,33 @@ log = logging.getLogger(__name__) ...@@ -30,23 +30,33 @@ log = logging.getLogger(__name__)
class TimeSeries(plotpanel.DataSeries): class TimeSeries(plotpanel.DataSeries):
def __init__(self, overlay, coords): def __init__(self, tsPanel, overlay, coords):
plotpanel.DataSeries.__init__(self, overlay) plotpanel.DataSeries.__init__(self, overlay)
self.coords = map(int, coords) self.tsPanel = tsPanel
self.data = overlay.data[coords[0], coords[1], coords[2], :] self.coords = map(int, coords)
self.data = overlay.data[coords[0], coords[1], coords[2], :]
def getData(self): 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): class TimeSeriesPanel(plotpanel.PlotPanel):
"""A panel with a :mod:`matplotlib` canvas embedded within. """A panel with a :mod:`matplotlib` canvas embedded within.
The volume data for each of the overlay objects in the The volume data for each of the overlay objects in the
:class:`.OverlayList`, at the current :attr:`.DisplayContext.location` is :class:`.OverlayList`, at the current :attr:`.DisplayContext.location`
plotted on the canvas. is plotted on the canvas.
""" """
...@@ -136,7 +146,7 @@ class TimeSeriesPanel(plotpanel.PlotPanel): ...@@ -136,7 +146,7 @@ class TimeSeriesPanel(plotpanel.PlotPanel):
vox[2] >= overlay.shape[2]: vox[2] >= overlay.shape[2]:
return return
ts = TimeSeries(overlay, vox) ts = TimeSeries(self, overlay, vox)
ts.colour = [0.2, 0.2, 0.2] ts.colour = [0.2, 0.2, 0.2]
ts.lineWidth = 1 ts.lineWidth = 1
ts.lineStyle = ':' ts.lineStyle = ':'
......
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