Index: examples/pylab_examples/mri_with_eeg.py
===================================================================
--- examples/pylab_examples/mri_with_eeg.py	(revision 7524)
+++ examples/pylab_examples/mri_with_eeg.py	(working copy)
@@ -9,6 +9,7 @@
 
 from matplotlib.pyplot import *
 from matplotlib.collections import LineCollection
+import matplotlib.mlab as mlab
 
 # I use if 1 to break up the different regions of code visually
 
@@ -71,5 +72,26 @@
     ax.set_yticklabels(['PG3', 'PG5', 'PG7', 'PG9'])
 
     xlabel('time (s)')
+    
+    #use mlab.cohere_pairs in order to examine the coherence between electrode
+    #pairs:
 
+    mat = np.zeros((data.shape[-1],data.shape[-1]))
+    ij = []
+    for i in xrange(data.shape[-1]):
+        for j in xrange(i+1,data.shape[-1]):
+            ij += [(i,j)]
+
+    Cxy,phase,freqs = mlab.cohere_pairs(data,ij)
+
+    for i,j in ij:
+        mat[i,j] += Cxy[(i,j)]
+
+    fig = matshow(mat)
+    title('Pairwise coherence between electrodes')
+    fig.set_cmap('Reds')
+    fig.axes.set_yticklabels(['','PG3', 'PG5', 'PG7', 'PG9'])
+    fig.axes.set_xticklabels(['','PG3', 'PG5', 'PG7', 'PG9'])
+    colorbar()
+
 show()
