2010-03-22 05:48:52 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2010-03-22 06:21:56 +00:00
|
|
|
## Add path to library (just for examples; you do not need this)
|
|
|
|
import sys, os
|
2011-04-05 16:53:05 +00:00
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
|
2010-03-22 05:48:52 +00:00
|
|
|
|
2011-04-05 14:35:50 +00:00
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
import scipy
|
2012-03-02 03:58:02 +00:00
|
|
|
from pyqtgraph.Qt import QtCore, QtGui
|
2011-04-05 14:35:50 +00:00
|
|
|
import pyqtgraph as pg
|
2010-03-22 05:48:52 +00:00
|
|
|
|
|
|
|
app = QtGui.QApplication([])
|
2010-03-22 06:21:56 +00:00
|
|
|
|
|
|
|
## Create window with ImageView widget
|
2010-03-22 05:48:52 +00:00
|
|
|
win = QtGui.QMainWindow()
|
2011-06-14 23:47:52 +00:00
|
|
|
win.resize(800,800)
|
2011-04-05 14:35:50 +00:00
|
|
|
imv = pg.ImageView()
|
2010-03-22 05:48:52 +00:00
|
|
|
win.setCentralWidget(imv)
|
|
|
|
win.show()
|
|
|
|
|
2011-04-05 14:35:50 +00:00
|
|
|
## Create random 3D data set with noisy signals
|
|
|
|
img = scipy.ndimage.gaussian_filter(np.random.normal(size=(200, 200)), (5, 5)) * 20 + 100
|
|
|
|
img = img[np.newaxis,:,:]
|
|
|
|
decay = np.exp(-np.linspace(0,0.3,100))[:,np.newaxis,np.newaxis]
|
|
|
|
data = np.random.normal(size=(100, 200, 200))
|
2010-07-24 18:29:09 +00:00
|
|
|
data += img * decay
|
|
|
|
|
|
|
|
#for i in range(data.shape[0]):
|
|
|
|
#data[i] += 10*exp(-(2.*i)/data.shape[0])
|
|
|
|
data += 2
|
|
|
|
|
|
|
|
## Add time-varying signal
|
2011-04-05 14:35:50 +00:00
|
|
|
sig = np.zeros(data.shape[0])
|
|
|
|
sig[30:] += np.exp(-np.linspace(1,10, 70))
|
|
|
|
sig[40:] += np.exp(-np.linspace(1,10, 60))
|
|
|
|
sig[70:] += np.exp(-np.linspace(1,10, 30))
|
2010-07-24 18:29:09 +00:00
|
|
|
|
2011-04-05 14:35:50 +00:00
|
|
|
sig = sig[:,np.newaxis,np.newaxis] * 3
|
2010-07-24 18:29:09 +00:00
|
|
|
data[:,50:60,50:60] += sig
|
|
|
|
|
2010-03-22 06:21:56 +00:00
|
|
|
|
|
|
|
## Display the data
|
2011-04-05 14:35:50 +00:00
|
|
|
imv.setImage(data, xvals=np.linspace(1., 3., data.shape[0]))
|
2010-03-22 06:21:56 +00:00
|
|
|
|
2011-04-05 14:35:50 +00:00
|
|
|
## Start Qt event loop unless running in interactive mode.
|
|
|
|
if sys.flags.interactive != 1:
|
|
|
|
app.exec_()
|