This pipeline opens the result of ICAalamelodic.m, lets the user interactively label the components that look like neuronal activity (rather than movement artefacts or noise), sort them by label, plots a final summary for the chosen components, and save the reordered maps and time series.


In [1]:
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
from scipy import io
%matplotlib inline 
import pylab

Open time series


In [2]:
import scipy.io as sio

In [3]:
# from http://stackoverflow.com/questions/3579568/choosing-a-file-in-python-with-simple-dialog
from Tkinter import Tk
from tkFileDialog import askopenfilename

Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
filename = askopenfilename() # show an "Open" dialog box and return the path to the selected file
print(filename)


/media/sophie/db554c18-e3eb-41e2-afad-7de1c92bf4a5/THDDCGCaMP62/100411series/100411alloncregcdFF20skfintminMB206Smith0_4_60TS.mat

In [4]:
Ua=sio.loadmat(filename)

In [5]:
DT=Ua['TSmean']

In [6]:
DT.shape


Out[6]:
(31289, 206)

In [7]:
S1=DT.shape

In [8]:
DTmean=np.zeros(S1)
DTvar=np.zeros(S1)
Var=np.zeros(S1[1])

In [9]:
for i in range(S1[1]):
    DTmean[:,i]=DT[:,i]-np.mean(DT[:,i],0)

In [10]:
for i in range(S1[1]):
    Var[i]=np.sqrt(np.var(DTmean[:,i]))
    DTvar[:,i]=DTmean[:,i]/Var[i]

In [11]:
DTvar.shape


Out[11]:
(31289, 206)

open maps


In [12]:
import nibabel as nb

In [13]:
# from http://stackoverflow.com/questions/3579568/choosing-a-file-in-python-with-simple-dialog
from Tkinter import Tk
from tkFileDialog import askopenfilename

Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
filename2 = askopenfilename() # show an "Open" dialog box and return the path to the selected file
print(filename2)


/media/test7/THDDCGCaMP62/100411series/100411alloncregcdFF20skfintminMB206Smith0_4_60IC.nii

In [14]:
img1 = nb.load(filename2)

In [15]:
data = img1.get_data()

In [16]:
S=data.shape

In [17]:
S


Out[17]:
(35, 22, 26, 206)

Zscore maps


In [18]:
Demean=np.zeros(S)
Dmaps=np.zeros(S)
Dvar=np.zeros(S)
Var=np.zeros(S[3])
D2=np.zeros([S[0],S[1],5,S[3]])
Tvar=np.zeros(S[3])

Transform the maps to have zero mean


In [19]:
for i in range(S[3]):
    Demean[:,:,:,i]=data[:,:,:,i]-np.mean(np.mean(np.mean(data[:,:,:,i],0),0),0)

Transform the maps to have unit variance and zscore


In [20]:
for i in range(S[3]):
    Dsq=np.reshape(Demean[:,:,:,i],S[0]*S[1]*S[2])
    Var[i]=np.sqrt(np.var(Dsq))
    Dvar=Demean[:,:,:,i]/Var[i]
    Dmaps[:,:,:,i]=Dvar-2.5
Dmaps[Dmaps<0]=0

Order ICs by variance


In [21]:
datao=data
Dmapso=Dmaps

In [22]:
plt.plot(Var)


Out[22]:
[<matplotlib.lines.Line2D at 0x7f2d3a9eb790>]

Separate maps in substacks, sort the independent components by brain regions


In [23]:
my_cmap=plt.cm.jet
my_cmap.set_bad(alpha=0)
Good_ICs=np.zeros(S[3])
Label_ICs=[]
pylab.rcParams['figure.figsize'] = (13, 2.5)

In [24]:
Dtemp=data[:,:,:,0]

In [25]:
%%javascript
IPython.OutputArea.auto_scroll_threshold =4000;



In [26]:
if S[2]>5:
    Nstack=5
    Int100=[(i+1)*100/Nstack for i in range(Nstack)]
    Percs=np.percentile(range(S[2]),Int100)
    Indices=np.split(range(S[2]),Percs)
    D1=np.zeros([S[0],S[1],Nstack])
    Dmean=Dtemp[:,:,range(Nstack)]
    for i in range(Nstack):
        Vmean=np.mean(Dtemp[:,:,Indices[i]],2)
        #Dmean[:,:,i]=np.max(Vmean,0)
        Dmean[:,:,i]=Vmean
else:
    Nstack=S[2]
    D1=np.zeros([S[0],S[1],S[2]])
    Dmean=data[:,:,range(S[2])]  
    Dmean=np.squeeze(Dtemp[:,:,:])


/usr/local/lib/python2.7/dist-packages/numpy/lib/shape_base.py:422: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  sub_arys.append(_nx.swapaxes(sary[st:end], axis, 0))

In [27]:
DTvar.shape


Out[27]:
(31289, 206)

In [28]:
S


Out[28]:
(35, 22, 26, 206)

In [29]:
# from http://stackoverflow.com/questions/3579568/choosing-a-file-in-python-with-simple-dialog
Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
filename = askopenfilename() # show an "Open" dialog box and return the path to the selected file
print(filename)


/media/test7/THDDCGCaMP62/100411series/100411seriesXk.mat

In [30]:
Ua=sio.loadmat(filename)
Xk=Ua['Xk']
#Xk[1,:]=Ua['Walk']

In [31]:
Xk.shape


Out[31]:
(31289, 6)

In [32]:
# from http://stackoverflow.com/questions/3579568/choosing-a-file-in-python-with-simple-dialog
from Tkinter import Tk
from tkFileDialog import askopenfilename

Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
filenamet = askopenfilename() # show an "Open" dialog box and return the path to the selected file
print(filenamet)
nimt=nb.load(filenamet)
Dtemp=np.squeeze(nimt.get_data())
Dtemp.shape


if S[2]>5:
    Nstack=5
    Int100=[(i+1)*100/Nstack for i in range(Nstack)]
    Percs=np.percentile(range(S[2]),Int100)
    Indices=np.split(range(S[2]),Percs)
    Dmean=np.zeros([S[0],S[1],Nstack])
    #Dmean=np.squeeze(data[:,:,range(Nstack),2])
    for i in range(Nstack):
        Vmean=np.mean(Dtemp[:,:,Indices[i]],2)
        Dmean[:,:,i]=Vmean

plt.imshow(Vmean,cmap=plt.cm.gray)


/media/test7/THDDCGCaMP62/100411series/MAX_100411alloncregcdFF20skfintminMB206Smith0_4_60IC.nii
Out[32]:
<matplotlib.image.AxesImage at 0x7f2d3a8090d0>

In [33]:
Xk=Xk.T

In [34]:
Label_ICs=[]

In [51]:
for j in range(S[3]):

    if S[2]>5:
        for i in range(Nstack):
            V=Dmaps[:,:,Indices[i],j]
            D1[:,:,i]=np.max(V,2)
        D2[:,:,:,j]=D1
        D1[D1==0]=np.nan
           
    else:
        for i in range(S[2]):
            V=Dmaps[:,:,i,j]
            D1[:,:,i]=V 
            

    print(j)
    for i in range(Nstack):
        plt.subplot(1,5,i+1)
        plt.imshow(Dmean[:,:,i],cmap=plt.cm.gray)
        plt.imshow(D1[:,:,i], cmap=my_cmap,interpolation='none')
        frame1 = plt.gca()
        frame1.axes.get_xaxis().set_visible(False)
        frame1.axes.get_yaxis().set_visible(False)
        
    plt.show()
    
   # plt.plot(TS_ROI[Order[j],:])
    plt.plot(DTvar[:,j])
    plt.plot(Xk[0,:]/np.std(Xk[0,:])+0.5,color=(1,0,0))   
    plt.plot(Xk[1,:]/np.std(Xk[1,:])+0.5,color=(0,1,0))
    plt.plot(Xk[2,:]/np.std(Xk[2,:])+0.5,color=(0.5,0.5,0))    
    #plt.plot(Xk[3,:]/np.std(Xk[1,:])+0.5,color=(0,0.5,1))
    
    plt.show()
    
    Label_ICs.append(raw_input())
    if Label_ICs[j]=='':
        Good_ICs[j]=0
    else:
        Good_ICs[j]=1


0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-51-7e5a74732beb> in <module>()
     34     plt.show()
     35 
---> 36     Label_ICs.append(raw_input())
     37     if Label_ICs[j]=='':
     38         Good_ICs[j]=0

/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.pyc in raw_input(self, prompt)
    687             self._parent_ident,
    688             self._parent_header,
--> 689             password=False,
    690         )
    691 

/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.pyc in _input_request(self, prompt, ident, parent, password)
    717             except KeyboardInterrupt:
    718                 # re-raise KeyboardInterrupt, to truncate traceback
--> 719                 raise KeyboardInterrupt
    720             else:
    721                 break

KeyboardInterrupt: 

In [ ]:
#zip(range(S[3]),Label_ICs)

In [40]:
set(Label_ICs)


Out[40]:
{'', 'alpha', 'beta', 'gamma'}

In [41]:
#Label_ICs[94]='M'

In [ ]:


In [43]:
Xk=Xk.T

In [42]:
Xk.shape


Out[42]:
(31289, 6)

In [52]:
Xksmoothed=np.zeros(Xk[range(3),:].shape)

Xksmoothed[0,:]=np.convolve(Xk[0,999:Xk.shape[1]-1000],np.ones(2000)/2000)

Xksmoothed[1,:]=np.convolve(Xk[1,999:Xk.shape[1]-1000],np.ones(2000)/2000)

Xksmoothed[2,:]=np.convolve(Xk[2,999:Xk.shape[1]-1000],np.ones(2000)/2000)

Xkdff=Xk[range(3),:]-Xksmoothed

In [53]:
Rsq=np.zeros((1,S[3]))
Betas=np.zeros((3,S[3]))

In [54]:
from sklearn import linear_model

In [55]:
algorithm = linear_model.LinearRegression()

In [56]:
for j in range(S[3]):
    model = algorithm.fit(Xkdff.T, DT[:,j])
    Betas[:,j] = model.coef_
    Rsq[:,j] = model.score(Xkdff.T,DT[:,j])

In [57]:
max(max(Rsq))


Out[57]:
0.27347871712173111

In [58]:
List1=[(Label_ICs[i],i) for i in range(S[3])]
Newlist=sorted(List1, key=lambda List1: List1[0])

Neworder=[Newlist[i][1] for i in range(S[3])]

NewDT=DTvar[:,Neworder[:]].T

for j in range(len(Neworder)):
    A=NewDT[:,j]
    V=np.sqrt(np.var(A))
    NewDT[:,j]=A/V

C1=np.zeros([16,3])
C1[0][:]=(1,0,0)
C1[1][:]=(0,1,0)
C1[2][:]=(0,0,1)
C1[3][:]=(0.8,0.8,0)
C1[4][:]=(0,1,1)
C1[5][:]=(1,0,1)
C1[6][:]=(1,0.5,0)
C1[7][:]=(0,1,0.5)
C1[8][:]=(0.5,0,1)
C1[9][:]=(0.8,0.8,0.5)
C1[10][:]=(0.5,1,1)
C1[11][:]=(1,0.5,1)
C1[12]=(0.5,0.5,0.5)
C1[13]=(0.2,0.5,0.5)
C1[14]=(0.5,0.2,0.5)
C1[15]=(0.5,0.5,0.2)
h=3

Newmaps=Dmaps[:,:,:,Neworder[:]]

L=len(set([Label_ICs[Neworder[i]] for i in range(len(Neworder))]))

Regionmaps=np.zeros([S[0],S[1],L,3])
Datasort=np.zeros([S[0],S[1],S[2],L,3])

Regionname=[]

DMapsordered=Dmapso[:,:,:,Neworder[:]]

j=0
i=0
k=Label_ICs[Neworder[0]]
m=0
Regionname.append(Label_ICs[Neworder[i]])
for i in range(len(Neworder)):
    
    #C2=C1[i%6][:]
    for l in range(3):
        M=np.max(np.squeeze(np.reshape(Newmaps[:,:,:,i],S[0]*S[1]*S[2])))
        Regionmaps[:,:,j,l]=Regionmaps[:,:,j,l]+0.6*np.max(DMapsordered[:,:,:,i],2)*C1[i%12+1][l]/M
        Datasort[:,:,:,j,l]=Datasort[:,:,:,j,l]+Dmaps[:,:,:,Neworder[i]]*C1[i%15+1][l] 
    i=i+1
    m=m+1
    if i<len(Neworder):
        k1=Label_ICs[Neworder[i]]
        
        
    if k1 != k:
        j=j+1
        k=k1
        m=0
        Regionname.append(Label_ICs[Neworder[i]])

pylab.rcParams['figure.figsize'] = (14, 5)
import scipy
from scipy import ndimage
j=0
m=0
L=0
k=Label_ICs[Neworder[0]]
for i in range(len(Neworder)):
    m=m+1
    
    
    if i<len(Neworder):
        k1=Label_ICs[Neworder[i]]
        
    if k1 != k:
        
        k=k1
        m=0
        
        plt.show()
        plt.figure(2*j+1)
        Rotated_Plot = ndimage.rotate(Regionmaps[:,:,j], -90)
        IM=plt.imshow(Rotated_Plot) 
        frame1 = plt.gca()
        frame1.axes.get_xaxis().set_visible(False)
        frame1.axes.get_yaxis().set_visible(False)
        j=j+1
        plt.figure(2*j)
        plt.plot(Xk[0,:]/np.std(Xk[0,:])+0.5,color=(1,0,0))   
        plt.plot(Xk[1,:]/np.std(Xk[1,:])+0.5,color=(0,1,0))
        plt.plot(Xk[2,:]/np.std(Xk[1,:])+0.5,color=(0.5,0.5,0))    
        #plt.plot(Xk[3,:]/np.std(Xk[1,:])+0.5,color=(0,0.5,1))
    plt.plot(NewDT[i,:]+h*m,color=C1[i%12+1][:])
    print(Neworder[i])
    print(Rsq[:,Neworder[i]])
    print(Betas[:,Neworder[i]])
plt.figure(2*j+1)
Rotated_Plot = ndimage.rotate(Regionmaps[:,:,j], -90)
IM=plt.imshow(Rotated_Plot)
frame1 = plt.gca()
frame1.axes.get_xaxis().set_visible(False)
frame1.axes.get_yaxis().set_visible(False)
print(Neworder)


0
[ 0.00057297]
[ 0.00118097 -0.00037869  0.00040502]
1
[ 0.00305997]
[ 0.00130102 -0.00175004  0.00136062]
2
[ 0.00521736]
[ 0.00037777  0.00164879 -0.00064747]
6
[ 0.00139542]
[-0.00016811  0.00049606 -0.00059936]
7
[ 0.00411605]
[  3.70774172e-05   5.57293259e-04  -3.90347226e-04]
8
[ 0.01146031]
[ 0.00049598  0.00077532 -0.00030965]
9
[ 0.00190528]
[ 0.00114325  0.00102525 -0.00061806]
11
[ 0.0116253]
[ 0.06324327  0.04449324 -0.01025199]
13
[ 0.00095404]
[ 0.00017629 -0.0002241   0.000145  ]
14
[ 0.00105004]
[ 0.00046232 -0.00106731  0.00135135]
16
[ 0.00302877]
[-0.00270334 -0.00199762  0.00178963]
17
[ 0.00174705]
[-0.00117502  0.0015966  -0.00281948]
19
[ 0.01096534]
[ 0.0005153   0.00331455 -0.00080803]
20
[ 0.00182129]
[-0.00071846  0.00035334  0.00035611]
21
[ 0.00323198]
[ 0.00070477  0.00041117 -0.0002281 ]
22
[ 0.00856318]
[-0.00084232 -0.00110679  0.00035031]
25
[ 0.00170039]
[ -1.16575995e-04   3.24016224e-04  -4.01588471e-05]
26
[ 0.00245625]
[  5.22052639e-05   5.43458086e-04  -3.09363748e-04]
27
[ 0.0063329]
[  3.10812028e-05   3.47617365e-03   8.77421949e-04]
28
[ 0.00775232]
[  2.84655204e-04   3.75997332e-05   1.00902917e-04]
29
[ 0.00106096]
[  8.46058877e-05  -3.87379357e-04   4.23511112e-04]
30
[ 0.00019854]
[  1.12610633e-04   2.12366112e-04   7.31095563e-05]
33
[ 0.06164738]
[-0.00116916 -0.00118019 -0.00036609]
34
[ 0.06276807]
[-0.00039263 -0.00027544 -0.00020464]
35
[ 0.01220594]
[ 0.01778309  0.0075997   0.00647156]
36
[ 0.02055295]
[ 0.00138498  0.00040734  0.00032732]
37
[ 0.14937474]
[ 0.00049049  0.00034934  0.00012967]
38
[ 0.02374928]
[ 0.00068674  0.00085336 -0.00022945]
39
[ 0.00197562]
[  1.21554956e-03  -9.42033237e-05  -1.66842056e-05]
40
[ 0.01799553]
[ -9.70386124e-04  -7.69629112e-04   5.38907974e-05]
42
[ 0.02305067]
[  4.19341028e-04   2.84508122e-04  -3.51557651e-05]
44
[ 0.01279732]
[ 0.00021371  0.00023992 -0.0001083 ]
46
[ 0.015382]
[ -2.31448164e-03  -2.51301788e-03   5.49398252e-05]
47
[ 0.00207634]
[-0.00030549  0.00041634 -0.0001509 ]
48
[ 0.06040915]
[  3.31099080e-04   1.20022362e-04   7.32965293e-05]
49
[ 0.00328283]
[ 0.00017173 -0.00020174  0.00033766]
50
[ 0.00064461]
[  2.65918650e-04  -1.45945293e-04   9.55977595e-05]
51
[ 0.00491015]
[ 0.00205911 -0.0006074   0.00038557]
52
[ 0.27347872]
[ 0.00247709  0.002257    0.0003891 ]
54
[ 0.02222743]
[ 0.00202104  0.00101134  0.00028532]
55
[ 0.03301662]
[  2.55921734e-04   1.04782086e-04   7.42187854e-05]
56
[ 0.01482508]
[ 0.00069462  0.00012308  0.00015345]
57
[ 0.20209889]
[ 0.00192626  0.00178271  0.00054366]
59
[ 0.00303223]
[ 0.00064763 -0.00039794  0.00031684]
60
[ 0.0048464]
[  3.45652429e-04  -2.30700052e-04   7.55958625e-05]
61
[ 0.00777165]
[ 0.00066757  0.00035027  0.00033826]
62
[ 0.05902515]
[ 0.00123756  0.00055698  0.00026794]
63
[ 0.00127042]
[  1.34049922e-04  -2.67427619e-04  -1.17223485e-05]
64
[ 0.1090839]
[ 0.00133515  0.00084818  0.00033965]
65
[ 0.15282705]
[ 0.00046934  0.00047744  0.00011645]
66
[ 0.06014093]
[ 0.00054405  0.0004168   0.00013734]
67
[ 0.04777293]
[  1.12465630e-03   1.06569692e-03  -8.56488159e-05]
68
[ 0.01732865]
[  1.11530759e-04   2.30367522e-04  -1.08690832e-05]
69
[ 0.03855324]
[ 0.08025647  0.0553629   0.02344595]
70
[ 0.13925673]
[ 0.0008083   0.0004243   0.00016249]
71
[ 0.01506641]
[  3.86407983e-04   2.33832962e-04   6.88190165e-05]
72
[ 0.00151236]
[  2.09437492e-04  -1.49251914e-05  -1.21336514e-04]
73
[ 0.00750872]
[  7.50689516e-04  -1.70234700e-05   1.83825071e-04]
74
[ 0.02651456]
[ 0.00128987  0.00052779  0.0001228 ]
75
[ 0.06729688]
[  4.54505721e-03   1.59135582e-03   3.75225449e-05]
76
[ 0.1300721]
[ 0.00554945  0.00459494  0.00119007]
77
[ 0.13147002]
[-0.0005117  -0.00027013 -0.00011704]
78
[ 0.19309131]
[-0.00495231 -0.00321457 -0.0011173 ]
79
[ 0.04781209]
[  5.04672094e-04   4.93731860e-04   6.25311588e-05]
80
[ 0.04098078]
[ 0.00267151  0.00085461  0.00058684]
81
[ 0.00208529]
[  5.59522775e-05  -6.13139937e-06   2.32695460e-04]
82
[ 0.09948367]
[-0.00848239 -0.00634848 -0.00138502]
83
[ 0.03518973]
[  2.71909840e-04   2.73356479e-04   8.66744289e-06]
84
[ 0.16072952]
[ 0.00376641  0.00216292  0.00101921]
85
[ 0.10401656]
[-0.00063702 -0.00051851 -0.00022708]
86
[ 0.00394238]
[ -4.26942505e-05  -2.75558798e-05  -1.73929678e-04]
87
[ 0.17206096]
[  1.07369623e-03   2.06882096e-03  -3.37813262e-05]
89
[ 0.073955]
[ 0.00154305  0.00088646  0.0005905 ]
90
[ 0.03180323]
[-0.00062957 -0.00023092 -0.00015997]
91
[ 0.17218433]
[ 0.00202181  0.00132366  0.00042658]
92
[ 0.05679452]
[ 0.00095599  0.00082654  0.00019491]
93
[ 0.08977419]
[ 0.00060029  0.00025758  0.0001848 ]
94
[ 0.22602068]
[-0.00632855 -0.00548013 -0.00105723]
95
[ 0.13910787]
[  5.45405467e-04   6.39788974e-04   7.96025319e-05]
96
[ 0.0031809]
[ 0.00058067  0.00016883 -0.00025777]
97
[ 0.15844451]
[ 0.00115271  0.00090643  0.00035959]
98
[ 0.04249189]
[  4.82107286e-04   2.58192029e-04   3.46729458e-05]
99
[ 0.04776588]
[-0.20038733 -0.05171487 -0.06597609]
100
[ 0.00074816]
[ -1.12319853e-05  -5.92554913e-05  -2.03471593e-05]
101
[ 0.07152903]
[ 0.00116607  0.00061219  0.00038276]
102
[ 0.02280282]
[ -1.89270595e-04  -3.02894222e-04   4.32989628e-05]
103
[ 0.1336872]
[-0.00892967 -0.00417406 -0.00208906]
105
[ 0.11428623]
[-0.00092774 -0.0004395  -0.00029696]
106
[ 0.02928191]
[ 0.00084881  0.00015775  0.00027106]
107
[ 0.08708185]
[ 0.0099349   0.00901044  0.00390681]
108
[ 0.00127267]
[  8.82417394e-05  -4.44903812e-05   9.13294168e-05]
109
[ 0.03011707]
[ -3.98887691e-04  -1.77217606e-04  -2.52867635e-05]
110
[ 0.01442023]
[  8.67102040e-05   8.38575828e-05  -1.10416871e-06]
111
[ 0.06257342]
[ 0.00214088  0.00091512  0.00069668]
112
[ 0.09400533]
[ 0.00043611  0.00051473  0.00017787]
113
[ 0.15374925]
[ 0.00089227  0.00059524  0.00013999]
114
[ 0.05513665]
[ 0.00179147  0.00183611  0.00064583]
116
[ 0.11403512]
[ 0.00147888  0.00119562  0.00047342]
117
[ 0.10920636]
[-0.00031629 -0.00014237 -0.00010269]
118
[ 0.05103958]
[  1.60539467e-03   1.67795334e-03   3.19570902e-05]
119
[ 0.13379621]
[ 0.00092213  0.00062158  0.00020986]
120
[ 0.09197128]
[ 0.00036395  0.00014599  0.00013004]
121
[ 0.04119541]
[-0.00341088 -0.00147106 -0.00146651]
122
[ 0.08544522]
[ 0.00051124  0.00033853  0.00020238]
123
[ 0.0028611]
[-0.00011148 -0.00010908  0.00016323]
124
[ 0.0473708]
[ 0.00035899  0.00022832  0.00011684]
125
[ 0.11440419]
[ 0.00392312  0.00297484  0.00131754]
126
[ 0.06849145]
[-0.00069293 -0.00045098 -0.00034079]
127
[ 0.00488329]
[  1.85093670e-04   2.38952529e-05   9.45964860e-05]
128
[ 0.03491802]
[ 0.00169777  0.00066576  0.00071443]
129
[ 0.05936739]
[ -3.17277879e-03  -2.88250977e-03  -9.36986514e-05]
130
[ 0.00319422]
[-0.00306093 -0.0082755   0.00099881]
131
[ 0.22163112]
[ 0.00546567  0.00344359  0.00082967]
132
[ 0.03314279]
[  8.49079620e-05   2.33650075e-04   2.09295553e-04]
133
[ 0.15510799]
[-3.28466193 -2.57488732 -1.17242041]
134
[ 0.08344658]
[ 0.55516903  0.33006825  0.15424327]
135
[ 0.0103521]
[  8.17137990e-05   1.50823788e-04  -6.51732794e-05]
136
[ 0.09873996]
[ 0.00043543  0.00022007  0.00017687]
137
[ 0.11796142]
[ 0.00073244  0.00065969  0.00020862]
138
[ 0.10175301]
[-0.01227441 -0.01192865 -0.00153512]
139
[ 0.03041668]
[-0.00050958 -0.00026073 -0.00036311]
140
[ 0.19141596]
[ 0.00120463  0.00131633  0.00026838]
141
[ 0.00460255]
[-0.04547016  0.1243207  -0.20753794]
142
[ 0.00541645]
[  1.13958393e-03  -4.04557978e-03   1.40385362e-05]
143
[ 0.06478808]
[ 0.00077053  0.00055831  0.00019568]
145
[ 0.0135849]
[  1.30832866e-04   1.33920322e-04   8.59411735e-05]
146
[ 0.02004721]
[ 0.00159671  0.00039193  0.00112168]
147
[ 0.14690068]
[ 0.00076651  0.00028543  0.00016359]
148
[ 0.020897]
[  1.08035924e-04   8.20468636e-05   1.27597509e-04]
149
[ 0.00593275]
[  8.71561542e-05   1.95512699e-04  -7.73713651e-05]
150
[ 0.02244381]
[ -6.24395550e-04  -2.83277675e-04  -6.64684773e-06]
151
[ 0.04322245]
[ 0.00046006  0.00035491  0.00018144]
152
[ 0.01165053]
[ -1.78253388e-04  -2.81132540e-05  -5.09139564e-05]
153
[ 0.07895613]
[ 0.00294724  0.00175384  0.00078225]
154
[ 0.03619528]
[ 0.00040435  0.00023159  0.00018908]
155
[ 0.07931514]
[ 0.0009411  0.0006102  0.0003156]
156
[ 0.04756853]
[ 0.0010243   0.00177956 -0.00019886]
157
[ 0.00167027]
[  6.01558663e-05   3.49363039e-05  -1.16075185e-05]
158
[ 0.01741516]
[  2.16439371e-04   1.01811724e-04   4.21838177e-06]
159
[ 0.17985981]
[ 0.00545446  0.00410138  0.0010999 ]
160
[ 0.00242727]
[-0.00040413  0.00013679 -0.00029457]
161
[ 0.05273076]
[ 0.00082646  0.00087062  0.00025106]
162
[ 0.02601782]
[ 0.000353    0.00017851  0.0001369 ]
163
[ 0.08372011]
[ 0.00097462  0.00067817  0.00027098]
164
[ 0.10582599]
[-0.00181711 -0.00100257 -0.00026634]
165
[ 0.07235819]
[ 0.00097703  0.00050959  0.00039474]
166
[ 0.00795517]
[  4.38910650e-05   6.32241673e-05   1.12657997e-04]
167
[ 0.04591013]
[  7.76736040e-05   1.28612710e-04  -2.20910251e-06]
168
[ 0.00843705]
[ 0.00011275 -0.00163547 -0.00053554]
169
[ 0.02204708]
[ -2.07090270e-04  -2.00976325e-05  -8.01167171e-05]
170
[ 0.14466648]
[ 0.00064478  0.00063779  0.00017041]
171
[ 0.03517822]
[ 0.00070255  0.00011747  0.00015707]
172
[ 0.15252359]
[  4.91730336e-04   4.17879946e-04   9.52528353e-05]
173
[ 0.05955385]
[ -2.98627821e-05  -1.54025904e-04  -2.01957132e-05]
174
[ 0.02902198]
[ 0.000624    0.00013201  0.00017625]
175
[ 0.0171845]
[  2.06599901e-04   9.92895149e-05   2.20356167e-05]
176
[ 0.15023242]
[ 0.00069727  0.00036941  0.00022741]
177
[ 0.08740932]
[-0.00568294 -0.00272889 -0.00124848]
178
[ 0.01817822]
[-0.00484428  0.0005149  -0.00165474]
179
[ 0.07062653]
[-0.00176566 -0.00121409 -0.00046673]
180
[ 0.11657098]
[ 0.00069408  0.00045252  0.00014221]
181
[ 0.00451129]
[  3.22601419e-04   1.65364106e-04   6.55936801e-05]
182
[ 0.05213458]
[ -1.77151096e-06   1.15146301e-03  -1.93763613e-06]
183
[ 0.0685741]
[-0.00928332 -0.00677948 -0.00382649]
184
[ 0.01353951]
[  2.50799741e-04   4.18195525e-05   8.73413175e-05]
185
[ 0.00234984]
[ -3.68474921e-05  -1.73298854e-05   6.52933426e-05]
186
[ 0.00189658]
[  1.24240881e-05  -8.98804947e-06   2.19912684e-05]
187
[ 0.04042091]
[ -1.09421572e-04  -2.36726567e-04   1.58225478e-05]
188
[ 0.02529597]
[ -2.22187233e-04  -1.53099168e-04  -2.07552350e-05]
189
[ 0.13415313]
[  1.15749060e-03   7.99538814e-04   4.57856186e-05]
190
[ 0.05868704]
[  1.37866982e-04   1.06257639e-04   1.18851757e-05]
191
[ 0.00304762]
[-0.00017469 -0.000253   -0.00019358]
192
[ 0.01400541]
[ -1.43171278e-04  -7.58125074e-05  -4.88042699e-05]
193
[ 0.00997654]
[ 0.00479854  0.00060214  0.00145027]
194
[ 0.00848212]
[ -7.18633095e-05   2.46613976e-05  -3.65492904e-05]
195
[ 0.00869028]
[ 0.00050641  0.0002775  -0.00013237]
196
[ 0.03139366]
[  3.33919234e-05   1.99191612e-04  -2.57389756e-05]
198
[ 0.00284571]
[  9.51143499e-05   2.42249515e-05  -2.89304331e-05]
199
[ 0.02021499]
[  1.05603289e-04   2.68974594e-05   5.49313493e-05]
200
[ 0.01108419]
[ -1.59267533e-04   3.53934471e-05  -5.91947828e-05]
201
[ 0.01680982]
[ -5.76476775e-06  -1.12980222e-04  -9.31269227e-05]
202
[ 0.02099341]
[ -3.75172856e-05  -1.08928415e-04   4.06762272e-05]
203
[ 0.03703434]
[ 0.00175477  0.00319291  0.00098607]
204
[ 0.02104949]
[  2.40549639e-04   3.15215181e-04  -1.46618738e-05]
205
[ 0.01037402]
[ -2.26750471e-05  -3.08997502e-05  -3.76561753e-06]
24
[ 0.00615433]
[ 0.00036834  0.0009575   0.00043853]
32
[ 0.0039632]
[ 0.00013425 -0.00018893 -0.00026359]
45
[ 0.00416805]
[ -1.42028195e-04  -2.37526581e-04   4.08878691e-05]
88
[ 0.02447239]
[ 0.0144697   0.00634848 -0.00336279]
144
[ 0.02602811]
[ 0.00036703  0.00024967  0.00024431]
197
[ 0.00858927]
[-0.0001166   0.00079813 -0.00044414]
10
[ 0.00210804]
[  1.24130954e-05   2.71186218e-04  -3.51327475e-04]
12
[ 0.03968471]
[ 0.0146608   0.00514938  0.00044511]
15
[ 0.01517912]
[-0.00084968 -0.00073848 -0.00094572]
18
[ 0.03789365]
[-0.00049815 -0.00034233 -0.00020627]
23
[ 0.00730566]
[ 0.00222103  0.00055584  0.0042988 ]
43
[ 0.00650989]
[ -5.68411831e-05  -9.46665411e-05   3.54085226e-05]
104
[ 0.03746003]
[ 0.0008555   0.00028725  0.00029841]
3
[ 0.16974401]
[ 0.0034445   0.00234131  0.00116138]
4
[ 0.03579985]
[ 0.0054421   0.00631761  0.00308767]
5
[ 0.03699357]
[ 0.00197756  0.00133676  0.00151937]
31
[ 0.04118636]
[ 0.00203547  0.00165723  0.00122187]
41
[ 0.04285258]
[ 0.00655772  0.00260166  0.00171196]
53
[ 0.02638086]
[ 0.0016544   0.00064488  0.00047737]
58
[ 0.01473388]
[-0.00165303 -0.0013008  -0.00153873]
115
[ 0.00643527]
[ 0.0006448   0.00066225  0.00028972]
[0, 1, 2, 6, 7, 8, 9, 11, 13, 14, 16, 17, 19, 20, 21, 22, 25, 26, 27, 28, 29, 30, 33, 34, 35, 36, 37, 38, 39, 40, 42, 44, 46, 47, 48, 49, 50, 51, 52, 54, 55, 56, 57, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 198, 199, 200, 201, 202, 203, 204, 205, 24, 32, 45, 88, 144, 197, 10, 12, 15, 18, 23, 43, 104, 3, 4, 5, 31, 41, 53, 58, 115]

In [ ]:
# from http://stackoverflow.com/questions/3579568/choosing-a-file-in-python-with-simple-dialog
Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
filename = askopenfilename() # show an "Open" dialog box and return the path to the selected file
print(filename)

In [ ]:
Ua=sio.loadmat(filename)
Xk=Ua['Xk']

In [63]:
plt.plot(Xkdff[range(3),:].T)


Out[63]:
[<matplotlib.lines.Line2D at 0x7f8896c45810>,
 <matplotlib.lines.Line2D at 0x7f8896c45a10>,
 <matplotlib.lines.Line2D at 0x7f8896c45c10>]

In [ ]: