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/test/FlyLFMDataSet/TH-DDC-GCaMP6SpontaneousBehavior/TDGSB2/TDGSB2_psfproj_dff_kfMB130Smith0_4_60TS.mat

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

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

In [7]:
DT.shape


Out[7]:
(10134, 130)

In [8]:
S1=DT.shape

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

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

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

In [12]:
DTvar.shape


Out[12]:
(10134, 130)

open maps


In [13]:
import nibabel as nb

In [14]:
# 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/test/FlyLFMDataSet/TH-DDC-GCaMP6SpontaneousBehavior/TDGSB2/TDGSB2_psfproj_dff_kfMB130Smith0_4_60IC.nii

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

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

In [17]:
S=data.shape

In [18]:
S


Out[18]:
(42, 25, 7, 130)

Zscore maps


In [19]:
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 [20]:
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 [21]:
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 [22]:
datao=data
Dmapso=Dmaps

In [23]:
plt.plot(Var)


Out[23]:
[<matplotlib.lines.Line2D at 0x7fbe1f6b0890>]

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


In [24]:
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 [25]:
Dtemp=data[:,:,:,0]

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



In [27]:
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 [28]:
DTvar.shape


Out[28]:
(10134, 130)

In [29]:
S


Out[29]:
(42, 25, 7, 130)

In [30]:
# 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/test/FlyLFMDataSet/TH-DDC-GCaMP6SpontaneousBehavior/TDGSB2/TDGSB2Xk.mat

In [31]:
Ua


Out[31]:
{'TSmean': array([[ -1.30928724e-03,   3.27551311e-03,   2.01522462e-03, ...,
          -2.60707016e-02,  -3.62575765e-03,  -8.86195027e-04],
        [ -7.31263299e-04,   4.99258504e-03,   1.85308746e-04, ...,
           1.46605853e-02,   7.09971240e-03,  -1.10019383e-03],
        [  2.58744917e-03,   4.18905320e-03,  -1.47807594e-03, ...,
          -9.76553021e-04,  -8.20430551e-04,   4.67077090e-04],
        ..., 
        [ -7.19766786e-04,   1.93474263e-03,   8.59271112e-04, ...,
           1.43019938e-02,  -2.46523499e-03,  -7.70251270e-05],
        [ -7.66658799e-04,   2.57275300e-03,   8.06894293e-04, ...,
           3.63485979e-03,  -2.55587311e-03,  -8.03288875e-04],
        [ -4.70430608e-04,   2.47938973e-03,   1.00394364e-03, ...,
           1.59160977e-03,  -1.48774741e-03,  -4.22498423e-04]]),
 '__globals__': [],
 '__header__': 'MATLAB 5.0 MAT-file, Platform: GLNXA64, Created on: Tue Apr  9 10:19:25 2019',
 '__version__': '1.0'}

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

In [33]:
# 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/test/FlyLFMDataSet/TH-DDC-GCaMP6SpontaneousBehavior/TDGSB2/MAX_TDGSB2_psfproj_dff_kfMB130Smith0_4_60IC.nii
Out[33]:
<matplotlib.image.AxesImage at 0x7fbe1e291c50>

In [34]:
Xk=Xk.T

In [35]:
Label_ICs=[]

In [36]:
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
/usr/local/lib/python2.7/dist-packages/numpy/ma/core.py:4185: UserWarning: Warning: converting a masked element to nan.
  warnings.warn("Warning: converting a masked element to nan.")
1
gamma
2
gamma
3
4
5
gamma
6
7
8
9
gamma
10
11
12
13
gamma
14
gamma
15
16
gamma
17
18
beta
19
beta
20
gamma
21
22
23
24
alpha
25
gamma
26
27
28
alpha
29
beta
30
31
32
33
gamma
34
gamma
35
alpha
36
beta
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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
88
89
90
91
92
93
94
95
96
97
98
99
alpha
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129


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

In [38]:
set(Label_ICs)


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

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

In [39]:
Xksmoothed=np.zeros(Xk.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-Xksmoothed

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

In [41]:
from sklearn import linear_model

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

In [43]:
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 [44]:
max(max(Rsq))


Out[44]:
0.60047305147886632

In [45]:
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.03774626]
[ -1.04384904e-04  -6.84836691e-05   2.40911626e-04]
3
[ 0.48256736]
[  2.42764247e-04   1.34345966e-04   3.27301152e-05]
4
[ 0.0571427]
[  6.43350524e-05   1.11462658e-04  -2.13985266e-04]
6
[ 0.219365]
[  3.63507187e-05   5.82252787e-05   2.73679044e-05]
7
[ 0.02562058]
[  8.08595875e-05   1.23306905e-04  -3.41595610e-04]
8
[ 0.4420752]
[-0.00126411 -0.00094884  0.00011549]
10
[ 0.45995316]
[-0.00075654 -0.00068773 -0.00089207]
11
[ 0.11568772]
[ -2.17236884e-05  -2.44382544e-05  -3.83096743e-06]
12
[ 0.01694978]
[ 0.00026432  0.00012989 -0.00055416]
15
[ 0.47814612]
[ 0.00030134  0.00012365  0.00092787]
17
[ 0.04331681]
[ -1.55612789e-05  -6.36641194e-06   1.65015800e-06]
21
[ 0.28229165]
[  3.99884512e-05   3.98962004e-05   4.42145058e-05]
22
[ 0.03296847]
[ -4.05086081e-06  -6.57472695e-06   1.25703377e-05]
23
[ 0.01915944]
[ -1.42044843e-05  -3.05156872e-05   6.45104652e-05]
26
[ 0.05786841]
[ -5.70941628e-05  -4.74200482e-05  -6.28138738e-06]
27
[ 0.60047305]
[  3.51089944e-05   3.12355512e-05  -4.81617317e-06]
30
[ 0.50599479]
[  5.79858039e-05   4.89154294e-05   5.00069705e-05]
31
[ 0.0331058]
[ -1.33707869e-05  -1.69295281e-05  -4.51977623e-05]
32
[ 0.27248383]
[  1.37039675e-04   1.21503080e-04   9.19039658e-05]
37
[ 0.10807853]
[ -7.56604021e-05  -3.19911189e-05  -4.23592928e-06]
38
[ 0.46867563]
[  8.11707673e-05   7.01495461e-05   6.80715745e-05]
39
[ 0.49843283]
[  3.89139320e-05   3.37171407e-05   4.77792801e-05]
40
[ 0.57079685]
[  3.69342682e-05   8.34382368e-05  -1.02005758e-05]
41
[ 0.14693569]
[-0.00043139 -0.00032591 -0.00049382]
42
[ 0.29858969]
[-0.00021823 -0.00026358 -0.00023865]
43
[ 0.08126448]
[  3.39426052e-05   1.96245115e-05  -1.95869522e-05]
44
[ 0.08943824]
[ -4.40506002e-06  -8.81674799e-06   8.59257014e-06]
45
[ 0.39230001]
[ 0.00021465  0.00012889  0.00010876]
46
[ 0.00168818]
[  6.68968038e-06   4.64151618e-06  -3.72491026e-05]
47
[ 0.21339519]
[ 0.00030408  0.00079834  0.00036257]
48
[ 0.14160512]
[  4.46635552e-05   4.66726168e-05  -3.28248337e-06]
49
[ 0.20450554]
[ -2.00651355e-05  -3.83420287e-05  -2.86083330e-05]
50
[ 0.46477778]
[  3.46682103e-05   2.79465133e-05   3.78083778e-05]
51
[ 0.07008145]
[  4.88499467e-06   1.24323108e-05   2.16140675e-06]
52
[ 0.41229929]
[ -3.43464929e-05  -2.50646433e-05  -2.35169710e-05]
53
[ 0.29698392]
[  4.10320395e-05   2.34605072e-05   3.35337468e-05]
54
[ 0.09361622]
[  6.25140293e-05   1.85341723e-05   4.93210035e-05]
55
[ 0.26677973]
[ -1.34583623e-04  -1.05702285e-04   4.54793837e-05]
56
[ 0.30976103]
[ 0.00031837  0.00025394  0.00013794]
57
[ 0.26518077]
[-0.00016323 -0.00014544 -0.00020795]
58
[ 0.31804772]
[  1.56344458e-05   2.20738003e-05   5.45163735e-06]
59
[ 0.02104248]
[ -1.66521773e-06  -2.39558769e-06   1.00429259e-06]
60
[ 0.46240084]
[  4.70636553e-05   3.00754164e-05  -7.54755172e-06]
61
[ 0.12945658]
[  1.10032496e-05   1.14157586e-05   3.32120515e-05]
62
[ 0.09205227]
[-0.00069914  0.00415637 -0.00233527]
63
[ 0.00670171]
[  2.94711864e-06  -1.87510624e-07  -3.37972441e-05]
64
[ 0.12615322]
[ -6.95061467e-05  -8.98748484e-05  -1.12426619e-04]
65
[ 0.26281461]
[ -3.39215364e-05  -2.44304138e-05   7.35059102e-06]
66
[ 0.45265741]
[  5.23263736e-05   3.23747614e-05   1.36785117e-05]
67
[ 0.17285042]
[  1.80125736e-05   1.00382860e-05   2.50259993e-05]
68
[ 0.27326271]
[ -8.81308737e-05  -1.01881854e-04  -8.63320220e-05]
69
[ 0.21130057]
[-0.00011196 -0.00013098 -0.00013121]
70
[ 0.22964897]
[  4.82482131e-05   9.15609148e-05   6.50549738e-05]
71
[ 0.42400673]
[  5.16673620e-05   5.51827463e-05  -8.05442928e-06]
72
[ 0.30186495]
[  2.96601827e-04   1.94033682e-04   1.93008120e-05]
73
[ 0.19035626]
[  1.50267455e-05   8.94533131e-06   8.27617083e-06]
74
[ 0.29600754]
[  4.29113468e-05   3.76823075e-05   2.39741547e-05]
75
[ 0.27437601]
[  6.50719953e-06   5.72180894e-06   4.92973872e-06]
76
[ 0.12878312]
[  1.76621396e-05   1.51346928e-05   3.76747643e-05]
77
[ 0.34493634]
[  4.81735446e-05   2.63528764e-05   5.05598741e-06]
78
[ 0.00994859]
[  2.60171687e-06  -7.69181404e-06   2.41249561e-05]
79
[ 0.11777402]
[  4.61798392e-05   2.73616924e-05   1.02204364e-04]
80
[ 0.27344295]
[ -1.47041298e-05  -1.62870141e-05  -3.74002332e-06]
81
[ 0.01185247]
[ -7.23630154e-07  -3.26027651e-06   7.08184149e-06]
82
[ 0.00288252]
[ -2.56491823e-06  -3.30415591e-07   6.68018788e-06]
83
[ 0.0451707]
[ -3.32598215e-06  -4.79745116e-06   6.13876401e-06]
84
[ 0.2042162]
[ -3.57813454e-05  -4.97155319e-05  -1.78266016e-05]
85
[ 0.01315525]
[ -1.59584558e-06   1.38712002e-05   1.26142288e-04]
86
[ 0.28575918]
[  1.80227870e-05   1.88031574e-05   1.69375314e-05]
87
[ 0.11758218]
[  6.87596227e-06   1.15842381e-05   3.18320166e-05]
88
[ 0.32633007]
[  1.40579276e-05   1.02010074e-05   9.99715615e-06]
89
[ 0.08657182]
[  7.22759254e-06   7.18268189e-06   1.29436715e-05]
90
[ 0.01973976]
[ -7.23974599e-06   1.67227290e-05   3.30442166e-05]
91
[ 0.23922309]
[ -1.28548108e-05  -9.08663852e-06  -9.24761093e-06]
92
[ 0.20636072]
[ -1.00537952e-04  -7.64763416e-05  -5.46365496e-05]
93
[ 0.05196994]
[ -4.10772775e-05  -4.52168443e-05  -7.69585067e-05]
94
[ 0.24096554]
[  2.67997544e-04   2.79362161e-04  -9.53859234e-05]
95
[ 0.20343098]
[-0.00046853 -0.00088936 -0.00049681]
96
[ 0.24732773]
[ -9.04392554e-05  -5.18797874e-05  -6.89241116e-05]
97
[ 0.01235933]
[  1.18191025e-05   2.87167191e-06  -2.19328323e-05]
98
[ 0.12027377]
[  4.18167116e-05   8.32708362e-06  -1.30734572e-05]
100
[ 0.07752724]
[  1.43050811e-05   1.99109756e-05   2.79554776e-05]
101
[ 0.1258121]
[ -7.43941198e-06  -1.31521085e-05  -1.62140790e-05]
102
[ 0.13920137]
[ 0.00022071  0.00033378  0.00018195]
103
[ 0.06304432]
[  7.55038374e-05  -1.74650519e-04  -1.23944280e-05]
104
[ 0.03709201]
[  5.02825361e-06  -1.13902917e-05   7.15796010e-06]
105
[ 0.03005789]
[  6.84329929e-06  -5.07541523e-06   3.97869683e-05]
106
[ 0.04314657]
[ -1.01605022e-06  -8.78351220e-06  -6.68466416e-06]
107
[ 0.08229131]
[  1.89168514e-05   3.75765855e-06   2.77173821e-05]
108
[ 0.23574705]
[ -1.34464732e-05  -2.41324716e-05  -1.42632594e-05]
109
[ 0.12361972]
[ -7.85588312e-05  -6.21012291e-05   8.14867460e-06]
110
[ 0.06587144]
[  8.59484683e-06   7.20151974e-06  -4.59180354e-06]
111
[ 0.00517671]
[ -6.55733762e-07  -1.37122187e-06  -3.25385452e-06]
112
[ 0.00824337]
[  5.40466473e-07   3.85751183e-06   2.16500182e-05]
113
[ 0.00892268]
[ -3.36437221e-07  -1.06837792e-06  -3.16969019e-05]
114
[ 0.05467424]
[ -1.50303573e-05  -1.24837422e-05  -1.22262352e-05]
115
[ 0.08535049]
[  1.72138953e-05  -1.98514313e-06   3.98408253e-05]
116
[ 0.01070104]
[ -3.51201235e-06  -4.98299429e-06   6.31858566e-06]
117
[ 0.05810437]
[ -1.06078949e-05  -2.76028864e-05  -9.75356103e-06]
118
[ 0.02407476]
[  9.97575775e-07   2.66240240e-06   1.81560558e-06]
119
[ 0.11448889]
[  2.66345858e-05   6.53450304e-05   4.56936426e-05]
120
[ 0.04583144]
[-0.00110138 -0.00134944  0.00274399]
121
[ 0.01693011]
[  3.51037320e-06  -1.53394971e-06  -1.47755893e-05]
122
[ 0.01130757]
[  1.02491539e-06  -1.32181498e-05  -9.11777645e-06]
123
[ 0.09509441]
[  1.06039079e-05   3.68698137e-06   6.67536229e-07]
124
[ 0.04725852]
[  6.78050171e-06  -1.89205737e-05   2.95297449e-05]
125
[ 0.09252859]
[ -1.78285571e-06  -1.20405165e-05  -9.70483659e-06]
126
[ 0.00737194]
[  2.44696325e-06   5.73264523e-06  -3.83304382e-05]
127
[ 0.01972596]
[  2.68798956e-05   2.48627800e-05   1.29571519e-04]
128
[ 0.05028734]
[ -1.77884491e-05  -1.94968595e-05   1.85222317e-05]
129
[ 0.0128879]
[ -1.61132849e-06  -6.05832663e-06   5.64957090e-06]
24
[ 0.02960903]
[ -3.82494993e-05  -1.26149824e-05   2.74223801e-05]
28
[ 0.067364]
[ 0.00028325  0.00023156 -0.0001073 ]
35
[ 0.09550212]
[ -7.23513712e-05  -9.89278917e-05   1.36539675e-05]
99
[ 0.25012978]
[ -4.69434941e-05  -5.40210591e-05   1.05952824e-05]
18
[ 0.22715359]
[  2.99967248e-05   1.55984693e-05   1.19662402e-05]
19
[ 0.15512205]
[  4.20261701e-05   2.22774535e-05   6.07549519e-05]
29
[ 0.09790899]
[ -6.22914505e-05  -2.24279505e-05  -5.84757875e-05]
36
[ 0.06585638]
[  2.72518335e-05   3.98542674e-07   3.46198969e-05]
1
[ 0.44469825]
[ 0.00019117  0.00017356  0.0001844 ]
2
[ 0.01382215]
[  6.24644550e-07   4.30781226e-05   3.17138095e-05]
5
[ 0.11697765]
[  4.25303543e-05   4.41366541e-05   7.97249361e-05]
9
[ 0.20832215]
[  2.38448521e-04   9.15951069e-05   1.68269239e-04]
13
[ 0.03254999]
[  1.10044973e-05   3.36329884e-05   4.14076438e-05]
14
[ 0.38411027]
[-0.00066851 -0.00060699 -0.00105376]
16
[ 0.20058753]
[  3.59359939e-05   3.18327776e-05  -3.92947478e-06]
20
[ 0.23172027]
[  6.33172621e-05   6.35099482e-05   7.92619477e-05]
25
[ 0.40747164]
[ 0.00213864  0.00161765  0.0013007 ]
33
[ 0.12403392]
[  5.67749907e-05   6.99045380e-05   6.71369605e-05]
34
[ 0.1518928]
[ -3.38990632e-05  -6.74112552e-05  -5.03078447e-05]
[0, 3, 4, 6, 7, 8, 10, 11, 12, 15, 17, 21, 22, 23, 26, 27, 30, 31, 32, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 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, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 24, 28, 35, 99, 18, 19, 29, 36, 1, 2, 5, 9, 13, 14, 16, 20, 25, 33, 34]

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 [ ]: